Skip to content

Commit

Permalink
Fix str / Path, add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
matbryan52 committed Jun 20, 2024
1 parent 03677db commit da491d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libertem/io/dataset/mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ def __init__(self, path, tileshape=None, scan_size=None, disable_glob=False,
if nav_shape is not None:
raise ValueError("cannot specify both scan_size and nav_shape")
self._nav_shape = tuple(scan_size)
if self._nav_shape is None and not path.lower().endswith(".hdr"):
if self._nav_shape is None and not self._path.lower().endswith(".hdr"):
raise ValueError(
"either nav_shape needs to be passed, or path needs to point to a .hdr file"
)
Expand Down
11 changes: 11 additions & 0 deletions tests/io/datasets/test_mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,14 @@ def test_bad_params(ds_params_tester, standard_bad_ds_params):
if 'nav_shape' not in params:
params['nav_shape'] = (1, 1)
ds_params_tester(*args, **params)


@needsdata
def test_read_scan_shape_header(lt_ctx):
out_dir = pathlib.Path(MIB_TESTDATA_PATH).parent / 'merlin_scan_header/'
hdr_path = (
out_dir / 't2_200kV_alpha3_28_20_px_5_4nm_300k_C2_30um_CL_10m_1ms_1L_with_flatfield.hdr'
)
ds = lt_ctx.load('mib', path=hdr_path)
assert ds.shape.nav.to_tuple() == (20, 28)
assert ds.shape.sig.to_tuple() == (514, 514)

0 comments on commit da491d5

Please sign in to comment.