Skip to content

Commit

Permalink
Fixed HSPY reader issue and tests for Hyperspy2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewHerzing committed Apr 10, 2024
1 parent a8ffedb commit b1804b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tomotools/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def load(filename, tilts=None):
if type(filename) is str:
ext = os.path.splitext(filename)[1]
if ext.lower() in hspy_file_types:
stack = hspy.load(filename)
stack = hspy.load(filename, reader='HSPY')
if stack.metadata.has_item("Tomography"):
tilts = stack.metadata.Tomography.tilts
elif ext.lower() in dm_file_types:
Expand Down
8 changes: 5 additions & 3 deletions tomotools/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def test_load_mrc_with_rawtlt(self):
filename = os.path.join(tomotools_path, "tests",
"test_data", "HAADF.mrc")
stack = tomotools.io.load(filename)
stack.original_metadata = {}
del stack.original_metadata.fei_header
del stack.original_metadata.std_header
tilts = tomotools.io.get_mrc_tilts(stack, filename)
assert type(tilts) is np.ndarray
assert tilts.shape[0] == stack.data.shape[0]
Expand All @@ -74,7 +75,8 @@ def test_load_mrc_with_bad_rawtlt(self):
filename = os.path.join(tomotools_path, "tests",
"test_data", "HAADF.mrc")
stack = tomotools.io.load(filename)
stack.original_metadata = {}
del stack.original_metadata.fei_header
del stack.original_metadata.std_header
stack.data = np.append(stack.data, np.zeros([1, stack.data.shape[1], stack.data.shape[2]]), axis=0)
with pytest.raises(ValueError):
tomotools.io.get_mrc_tilts(stack, filename)
Expand All @@ -96,7 +98,7 @@ def test_convert_signal2d(self):
def test_load_hspy_hdf5(self):
filename = os.path.join(tomotools_path, "tests",
"test_data", "HAADF_Aligned.hdf5")
stack_orig = hs.load(filename)
stack_orig = hs.load(filename, reader='HSPY')
stack = tomotools.io.load(filename)
with h5py.File(filename, 'r') as h5:
h5_shape = h5['Experiments']['__unnamed__']['data'].shape
Expand Down

0 comments on commit b1804b7

Please sign in to comment.