check_is_mtype#
- check_is_mtype(obj, mtype, scitype: str = None, return_metadata=False, var_name='obj', msg_return_dict='dict')[source]#
Check object for compliance with mtype specification, return metadata.
See glossary for explanations of :glossary:`mtype` and :glossary:`scitype`.
- Parameters:
- obj - object to check
- mtype: str or list of str, mtype to check obj as
valid mtype strings are in datatypes.MTYPE_REGISTER (1st column)
- scitype: str, optional, scitype to check obj as; default = inferred from mtype
if inferred from mtype, list elements of mtype need not have same scitype valid mtype strings are in datatypes.SCITYPE_REGISTER (1st column)
- return_metadata - bool, str, or list of str, optional, default=False
if False, returns only
valid
return. No metadata is returned.if True, returns all three return objects. All metadata fields are returned.
if str, list of str, metadata return dict is subset to keys in
return_metadata
. This allows selective return of metadata fields, to avoid unnecessary computation.- var_name: str, optional, default=”obj”
name of input in error messages
- msg_return_dict: str, one of ``”list”`` or ``”dict”``, optional, default=”dict”
whether returned msg, if returned, is a str, dict or list
if
msg_return_dict="list"
,
returned
msg
isstr
ifmtype
isstr
, returnedmsg
islist
ofstr
ifmtype
islist
if
msg_return_dict="dict"
,
returned
msg
isstr
ifmtype
isstr
, returnedmsg
isdict
ofstr
ifmtype
islist
. Ifdict
, has str inmtype
as key, and error message for mtype as value.
- Returns:
- valid: bool
whether obj is a valid object of mtype/scitype
- msg: str or list/dict of str
error messages if object is not valid, otherwise None
list or dict type is controlled via
msg_return_dict
argumentif str: error message for tested mtype
it list: list of len(mtype) with message per mtype if list,
same order as in
mtype
parameter * if dict: dict with mtype as key and error message for mtype as value * returned only if return_metadata is True or str, list of str- metadata: dict - metadata about obj if valid, otherwise None
returned only if
return_metadata
is True or str, list of strKeys populated depend on (assumed, otherwise identified) scitype of obj.
Always returned:
“mtype”: str, mtype of obj (assumed or inferred)
“scitype”: str, scitype of obj (assumed or inferred)
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 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
“n_instances”: int, number of instances/rows in the table
For scitype “Alignment”:
“is_multiple” : bool, True iff multiple alignment of (3 or more) series
- Raises:
- TypeError if no checks defined for mtype/scitype combination
- TypeError if mtype input argument is not of expected type