Skip to content

Generic

Validation of individual data items that can appear in multiple kinds of file.

check_column

check_column(name: str, dtype: dtype, col: ColumnObject) -> list[str]

'col' is a ColumnObject describing one column of a table. 'name' and 'dtype' are the name and dtype of one field of a numpy structured array, which is supposed to agree with 'spec'. Compare them and return a list of differences. An empty list means they do agree.

check_meta

check_meta(val: str | bool | float | int, spec: ObjectMetadata) -> str | None

'spec' describes the constraints on a metadata item, and 'val' is the actual value of that metadata item. Check whether 'val' is a legitimate value according to 'spec'. Return None if it is, or a description of the mismatch if it is not.

check_schema

check_schema(dtype: dtype, spec: DataObject) -> dict[str, list[str]]

'spec' is a DataObject describing a table. 'dtype' is the dtype of a numpy structured array, which should agree with the table schema defined by 'spec'. Compare the two. Return a description of the differences; if it is empty, they match.

Comparison is order sensitive: np.dtype([('name', 'U10'), ('age', 'i4')]) does not match [ColumnObject(name='age', dtype='i4'), ColumnObject(name='name', dtype='U10')].

normalize_dt_rep

normalize_dt_rep(dtype: dtype) -> str

'Normalized' string representation of a numpy dtype, agnostic to byteorder, repeated elements, dimensionality, etc. Will not produce satisfying results on dtypes with multiple fields.