TableSpec#

class caput.containers.TableSpec(*args: tuple, **kwargs: dict)[source]#

Bases: ContainerPrototype

A base class for containers holding tables of data.

Similar to the ContainerPrototype class, a container is defined through a dictionary given as a _table_spec class attribute when subclassing this base class. The container may also hold generic datasets by specifying _dataset_spec as with ContainerPrototype. See Notes for details.

Optional Parameters#

kwargsdict

Should contain definitions for all other table axes.

Notes

A _table_spec consists of a dictionary mapping table names into a description of the table. That description is another dictionary containing several entries.

  • columns : the set of columns in the table. Given as a list of (name, dtype) pairs.

  • axis : an optional name for the rows of the table. This is automatically generated as <tablename>_index if not explicitly set. This corresponds to an index_map entry on the container.

  • initialise : whether to create the table by default.

  • distributed : whether the table is distributed, or common across all MPI ranks.

An example _table_spec entry is:

_table_spec = {
    'quasars': {
        'columns': [
            ['ra': np.float64],
            ['dec': np.float64],
            ['z': np.float64]
        ],
        'distributed': False,
        'axis': 'quasar_id'
    }
    'quasar_mask': {
        'columns': [
            ['mask', bool]
        ],
        'axis': 'quasar_id'
    }
}
property table_spec: dict[str, dict][source]#

Return a copy of the fully resolved table specifiction as a dictionary.