Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into release_v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaehne committed Apr 29, 2022
2 parents d895edd + ad23caf commit 70cda7c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
19 changes: 12 additions & 7 deletions lumispy/signals/luminescence_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

"""Signal class for Luminescence spectral data (1D).
"""
import warnings
import numpy as np
from inspect import getfullargspec
from warnings import warn
Expand Down Expand Up @@ -512,18 +511,24 @@ def remove_background_from_file(self, background=None, inplace=False, **kwargs):
-----
This function does not work with non-uniform axes.
"""
warnings.warn('The use of `remove_background_from_file` is deprecated and will be removed in LumiSpy 1.0. '
'Please use `remove_background_signal` from the Signal1D class.', DeprecationWarning, stacklevel=2)
warn(
"The use of `remove_background_from_file` is deprecated and will "
"be removed in LumiSpy 1.0. Please use `remove_background_signal` "
"from the Signal1D class.",
DeprecationWarning,
stacklevel=2,
)
if hasattr(self.metadata.Signal, "background_subtracted"):
if self.metadata.Signal.background_subtracted is True:
raise RecursionError(
"You have already removed background once. If you need to remove it again, "
"set the s.metadata.Signal.background_subtracted to False"
"You have already removed background once. If you need to "
"remove it again, set the "
"s.metadata.Signal.background_subtracted to False."
)
elif background is None:
warn(
"Using the Hyperspy specfic `remove_background` function. Use `s.remove_background()` "
"instead.",
"Using the Hyperspy specfic `remove_background` function. "
"Use `s.remove_background()` instead.",
category=SyntaxWarning,
)
self.remove_background(**kwargs)
Expand Down
4 changes: 1 addition & 3 deletions lumispy/tests/signals/test_common_luminescence.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,5 @@ def test_normalize(self):
assert s3a == s3
assert s4a == s4
assert s4.metadata.Signal.quantity == "Normalized intensity"
with pytest.warns(UserWarning) as warninfo:
with pytest.warns(UserWarning, match="Data was"):
s1.normalize(inplace=True)
assert len(warninfo) == 1
assert warninfo[0].message.args[0][:8] == "Data was"
6 changes: 3 additions & 3 deletions lumispy/tests/signals/test_luminescence_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
error_backgrounds = [
([np.linspace(0, 49, num=10, dtype="float64"), np.ones(50)], AttributeError),
([[1, 1], [1, 1], [1, 1]], AttributeError),
#([np.linspace(0, 48, num=10, dtype="float64"), np.ones(50)], AttributeError),
# ([np.linspace(0, 48, num=10, dtype="float64"), np.ones(50)], AttributeError),
]


Expand Down Expand Up @@ -68,10 +68,10 @@ def test_errors_raise(self):
def test_warnings(self):
pytest.importorskip("hyperspy_gui_ipywidgets")
s = LumiSpectrum(np.ones(50))
with pytest.warns(SyntaxWarning, match='Using the Hyperspy') as warninfo:
with pytest.warns(SyntaxWarning, match="Using the Hyperspy"):
s.remove_background_from_file(background=None, display=False)

def test_deprecation_warning(self):
s = LumiSpectrum(np.ones(50))
with pytest.warns(DeprecationWarning, match='deprecated') as warninfo:
with pytest.warns(DeprecationWarning, match="deprecated"):
s.remove_background_from_file(background=backgrounds[0][0])
4 changes: 1 addition & 3 deletions lumispy/tests/utils/test_joinspectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@

def test__n_air():
wl = arange(800) * 2 + 150
with warns(UserWarning) as warninfo:
with warns(UserWarning, match="The wavelength"):
n = _n_air(wl)
assert len(warninfo) == 1
assert warninfo[0].message.args[0][:14] == "The wavelength"
assert n[0] == _n_air(185)
assert n[-1] == _n_air(1700)
with warns(UserWarning):
Expand Down

0 comments on commit 70cda7c

Please sign in to comment.