Skip to content

Commit

Permalink
Avoid reshaping
Browse files Browse the repository at this point in the history
The reshape was just used to determine the image count. Replaced with size calculation.
  • Loading branch information
uellue committed Mar 17, 2023
1 parent 79fc712 commit c0259c8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libertem/io/dataset/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ def __init__(self, tileshape=None, num_partitions=None, data=None, sig_dims=None
sig_shape = data.shape[-sig_dims:]
else:
sig_shape = tuple(sig_shape)
reshaped_data = self.data.reshape((-1, *sig_shape))
if self.data.size % prod(sig_shape) != 0:
raise ValueError("Data size is not a multiple of sig shape")
self._image_count = self.data.size // prod(sig_shape)
self._nav_shape = nav_shape
self._sig_shape = sig_shape
self._sync_offset = sync_offset
Expand All @@ -264,7 +266,6 @@ def __init__(self, tileshape=None, num_partitions=None, data=None, sig_dims=None
self._tiledelay = tiledelay
self._force_need_decode = force_need_decode
self._nav_shape_product = int(prod(nav_shape))
self._image_count = int(prod(reshaped_data.shape[:-sig_dims]))
self._shape = Shape(
nav_shape + sig_shape, sig_dims=self.sig_dims
)
Expand Down

0 comments on commit c0259c8

Please sign in to comment.