From 098b669df66448493e53e86c97ca1172fcbbfc98 Mon Sep 17 00:00:00 2001 From: jlaehne Date: Fri, 3 Jan 2025 12:17:00 +0100 Subject: [PATCH] add tests --- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 +- doc/conf.py | 1 + doc/user_guide/streak_images.rst | 2 +- lumispy/signals/luminescence_transientspec.py | 15 ++++-------- .../test_luminescence_transient_spectrum.py | 24 +++++++++++++++++++ 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a97dc037..5b4ea4f4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,4 +57,4 @@ jobs: uses: actions/checkout@v4 - name: Create Release if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'lumispy' }} - uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 + uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4aeef1dbb..a40d822f9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -65,4 +65,4 @@ jobs: - name: Upload coverage to Codecov if: ${{ always() }} && ${{ matrix.PYTEST_ARGS_COVERAGE }} - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 diff --git a/doc/conf.py b/doc/conf.py index 82157471a..3424dde96 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -48,6 +48,7 @@ intersphinx_disabled_domains = ["std"] linkcheck_ignore = [ + "https://doi.org/10.1063/5.0080486", # 403 Client Error: Forbidden for url "https://doi.org/10.1021/jz401508t", # 403 Client Error: Forbidden for url "https://github.com/LumiSpy/lumispy/security/code-scanning", # 404 Client Error: Not Found for url (even though page exists) ] diff --git a/doc/user_guide/streak_images.rst b/doc/user_guide/streak_images.rst index 8fada0360..2d1efe037 100644 --- a/doc/user_guide/streak_images.rst +++ b/doc/user_guide/streak_images.rst @@ -78,7 +78,7 @@ class provides the functions :meth:`~.signals.luminescence_transientspec.LumiTra and :meth:`~.signals.luminescence_transientspec.LumiTransientSpectrum.time2nav` to convert streak images to the :class:`~.signals.luminescence_transient.LumiTransient` and :class:`~.signals.luminescence_spectrum.LumiSpectrum` classes, respectively. -Both functions return a new signal. By default, the methods ensure that the data +Both functions return a new signal. By default (``optimize=True``), the methods ensure that the data is stored optimally, hence often making a copy of the data. .. code-block:: python diff --git a/lumispy/signals/luminescence_transientspec.py b/lumispy/signals/luminescence_transientspec.py index 632c62a04..85960d8b7 100644 --- a/lumispy/signals/luminescence_transientspec.py +++ b/lumispy/signals/luminescence_transientspec.py @@ -91,12 +91,10 @@ def spec2nav(self, optimize=True): lumispy.signals.LumiTransientSpectrum.time2nav hyperspy.api.signals.BaseSignal.transpose """ - s = self.transpose(signal_axes=[-1],optimize=optimize) + s = self.transpose(signal_axes=[-1], optimize=optimize) return s - spec2nav.__doc__ %= ( - OPTIMIZE_ARG.replace("False", "True"), - ) + spec2nav.__doc__ %= (OPTIMIZE_ARG,) def time2nav(self, optimize=True): """Return the streak image as signal with the time axis as navigation @@ -119,14 +117,11 @@ def time2nav(self, optimize=True): lumispy.signals.LumiTransientSpectrum.time2nav hyperspy.api.signals.BaseSignal.transpose """ - s = self.transpose(signal_axes=[-2],optimize=optimize) + s = self.transpose(signal_axes=[-2], optimize=optimize) return s - #self.axes_manager.signal_axes[-1].navigate = True - #self.set_signal_type("LumiSpectrum") - time2nav.__doc__ %= ( - OPTIMIZE_ARG.replace("False", "True"), - ) + time2nav.__doc__ %= (OPTIMIZE_ARG,) + class LazyLumiTransientSpectrum(LazySignal, LumiTransientSpectrum): """**Lazy 2D luminescence signal class (spectral+transient/time resolved dimensions)**""" diff --git a/lumispy/tests/signals/test_luminescence_transient_spectrum.py b/lumispy/tests/signals/test_luminescence_transient_spectrum.py index 30e6b7de8..23aa2665d 100644 --- a/lumispy/tests/signals/test_luminescence_transient_spectrum.py +++ b/lumispy/tests/signals/test_luminescence_transient_spectrum.py @@ -69,6 +69,18 @@ def test_max_t(self): assert s2.axes_manager[-1].units == "nm" assert type(s2) == LumiSpectrum + def test_spec2nav(self): + s2 = self.s.spec2nav() + assert s2.axes_manager[0].units == "nm" + assert s2.axes_manager[-1].units == "ps" + assert type(s2) == LumiTransient + + def test_time2nav(self): + s2 = self.s.time2nav() + assert s2.axes_manager[0].units == "ps" + assert s2.axes_manager[-1].units == "nm" + assert type(s2) == LumiSpectrum + class TestLumiTransientSpectrum2D: def setup_method(self, method): @@ -120,3 +132,15 @@ def test_max_t(self): s2 = self.s.max(axis="Time") assert s2.axes_manager[-1].units == "nm" assert type(s2) == LumiSpectrum + + def test_spec2nav(self): + s2 = self.s.spec2nav() + assert s2.axes_manager[0].units == "nm" + assert s2.axes_manager[-1].units == "ps" + assert type(s2) == LumiTransient + + def test_time2nav(self): + s2 = self.s.time2nav() + assert s2.axes_manager[0].units == "ps" + assert s2.axes_manager[-1].units == "nm" + assert type(s2) == LumiSpectrum