Skip to content

Types (polykin.utils.typing)¤

Type aliases and variables for numeric scalars and NumPy arrays.

This module provides a centralized set of type hints used throughout PolyKin to ensure consistency and improve code readability. It leverages numpy.typing for data type validation and uses PEP 585-style shape annotations to provide informal hints about array dimensions.

Note: While shapes (e.g., 1D vectors vs 2D matrices) are annotated in the type aliases, most static type checkers (like Mypy) do not yet strictly enforce NumPy array shapes.

FloatArray module-attribute ¤

FloatArray = NDArray[float64]

A NumPy array of float64 (any shape).

FloatArrayLike module-attribute ¤

FloatArrayLike: TypeAlias = (
    list[float] | tuple[float, ...] | FloatArray
)

An object convertible to a float64 array (list, tuple, or NDArray).

FloatVector module-attribute ¤

FloatVector: TypeAlias = ndarray[tuple[int], dtype[float64]]

A 1-dimensional NumPy array of float64.

FloatVectorLike module-attribute ¤

FloatVectorLike: TypeAlias = (
    list[float] | tuple[float, ...] | FloatVector
)

An object convertible to a 1D float64 vector.

Float2x2Matrix module-attribute ¤

Float2x2Matrix: TypeAlias = ndarray[
    tuple[Literal[2], Literal[2]], dtype[float64]
]

A 2x2 NumPy array of float64.

FloatMatrix module-attribute ¤

FloatMatrix: TypeAlias = ndarray[
    tuple[int, int], dtype[float64]
]

A 2-dimensional NumPy array of float64.

FloatSquareMatrix module-attribute ¤

FloatSquareMatrix: TypeAlias = ndarray[
    tuple[int, int], dtype[float64]
]

A 2-dimensional float64 array with implicitly equal dimensions.

FloatRangeArray module-attribute ¤

FloatRangeArray: TypeAlias = ndarray[
    tuple[Literal[2]], dtype[float64]
]

A NumPy array of shape (2,) used to define [min, max] ranges.

IntArray module-attribute ¤

IntArray = NDArray[int_]

A NumPy array of integers (any shape).

IntArrayLike module-attribute ¤

IntArrayLike: TypeAlias = (
    list[int] | tuple[int, ...] | IntArray
)

An object convertible to an integer array (list, tuple, or NDArray).

IntVector module-attribute ¤

IntVector: TypeAlias = ndarray[tuple[int], dtype[int_]]

A 1-dimensional NumPy array of integers.

IntVectorLike module-attribute ¤

IntVectorLike: TypeAlias = (
    list[int] | tuple[int, ...] | IntVector
)

An object convertible to a 1D integer vector.

Number module-attribute ¤

Number = TypeVar('Number', float, complex)

A TypeVar bound to float or complex for generic numeric operations.