Skip to content

Commit b298699

Browse files
committed
fix: reshape read frames
1 parent 37b131f commit b298699

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/nd2/_nd2file.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,8 +1251,7 @@ def read_frame(self, frame_index: SupportsInt) -> np.ndarray:
12511251
12521252
!!! Tip "new in version 0.8.0"
12531253
"""
1254-
frame = self._rdr.read_frame(int(frame_index))
1255-
frame.shape = self._raw_frame_shape
1254+
frame = self._rdr.read_frame(int(frame_index)).reshape(self._raw_frame_shape)
12561255
return frame.transpose((2, 0, 1, 3)).squeeze()
12571256

12581257
@cached_property

tests/test_reader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
DATA = Path(__file__).parent / "data"
1515

1616

17+
@pytest.mark.filterwarnings(
18+
"error:Setting the shape on a NumPy array has been deprecated:DeprecationWarning"
19+
)
1720
def test_read_safety(new_nd2: Path):
1821
with ND2File(new_nd2) as nd:
1922
for i in range(nd._frame_count):
20-
nd._rdr.read_frame(i)
23+
nd.read_frame(i)
2124

2225

2326
def test_position(new_nd2: Path):

0 commit comments

Comments
 (0)