Dealing with data types

dtype (obj, align=0)

Return a data-type object from any object. See Chapter 7 for a more detailed explanation of what can be interpreted as a data-type object and the meaning of the align keyword.

maximum_sctype (arg)

Returns the array-scalar type of highest precision of the same general kind as arg which can be any recognized form for describing a data-type.

issctype (obj)

Returns True if obj is an array data type (or a recognized alias for one) obj2sctype (obj, default=None)

Returns the array type object corresponding to obj which can be an array type already, a python type object, an actual array, or any recognized alias for an array type object. If no suitable data type object can be determined, return default.

sctype2char (sctype)

Return the typecode character associated with an array-scalar type dtype. The first argument is first converted to a dtype if it needs to be.

the type attribute of data-type objects are actual Python type objects subclassed in a hierarchy of types. This can often be useful to check data types generically. For example, issubclass(dtype.type, integer) can check to see if the data type is one of the 10 different integer types. The issubclass function, however, raises an error if either argument is not an actual type object. NumPy defines _(argl, arg2) that will return false instead of raise an error. Alternatively, dtype.kind is a character describing the class of the data-type so dtype.kind in 'iu' would also check to see if the data-type is an integer type.

Return Boolean value indicating whether or not data type d1 can be cast to data type d2 safely (without losing precision or information).

0 0

Post a comment