Skip to content

Commit

Permalink
Some tweaks to the testing. Make SLS SXTM files open read only
Browse files Browse the repository at this point in the history
  • Loading branch information
gb119 committed Dec 8, 2023
1 parent eee60d9 commit 6ad0502
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ clean:
- find -name '__pycache__' -exec rm -rf {} \;

test:
pytest -n `python -c 'import os;print(min(8,os.cpu_count()))'`
pytest -n `python -c 'import os;print(min(12,os.cpu_count()))'`

test-single:
pytest --pdb
Expand Down
5 changes: 4 additions & 1 deletion Stoner/HDF5.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def get_hdf_loader(f, default_loader=lambda *args, **kargs: None):


class HDFFileManager:

"""Context manager for HDF5 files."""

def __init__(self, filename, mode="r"):
"""Initialise context handler.
Expand Down Expand Up @@ -601,7 +604,7 @@ def _load(self, filename, *args, **kargs):
self.filename = filename
if isinstance(filename, path_types): # We got a string, so we'll treat it like a file...
try:
f = h5py.File(filename, "r+")
f = h5py.File(filename, "r")
except IOError as err:
raise StonerLoadError(f"Failed to open {filename} as a n hdf5 file") from err
elif isinstance(filename, h5py.File) or isinstance(filename, h5py.Group):
Expand Down
2 changes: 1 addition & 1 deletion tests/Stoner/Image/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _expected():
8: {6: 1056, 7: 1058, 8: 1062, 9: 1087, 10: 1089, 11: 1089},
9: {6: 1056, 7: 1058, 8: 1062, 9: 1087, 10: 1089, 11: 1089},
10: {6: 1056, 7: 1062, 8: 1062, 9: 1062, 10: 1089, 11: 1090},
11: {6: 1056, 7: 1062, 8: 1062, 9: 1062, 10: 1089, 11: 1097},
11: {6: 1056, 7: 1062, 8: 1062, 9: 1062, 10: 1089, 11: 1097 },
}
return data[py][scipy]

Expand Down
1 change: 1 addition & 0 deletions tests/Stoner/analysis/test_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
def setup_function(function):
global testd
x = np.linspace(0, 2 * np.pi, 721)
np.random.seed(87654321)
y = np.sin(2 * x) + np.random.normal(scale=0.02, size=x.size)
testd = Data(x, y, column_headers=["Time", "Ramp", "sine"])

Expand Down

0 comments on commit 6ad0502

Please sign in to comment.