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, Generic

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) → None

init

Base class for a hashable wrapped NDArray.

__call__() → NDArray

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

copy

Return a read-write copy of the wrapped NDArray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayNumber

Bases: HWrapNDArray[number]

wrapped numeric NDArray

Wrapped 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[str_]

wrapped string NDArray

Wrapped 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[bytes_]

wrapped byte NDArray

Wrapped NDArray of null-terminated bytes.

__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[void]

wrapped void NDArray

Wrapped 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[object_]

wrapped object reference NDArray

Wrapped NDArray of object references.

Deprecated since version 6.1.0: Object arrays cannot be hashed consistently with equality. Use a typed dtype instead. Removed in 7.0.0.

__repr__() → str

repr string

returns:

String to reproduce the wrapped object reference NDArray.

classmethod __init_subclass__(*args, **kwargs)

Function to initialize subclasses.

static __new__(*args, **kwargs)
class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayDateTime

Bases: HWrapNDArray[datetime64]

wrapped datetime NDArray

Wrapped NDArray of datetime references.

__repr__() → str

repr string

returns:

String to reproduce the wrapped datetime NDArray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayTimeDelta

Bases: HWrapNDArray[timedelta64]

wrapped timedelta NDArray

Wrapped NDArray of timedelta references.

__repr__() → str

repr string

returns:

String to reproduce the wrapped timedelta NDArray.

class pythonic_fp.numpy.hashable_wrapped_ndarray.HWrapNDArrayBool

Bases: HWrapNDArray[bool]

wrapped Boolean NDArray

Wrapped NDArray of NumPy Booleans.

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

__repr__() → str

repr string

returns:

String to reproduce the wrapped Boolean NDArray.