Skip to content

epymorph.data_type

Types for source data and attributes in epymorph.

ScalarType module-attribute

ScalarType = type[int | float | str | date]

StructType module-attribute

StructType = tuple[tuple[str, ScalarType], ...]

AttributeType module-attribute

AttributeType = ScalarType | StructType

The allowed type declarations for epymorph attributes.

ScalarValue module-attribute

ScalarValue = int | float | str | date

StructValue module-attribute

StructValue = tuple[ScalarValue, ...]

AttributeValue module-attribute

AttributeValue = ScalarValue | StructValue

The allowed types for epymorph attribute values (specifically: default values).

ScalarDType module-attribute

ScalarDType = int64 | float64 | str_ | datetime64

StructDType module-attribute

StructDType = void

AttributeDType module-attribute

AttributeDType = ScalarDType | StructDType

The subset of numpy dtypes for use in epymorph: these map 1:1 with AttributeType.

AttributeArray module-attribute

AttributeArray = NDArray[AttributeDType]

CentroidType module-attribute

CentroidType: AttributeType = (
    ("longitude", float),
    ("latitude", float),
)

Structured epymorph type declaration for long/lat coordinates.

CentroidDType module-attribute

CentroidDType: dtype[void] = dtype_as_np(CentroidType)

The numpy equivalent of CentroidType (structured dtype for long/lat coordinates).

SimDType module-attribute

SimDType = int64

This is the numpy datatype that should be used to represent internal simulation data. Where segments of the application maintain compartment and/or event counts, they should take pains to use this type at all times (if possible).

SimArray module-attribute

SimArray = NDArray[SimDType]

dtype_as_np

dtype_as_np(dtype: AttributeType) -> dtype

Return a python-style dtype as its numpy-equivalent.

dtype_str

dtype_str(dtype: AttributeType) -> str

Return a human-readable description of the given dtype.

dtype_check

dtype_check(dtype: AttributeType, value: Any) -> bool

Checks that a value conforms to a given dtype. (Python types only.)