diff --git a/news/in-1-2-dependencies.rst b/news/in-1-2-dependencies.rst new file mode 100644 index 0000000..92d8c14 --- /dev/null +++ b/news/in-1-2-dependencies.rst @@ -0,0 +1,23 @@ +**Added:** + +* ``h5py``, ``hdf5plugin`` and ``matplotlib`` as dependencies. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/requirements/conda.txt b/requirements/conda.txt index 24ce15a..430509b 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -1 +1,4 @@ numpy +h5py +hdf5plugin +matplotlib-base diff --git a/requirements/pip.txt b/requirements/pip.txt index 24ce15a..5e52139 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -1 +1,4 @@ numpy +h5py +hdf5plugin +matplotlib diff --git a/src/diffpy/diffchooser/reader.py b/src/diffpy/diffchooser/reader.py new file mode 100644 index 0000000..eb085c5 --- /dev/null +++ b/src/diffpy/diffchooser/reader.py @@ -0,0 +1,8 @@ +"""Read EIGER2 NXmx runs. + +Importing hdf5plugin registers the filters that h5py needs to read +bslz4-compressed frames. +""" + +import h5py # noqa: F401 +import hdf5plugin # noqa: F401 diff --git a/tests/test_reader.py b/tests/test_reader.py new file mode 100644 index 0000000..e7947bc --- /dev/null +++ b/tests/test_reader.py @@ -0,0 +1,19 @@ +"""Unit tests for reader.py.""" + +import h5py +import hdf5plugin +import numpy as np + +from diffpy.diffchooser import reader # noqa + + +def test_read_bslz4_frame(tmp_path): + expected = np.arange(64, dtype=np.uint32).reshape(8, 8) + path = tmp_path / "frame.h5" + with h5py.File(path, "w") as f: + f.create_dataset( + "data", data=expected, **hdf5plugin.Bitshuffle(cname="lz4") + ) + with h5py.File(path, "r") as f: + actual = f["data"][()] + np.testing.assert_array_equal(actual, expected)