Skip to content

Commit 44db623

Browse files
author
Luke Shaw
committed
Add direct cast to numpy array in SimpleProxy getitem
1 parent 78bf78d commit 44db623

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/blosc2/proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ def __getitem__(self, item: slice | list[slice]) -> np.ndarray:
667667
out: numpy.ndarray
668668
An array with the data slice.
669669
"""
670-
return self._src[item]
670+
return np.asarray(self._src[item]) # avoids copy for PyTorch at least
671671

672672

673673
def jit(func=None, *, out=None, disable=False, **kwargs): # noqa: C901

tests/ndarray/test_elementwise_funcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _test_binary_func_proxy(np_func, blosc_func, dtype, shape, chunkshape, xp):
136136
assert True
137137
if success:
138138
try:
139-
result = blosc_func(not_blosc1, a_blosc2)[...]
139+
result = blosc_func(not_blosc1, a_blosc2)[()]
140140
np.testing.assert_allclose(result, expected, rtol=1e-6, atol=1e-6)
141141
except TypeError as e:
142142
# some functions don't support certain dtypes and that's fine

0 commit comments

Comments
 (0)