This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / sctype2char

function

numpy:sctype2char

source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/numerictypes.py :541

Signature

def   sctype2char ( sctype )

Summary

Return the string representation of a scalar dtype.

Parameters

sctype : scalar dtype or object

If a scalar dtype, the corresponding string character is returned. If an object, sctype2char tries to infer its scalar type and then return the corresponding string character.

Returns

typechar : str

The string character corresponding to the scalar type.

Raises

: ValueError

If sctype is an object for which the type can not be inferred.

Examples

from numpy._core.numerictypes import sctype2char
for sctype in [np.int32, np.double, np.cdouble, np.bytes_, np.ndarray]:
    print(sctype2char(sctype))
x = np.array([1., 2-1.j])
sctype2char(x)
sctype2char(list)

See also

issctype
issubsctype
mintypecode
obj2sctype

Aliases

  • numpy._core.fromnumeric._dt_