reprospect.utils.types module

Type information for numeric scalar types.

The minimal information needed to describe a numeric type is:

  • kind and signedness — integer or floating-point, signed or unsigned (see Kind)

  • bits — width in bits (e.g. 16, 32, 64, 128)

This module provides TypeInfo to carry this information.

Note

Several alternatives to writing this module have been considered:

class reprospect.utils.types.Kind(*values)View on GitHub

Bases: Enum

FLOAT = 3
INT = 1
UINT = 2
classmethod from_numpy(kind: str) SelfView on GitHub

See https://numpy.org/doc/stable/reference/generated/numpy.dtype.kind.html.

property signed: boolView on GitHub
class reprospect.utils.types.TypeInfo(bits: int, kind: Kind)View on GitHub

Bases: object

Minimal type information.

__init__(bits: int, kind: Kind) None
bits: int

Number of bits.

property itemsize: intView on GitHub
kind: Kind
classmethod normalize(*, dtype: TypeInfo | int | DTypeLike) SelfView on GitHub
property signed: boolView on GitHub