Пример #1
0
 def test_remove_background_from_file(self):
     for bkg, output in backgrounds:
         s = LumiSpectrum(np.ones(50))
         s2 = s.remove_background_from_file(bkg, inplace=False)
         s.remove_background_from_file(bkg, inplace=True)
         assert np.allclose(s.data, output)
         assert np.allclose(s2.data, output)
         assert s.metadata.Signal.background_subtracted is True
         assert hasattr(s.metadata.Signal, "background")
 def test_errors_raise(self):
     s = LumiSpectrum(np.ones(50))
     for bkg, error in error_backgrounds:
         self.assertRaises(error, s.remove_background_from_file, bkg)
     # Test that a GUI is opened if s.remove_background_from_file is passed without a background
     # s.remove_background_from_file()
     # Test double background removal
     s.remove_background_from_file(backgrounds[0][0], inplace=True)
     self.assertRaises(RecursionError, s.remove_background_from_file,
                       backgrounds[0][0])
Пример #3
0
 def test_warnings(self):
     pytest.importorskip("hyperspy_gui_ipywidgets")
     s = LumiSpectrum(np.ones(50))
     with pytest.warns(SyntaxWarning) as warninfo:
         s.remove_background_from_file(background=None, display=False)
     assert warninfo[0].message.args[0][:18] == "Using the Hyperspy"