Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaehne committed Jan 6, 2025
1 parent f432a70 commit 098b669
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
Expand Down
2 changes: 1 addition & 1 deletion doc/user_guide/streak_images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 5 additions & 10 deletions lumispy/signals/luminescence_transientspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)**"""
Expand Down
24 changes: 24 additions & 0 deletions lumispy/tests/signals/test_luminescence_transient_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

0 comments on commit 098b669

Please sign in to comment.