You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / _core / numerictypes / obj2sctype

function

numpy._core.numerictypes:obj2sctype

source: /numpy/_core/numerictypes.py :239

Signature

def   obj2sctype ( rep default = None )

Summary

Return the scalar dtype or NumPy equivalent of Python type of an object.

Parameters

rep : any

The object of which the type is returned.

default : any, optional

If given, this is returned for objects whose types can not be determined. If not given, None is returned for those objects.

Returns

dtype : dtype or Python type

The data type of rep.

Examples

from numpy._core.numerictypes import obj2sctype
obj2sctype(np.int32)
obj2sctype(np.array([1., 2.]))
obj2sctype(np.array([1.j]))
obj2sctype(dict)
obj2sctype('string')
obj2sctype(1, default=list)

See also

issctype
issubdtype
issubsctype
sctype2char

Aliases

  • numpy._core.numerictypes.obj2sctype