mtype(obj, as_scitype: Optional[Union[str, List[str]]] = None, exclude_mtypes=['numpyflat', 'alignment_loc'])[source]#

Infer the mtype of an object considered as a specific scitype.

objobject to infer type of - any type, should comply with some mtype spec

if as_scitype is provided, this needs to be mtype belonging to scitype

as_scitypestr, list of str, or None, optional, default=None

name of scitype(s) the object “obj” is considered as, finds mtype for that if None (default), does not assume a specific as_scitype and tests all mtypes

generally, as_scitype should be provided for maximum efficiency

valid scitype type strings are in datatypes.SCITYPE_REGISTER (1st column)

exclude_mtypeslist of str, default = AMBIGUOUS_MTYPES

which mtypes to ignore in inferring mtype, default = ambiguous ones

str - the inferred mtype of “obj”, a valid mtype string

or None, if obj is None

mtype strings with explanation are in datatypes.MTYPE_REGISTER

TypeError if no type can be identified, or more than one type is identified