hashable_wrapped_ndarray

class pythonic_fp.numpy.hashable_wrapped_ndarray.DTypes

Bases: Enum

Enumeration of closed NumPy datatypes.

Groups (Unions) of NumPy datatypes closed to NumPy operations.

  • number

  • str_

  • bytes

  • datetime64

  • timedelta64

  • bool_

  • void

  • object_

While NumPy types are extensively covariant, the NumPy C internals are somewhat invariant. NumPy also suffers from what I call “Fortran Disease”, types get “auto-promoted” to compatible “wider types” when necessary. That is fine when dealing with operators on mixed types, but NumPy will auto-promote with operations on the same type.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArray

Bases: ABC

Make NumPy NDArrays hashable.

Just making an NDArray (np.array) readonly is not enough. This class stores a read-only copy of the NDArray given to the constructor and is hashable.

__init__(ndarray: ndarray[tuple[Any, ...], dtype[generic]]) None
abstractmethod __repr__() str

Return repr(self).

__call__() ndarray[tuple[Any, ...], dtype[number]]

Return a reference to the stored NDArray.

Warning

For efficiency this method returns a reference to the wrapped NDArray.

  • Allows for faster slicing and faster operations.

  • Use the copy method if you want a read-write copy.

  • Never make the underlying NDArray writable!!!

__hash__() int

Return hash(self).

__eq__(other: object) bool

Return self==value.

__str__() str

Return str(self).

copy() ndarray[tuple[Any, ...], dtype[number]]

Return a copy of the wrapped NDArray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayNumber

Bases: HWrapNDArray

Wrap NDArrays of arbitrary NumPy numeric types.

__init__(ndarray: ndarray[tuple[Any, ...], dtype[number]]) None
__repr__() str

Return repr(self).

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayString

Bases: HWrapNDArray

Wrap NDArrays of Unicode strings.

__init__(ndarray: ndarray[tuple[Any, ...], dtype[str_]]) None
__repr__() str

Return repr(self).

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayBytes

Bases: HWrapNDArray

Wrap NDArrays of null-terminated byte sequences.

__init__(ndarray: ndarray[tuple[Any, ...], dtype[bytes_]]) None
__repr__() str

Return repr(self).

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayVoid

Bases: HWrapNDArray

Wrap NDArrays of arbitrary byte sequences.

__init__(ndarray: ndarray[tuple[Any, ...], dtype[void]]) None
__repr__() str

Return repr(self).

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayObject

Bases: HWrapNDArray

Wrap NDArrays of references to arbitrary Python objects.

__init__(ndarray: ndarray[tuple[Any, ...], dtype[object_]]) None
__repr__() str

Return repr(self).

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayDateTime

Bases: HWrapNDArray

Wrap NDArrays of references to arbitrary Python objects.

__init__(ndarray: ndarray[tuple[Any, ...], dtype[datetime64]]) None
__repr__() str

Return repr(self).

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayTimeDelta

Bases: HWrapNDArray

Wrap NDArrays of references to arbitrary Python objects.

__init__(ndarray: ndarray[tuple[Any, ...], dtype[timedelta64]]) None
__repr__() str

Return repr(self).

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayBool

Bases: HWrapNDArray

Wrap NDArrays of Booleans.

NumPy Booleans are actual Booleans, unlike Python bools which are subtypes of int.

Note

  • * uses component-wise Boolean and

  • + uses component-wise Boolean or

  • @ does matrix multiplication using and then or

__init__(ndarray: ndarray[tuple[Any, ...], dtype[bool]]) None
__repr__() str

Return repr(self).