hyperspy / rosettasciio

Python library for reading and writing scientific data format
https://hyperspy.org/rosettasciio
GNU General Public License v3.0
47 stars 28 forks source link

Fix test failure in empad test when pyxem >=0.19 is installed #282

Closed ericpre closed 2 months ago

ericpre commented 3 months ago

From https://github.com/hyperspy/hyperspy-extensions-list/actions/runs/9629835432/job/26559728297:

=================================== FAILURES ===================================
____________________________ test_read_stack[False] ____________________________
[gw1] linux -- Python 3.11.9 /home/runner/miniconda3/envs/test/bin/python

lazy = False

    @pytest.mark.parametrize("lazy", (False, True))
    def test_read_stack(lazy):
        # xml file version 0.51 211118
        s = hs.load(DATA_DIR / "stack_images.xml", lazy=lazy, reader="EMPAD")
        assert s.data.dtype == "float32"
        ref_data = np.arange(166400).reshape((10, 130, 128))[..., :128, :]
        np.testing.assert_allclose(s.data, ref_data.astype("float32"))
        signal_axes = s.axes_manager.signal_axes
        assert signal_axes[0].name == "width"
        assert signal_axes[1].name == "height"
        for axis in signal_axes:
>           assert axis.units == t.Undefined
E           AssertionError: assert 'px' == <undefined>
E            +  where 'px' = <width axis, size: 128>.units
E            +  and   <undefined> = t.Undefined

../../../miniconda3/envs/test/lib/python3.11/site-packages/rsciio/tests/test_empad.py:69: AssertionError
----------------------------- Captured stdout call -----------------------------
WARNING | RosettaSciIO | The scale of the signal axes cannot be read. (rsciio.empad._api:170)
------------------------------ Captured log call -------------------------------
WARNING  rsciio.empad._api:_api.py:170 The scale of the signal axes cannot be read.
____________________________ test_read_stack[True] _____________________________
[gw1] linux -- Python 3.11.9 /home/runner/miniconda3/envs/test/bin/python

lazy = True

    @pytest.mark.parametrize("lazy", (False, True))
    def test_read_stack(lazy):
        # xml file version 0.51 211118
        s = hs.load(DATA_DIR / "stack_images.xml", lazy=lazy, reader="EMPAD")
        assert s.data.dtype == "float32"
        ref_data = np.arange(166400).reshape((10, 130, 128))[..., :128, :]
        np.testing.assert_allclose(s.data, ref_data.astype("float32"))
        signal_axes = s.axes_manager.signal_axes
        assert signal_axes[0].name == "width"
        assert signal_axes[1].name == "height"
        for axis in signal_axes:
>           assert axis.units == t.Undefined
E           AssertionError: assert 'px' == <undefined>
E            +  where 'px' = <width axis, size: 128>.units
E            +  and   <undefined> = t.Undefined

../../../miniconda3/envs/test/lib/python3.11/site-packages/rsciio/tests/test_empad.py:69: AssertionError
----------------------------- Captured stdout call -----------------------------
WARNING | RosettaSciIO | The scale of the signal axes cannot be read. (rsciio.empad._api:170)
------------------------------ Captured log call -------------------------------
WARNING  rsciio.empad._api:_api.py:170 The scale of the signal axes cannot be read.
=============================== warnings summary ===============================

Progress of the PR

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.33%. Comparing base (fd8e2f5) to head (f8187be). Report is 3 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #282 +/- ## ======================================= Coverage 86.33% 86.33% ======================================= Files 83 83 Lines 10672 10672 Branches 2331 2331 ======================================= Hits 9214 9214 Misses 939 939 Partials 519 519 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.