fastcs.datatypes.datatype#

Members

DType

A builtin (or numpy) type supported by a corresponding FastCS Attribute DataType

DType_T

A TypeVar of DType for use in generic classes and functions

DataType

Generic datatype mapping to a python type, with additional metadata.

fastcs.datatypes.datatype.DType = int | float | bool | str | enum.Enum | numpy.ndarray#

A builtin (or numpy) type supported by a corresponding FastCS Attribute DataType

class fastcs.datatypes.datatype.DType_T#

A TypeVar of DType for use in generic classes and functions

alias of TypeVar(‘DType_T’, bound=int | float | bool | str | Enum | ndarray)

class fastcs.datatypes.datatype.DataType[source]#

Generic datatype mapping to a python type, with additional metadata.

validate(value: Any) DType_T[source]#

Validate a value against the datatype.

The base implementation is to try the cast and raise a useful error if it fails.

Child classes can implement logic before calling super.validate(value) to modify the value passed in and help the cast succeed or after to perform further validation of the coerced type.

Parameters:

value – The value to validate

Returns:

The validated value

Raises:

ValueError – If the value cannot be coerced

static equal(value1: DType_T, value2: DType_T) bool[source]#

Compare two values for equality

Child classes can override this if the underlying type does not implement __eq__ or to define custom logic.

Parameters:
  • value1 – The first value to compare

  • value2 – The second value to compare

Returns:

True if the values are equal

classmethod all_equal(values: Sequence[DType_T]) bool[source]#

Compare a sequence of values for equality

Parameters:

values – Values to compare

Returns:

True if all values are equal, else False