Skip to content

Commit

Permalink
Use filename in test metadata that should work on all platforms
Browse files Browse the repository at this point in the history
Signed-off-by: Håkon Wiik Ånes <[email protected]>
  • Loading branch information
hakonanes committed Sep 30, 2024
1 parent b32b657 commit 06a1352
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,9 @@ def emsoft_ebsd_file(emsoft_ebsd_path) -> Generator[Path, None, None]:

@pytest.fixture
def emsoft_ebsd_master_pattern_metadata() -> Generator[dict, None, None]:
fname = "master_patterns.h5"
yield {
"General": {
"original_filename": "master_patterns.h5",
"title": "master_patterns",
},
"General": {"original_filename": fname, "title": fname.split(".")[0]},
"Signal": {"signal_type": "EBSDMasterPattern"},
}

Expand Down
9 changes: 6 additions & 3 deletions src/kikuchipy/io/plugins/_emsoft_master_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import abc
import os
from pathlib import Path
from typing import List, Optional, Tuple

import dask.array as da
Expand Down Expand Up @@ -74,8 +75,10 @@ def read(self, **kwargs) -> List[dict]:
signal_dict_list
Data, axes, metadata and original metadata.
"""
fpath = Path(self.filename)

mode = kwargs.pop("mode", "r")
f = File(self.filename, mode=mode, **kwargs)
f = File(fpath, mode=mode, **kwargs)

_check_file_format(f, self.diffraction_type)

Expand All @@ -91,8 +94,8 @@ def read(self, **kwargs) -> List[dict]:
md = {
"Signal": {"signal_type": signal_type, "record_by": "image"},
"General": {
"title": f.filename.split("/")[-1].split(".")[0],
"original_filename": f.filename.split("/")[-1],
"title": fpath.stem,
"original_filename": fpath.name,
},
}
nml_params = _hdf5group2dict(f["NMLparameters"], recursive=True)
Expand Down

0 comments on commit 06a1352

Please sign in to comment.