Skip to content

Commit

Permalink
Merge pull request #282 from swelborn/type-conversion-sparse-array
Browse files Browse the repository at this point in the history
avoid type conversion to float on h5 import
  • Loading branch information
swelborn authored Apr 28, 2023
2 parents 1152634 + bfee3a8 commit 3447fb0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/stempy/io/sparse_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ def from_hdf5(cls, filepath, **init_kwargs):
scan_shape = scan_shape[::-1]

if version >= 3:
# Convert to int to avoid integer division that results in
# a float
frames_per_scan = len(data) // np.prod(scan_shape, dtype=int)
# Need to reshape the data, as it was flattened before saving
frames_per_scan = len(data) // np.prod(scan_shape)
data = data.reshape((np.prod(scan_shape), frames_per_scan))

# We may need to convert the version of the data
Expand Down

0 comments on commit 3447fb0

Please sign in to comment.