SimpleProxy

Simple proxy for a NumPy array (or similar) that can be used with the Blosc2 compute engine.

This only supports the __getitem__ method. No caching is performed.

class blosc2.SimpleProxy(src, chunks: tuple | None = None, blocks: tuple | None = None)[source]

Simple proxy for any data container to be used with the compute engine.

The source must have a shape and dtype attributes; if not, it will be converted to a NumPy array via the np.asarray function. It should also have a __getitem__ method.

This only supports the __getitem__ method. No caching is performed.

Examples

>>> import numpy as np
>>> import blosc2
>>> a = np.arange(20, dtype=np.float32).reshape(4, 5)
>>> proxy = blosc2.SimpleProxy(a)
>>> proxy[1:3, 2:4]
[[ 7.  8.]
 [12. 13.]]
Attributes:
device
dtype

The data type of the source array.

shape

The shape of the source array.

src

The source object that this proxy wraps.

Methods

item()

Copy an element of an array to a standard Python scalar and return it.

where([value1, value2])

Select value1 or value2 values based on True/False for self.

to_device

Special Methods:

__init__(src[, chunks, blocks])

__getitem__(item)

Get a slice as a numpy.ndarray (via this proxy).

Constructor

__init__(src, chunks: tuple | None = None, blocks: tuple | None = None)[source]

Utility Methods

__getitem__(item: slice | list[slice]) ndarray[source]

Get a slice as a numpy.ndarray (via this proxy).

Parameters:

item

Returns:

out – An array with the data slice.

Return type:

numpy.ndarray

property dtype

The data type of the source array.

property shape

The shape of the source array.

property src

The source object that this proxy wraps.