check_is_scitype#
- check_is_scitype(obj, scitype: str | List[str], return_metadata=False, var_name='obj', exclude_mtypes=['numpyflat', 'alignment_loc'])[source]#
Check object for compliance with scitype specification, return metadata.
- Parameters:
- obj - object to check
- scitype: str or list of str, scitype to check obj as
valid mtype strings are in datatypes.SCITYPE_REGISTER
- return_metadata - bool, optional, default=False
if False, returns only “valid” return if True, returns all three return objects if str, list of str, metadata return dict is subset to keys in return_metadata
- var_name: str, optional, default=”obj” - name of input in error messages
- exclude_mtypeslist of str, default = AMBIGUOUS_MTYPES
which mtypes to ignore in inferring mtype, default = ambiguous ones
- Returns:
- valid: bool - whether obj is a valid object of mtype/scitype
- msg: dict[str, str] or None
error messages if object is not valid, otherwise None keys are all mtypes tested, value for key is error message for that key
- metadata: dict - metadata about obj if valid, otherwise None
returned only if return_metadata is True
Fields depend on scitpe. Always returned:
- “mtype”: str, mtype of obj (assumed or inferred)
mtype strings with explanation are in datatypes.MTYPE_REGISTER
- “scitype”: str, scitype of obj (assumed or inferred)
scitype strings with explanation are in datatypes.SCITYPE_REGISTER
- For scitype “Series”:
“is_univariate”: bool, True iff series has one variable “is_equally_spaced”: bool, True iff series index is equally spaced “is_empty”: bool, True iff series has no variables or no instances “has_nans”: bool, True iff the series contains NaN values
- For scitype “Panel”:
“is_univariate”: bool, True iff all series in panel have one variable “is_equally_spaced”: bool, True iff all series indices are equally spaced “is_equal_length”: bool, True iff all series in panel are of equal length “is_empty”: bool, True iff one or more of the series in the panel are empty “is_one_series”: bool, True iff there is only one series in the panel “has_nans”: bool, True iff the panel contains NaN values “n_instances”: int, number of instances in the panel
- For scitype “Table”:
“is_univariate”: bool, True iff table has one variable “is_empty”: bool, True iff table has no variables or no instances “has_nans”: bool, True iff the panel contains NaN values
- For scitype “Alignment”:
currently none
- Raises
- TypeError if scitype input argument is not of expected type