Skip to content

Commit aebaef5

Browse files
committed
Specify the requisites of the input of a SimpleProxy
1 parent 8bb72d6 commit aebaef5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/blosc2/proxy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,11 @@ def __getitem__(self, item: slice | list[slice]) -> np.ndarray:
546546

547547
class SimpleProxy(blosc2.Operand):
548548
"""
549-
Simple proxy for a NumPy array (or similar) that can be used with the Blosc2 compute engine.
549+
Simple proxy for any data container to be used with the compute engine.
550+
551+
The source must have a `shape` and `dtype` attributes; if not,
552+
it will be converted to a NumPy array via the `np.asarray` function.
553+
It should also have a `__getitem__` method.
550554
551555
This only supports the __getitem__ method. No caching is performed.
552556
@@ -565,6 +569,8 @@ def __init__(self, src, chunks: tuple | None = None, blocks: tuple | None = None
565569
if not hasattr(src, "shape") or not hasattr(src, "dtype"):
566570
# If the source is not a NumPy array, convert it to one
567571
src = np.asarray(src)
572+
if not hasattr(src, "__getitem__"):
573+
raise TypeError("The source must have a __getitem__ method")
568574
self._src = src
569575
self._dtype = src.dtype
570576
self._shape = src.shape

0 commit comments

Comments
 (0)