jztools.numpy#

Functions

argmax_accumulate(a)

Returns the accumulated max and argmax.

decode_ndarray(arr_bytes[, serializer])

Inverts the operation of encode_ndarray().

encode_ndarray(arr[, serializer])

Produces a bytes string containing the input array, including shape and dtype information.

random_array(shape, dtype[, rng])

Returns an array from random bytes of the specified dtype (can be structured).

randomizer(specifier)

Outputs a numpy.random.Generator based on the input.

raw_decode_ndarray(arr_bytes, dtype, shape)

Inverts the operation of raw_encode_ndarray().

raw_encode_ndarray(arr)

Produces a bytes string containing the input array, which can be re-constructed from the bytes string using decode_ndarray.

structured_to_unstructured(arr[, dtype])

Alternative to numpy.lib.recfunctions import structured_to_unstructured, which has a memory leak in

Classes

CircularArray(shape[, dtype, values])

param shape:

The shape of the circular array. Circular inserts occur over the first dimension.

jztools.numpy.randomizer(specifier: bool | int | Generator | None)#

Outputs a numpy.random.Generator based on the input. :param specifier: An integer used as the seed, or a passed-through numpy.random.Generator object or False to return None.

jztools.numpy.random_array(shape, dtype, rng=None)#

Returns an array from random bytes of the specified dtype (can be structured).

jztools.numpy.structured_to_unstructured(arr, dtype=None)#

Alternative to numpy.lib.recfunctions import structured_to_unstructured, which has a memory leak in

jztools.numpy.argmax_accumulate(a)#

Returns the accumulated max and argmax. https://stackoverflow.com/questions/37855059/why-does-accumulate-work-for-numpy-maximum-but-not-numpy-argmax

jztools.numpy.raw_encode_ndarray(arr: ndarray) Tuple[bytes, dtype, Tuple[int]]#

Produces a bytes string containing the input array, which can be re-constructed from the bytes string using decode_ndarray.

Returns:

3-tuple of bytes representation of content, dtype and shape.

(See also encode_ndarray().)

jztools.numpy.raw_decode_ndarray(arr_bytes: bytes, dtype: dtype, shape: Tuple[int]) ndarray#

Inverts the operation of raw_encode_ndarray().

(See also encode_ndarray().)

jztools.numpy.encode_ndarray(arr: ndarray, serializer=None) bytes#

Produces a bytes string containing the input array, including shape and dtype information. The original array can be re-constructed from the output bytes string using decode_ndarray.

(See also raw_encode_ndarray().)

jztools.numpy.decode_ndarray(arr_bytes: bytes, serializer=None) ndarray#

Inverts the operation of encode_ndarray().

(See also raw_decode_ndarray().’)