dtypes

dtypes(*, device: device | None = None, kind: str | Tuple[str, ...] | None = None) DataTypes

Returns a dictionary of supported Array API data types.

Note

While specification-conforming array libraries may support additional data types which are not present in this specification, data types which are not present in this specification should not be included in the returned dictionary.

Note

Specification-conforming array libraries must only return supported data types having expected properties as described in Data Types. For example, if a library decides to alias float32 as float64, that library must not include float64 in the dictionary of supported data types.

Parameters:
  • kind (Optional[Union[str, Tuple[str, ...]]]) –

    data type kind.

    • If kind is None, the function must return a dictionary containing all supported Array API data types.

    • If kind is a string, the function must return a dictionary containing the data types belonging to the specified data type kind. The following data type kinds must be supported:

      • 'bool': boolean data types (e.g., bool).

      • 'signed integer': signed integer data types (e.g., int8, int16, int32, int64).

      • 'unsigned integer': unsigned integer data types (e.g., uint8, uint16, uint32, uint64).

      • 'integral': integer data types. Shorthand for ('signed integer', 'unsigned integer').

      • 'real floating': real-valued floating-point data types (e.g., float32, float64).

      • 'complex floating': complex floating-point data types (e.g., complex64, complex128).

      • 'numeric': numeric data types. Shorthand for ('integral', 'real floating', 'complex floating').

    • If kind is a tuple, the tuple specifies a union of data type kinds, and the function must return a dictionary containing the data types belonging to at least one of the specified data type kinds.

    Default: None.

  • device (Optional[device]) –

    device for which to return supported data types. If device is None, the returned data types must be the supported data types for the current device; otherwise, the returned data types must be supported data types specific to the specified device. Default: None.

    Note

    Some array libraries have the concept of a device context manager, allowing library consumers to manage the current device context. When device is None, libraries supporting a device context should return the supported data types for the current device. For libraries without a context manager or supporting only a single device, those libraries should return the supported data types for the default device.

Returns:

out (DataTypes) – a dictionary containing supported data types.

Note

Dictionary keys must only consist of canonical names as defined in Data Types.

Notes