Skip to content

Commit 3408583

Browse files
bendichterclaude
andcommitted
Address review: add copy=False check, pass dtype directly to np.array
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 605f02f commit 3408583

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

lindi/LindiH5pyFile/LindiH5pyDataset.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,14 @@ def _is_empty(self):
174174
return False
175175

176176
def __array__(self, dtype=None, copy=None):
177+
if copy is False:
178+
raise ValueError(
179+
"LindiH5pyDataset.__array__ received copy=False "
180+
"but memory allocation cannot be avoided on read"
181+
)
177182
if self._is_scalar:
178-
arr = np.array(self[()])
179-
else:
180-
arr = np.array(self[:])
181-
if dtype is not None:
182-
arr = arr.astype(dtype)
183-
return arr
183+
return np.array(self[()], dtype=dtype)
184+
return np.array(self[:], dtype=dtype)
184185

185186
def __repr__(self): # type: ignore
186187
return f"<{self.__class__.__name__}: {self.name}>"

0 commit comments

Comments
 (0)