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

init

Base class for a hashable wrapped ndarray.

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

call

Return a reference to the stored NDArray.

Warning

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

  • 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

hash

Return hash created during initialization. Hash only remains valid if NDArray’s flag remains off.

__eq__(other: object) bool

equality comparison

param other:

The object being compared to self.

returns:

True if object is another HWrapNDArray all whose corresponding components are equal to the ones in self.

abstractmethod __repr__() str

Return repr(self).

__str__() str

user string

returns:

String meaningful to an end user.

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

copy

Return a copy of the wrapped NDArray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayNumber

Bases: HWrapNDArray

wrapped numeric ndarray

Class for a hashable wrapped numeric ndarray.

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

init

Wrap NDArray of arbitrary NumPy numeric types.

__repr__() str

repr string

returns:

String to reproduce the wrapped numeric ndarray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayString

Bases: HWrapNDArray

wrapped string ndarray

Class for a hashable wrapped string ndarray.

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

init

Wrap NDArray of Unicode strings.

__repr__() str

repr string

returns:

String to reproduce the wrapped string ndarray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayBytes

Bases: HWrapNDArray

wrapped byte ndarray

Class for a hashable wrapped null-terminated byte sequence ndarray.

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

init

Wrap NDArray of null-terminated byte sequences.

__repr__() str

repr string

returns:

String to reproduce the wrapped null-terminated byte sequence ndarray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayVoid

Bases: HWrapNDArray

wrapped void ndarray

Class for a hashable wrapped arbitrary byte sequence ndarray.

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

init

Wrap NDArray of arbitrary byte sequences.

__repr__() str

repr string

returns:

String to reproduce the wrapped arbitrary byte sequence ndarray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayObject

Bases: HWrapNDArray

wrapped object reference ndarray

Class for a hashable wrapped object reference ndarray.

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

init

Wrap NDArray of references to arbitrary Python objects.

__repr__() str

repr string

returns:

String to reproduce the wrapped object reference ndarray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayDateTime

Bases: HWrapNDArray

wrapped datetime ndarray

Class for a hashable wrapped datatime ndarray.

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

init

Wrap NDArray of datetimes.

__repr__() str

repr string

returns:

String to reproduce the wrapped datetime ndarray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayTimeDelta

Bases: HWrapNDArray

wrapped timedelta ndarray

Class for a hashable wrapped timedelta ndarray.

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

init

Wrap NDArray of timedeltas.

__repr__() str

repr string

returns:

String to reproduce the wrapped timedelta ndarray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayBool

Bases: HWrapNDArray

wrapped Boolean ndarray

Class for a hashable wrapped Boolean ndarray.

Note

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

  • * uses component-wise Boolean and

  • + uses component-wise Boolean or

  • @ matrix multiplication using and then or

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

init

Wrap NDArray of Booleans.

__repr__() str

repr string

returns:

String to reproduce the wrapped Boolean ndarray.