Commit 335761a6 authored by payno's avatar payno
Browse files

[integrate ewoks] reworks test

parent a7549417
...@@ -115,14 +115,14 @@ class TestStreamSingleSpectrum(unittest.TestCase): ...@@ -115,14 +115,14 @@ class TestStreamSingleSpectrum(unittest.TestCase):
file_path=data_file, scheme="PyMca", data_path="Column 1" file_path=data_file, scheme="PyMca", data_path="Column 1"
), ),
) )
out = PyMca_normalization()(xas_obj=out) out = PyMca_normalization(inputs={"xas_obj": out})()
exafs_process = PyMca_exafs() exafs_process = PyMca_exafs(inputs={"xas_obj": out})
exafs_process.setConfiguration(configuration=self.exafs_configuration) exafs_process.setConfiguration(configuration=self.exafs_configuration)
out = exafs_process(xas_obj=out) out = exafs_process(xas_obj=out)
kweight_process = PyMca_k_weight() kweight_process = PyMca_k_weight(inputs={"xas_obj": out})
kweight_process.setConfiguration({"k_weight": 0}) kweight_process.setConfiguration({"k_weight": 0})
out = kweight_process(xas_obj=out) out = kweight_process()
out = PyMca_ft()(xas_obj=out) out = PyMca_ft(inputs={"xas_obj": out})()
assert isinstance(out, XASObject) assert isinstance(out, XASObject)
self.assertTrue(out.spectra.data.flat[0].ft is not None) self.assertTrue(out.spectra.data.flat[0].ft is not None)
self.assertTrue(len(out.spectra.data.flat[0].ft.intensity) > 0) self.assertTrue(len(out.spectra.data.flat[0].ft.intensity) > 0)
...@@ -175,8 +175,8 @@ class TestWorkflowAndH5LinkedFile(unittest.TestCase): ...@@ -175,8 +175,8 @@ class TestWorkflowAndH5LinkedFile(unittest.TestCase):
def test_h5_link_xas_object(self): def test_h5_link_xas_object(self):
"""Test that the processing can be stored continuously on a .h5 file""" """Test that the processing can be stored continuously on a .h5 file"""
self.assertTrue(self.xas_obj.linked_h5_file is not None) self.assertTrue(self.xas_obj.linked_h5_file is not None)
out = PyMca_normalization()(xas_obj=self.xas_obj) out = PyMca_normalization(inputs={"xas_obj": self.xas_obj})()
exafs_process = PyMca_exafs() exafs_process = PyMca_exafs(inputs={"xas_obj": out})
configuration = { configuration = {
"Knots": {"Values": (1, 2, 5), "Number": 3, "Orders": [3, 3, 3]}, "Knots": {"Values": (1, 2, 5), "Number": 3, "Orders": [3, 3, 3]},
"KMin": 0, "KMin": 0,
...@@ -184,11 +184,11 @@ class TestWorkflowAndH5LinkedFile(unittest.TestCase): ...@@ -184,11 +184,11 @@ class TestWorkflowAndH5LinkedFile(unittest.TestCase):
} }
exafs_process.setConfiguration(configuration=configuration) exafs_process.setConfiguration(configuration=configuration)
out = exafs_process(xas_obj=out) out = exafs_process(xas_obj=out)
k_weight_process = PyMca_k_weight() k_weight_process = PyMca_k_weight(inputs={"xas_obj": out})
k_weight_process.setConfiguration({"k_weight": 0}) k_weight_process.setConfiguration({"k_weight": 0})
out = k_weight_process(xas_obj=out) out = k_weight_process(xas_obj=out)
out = PyMca_ft()(xas_obj=out) out = PyMca_ft(inputs={"xas_obj": out})()
out = PyMca_normalization()(xas_obj=out) out = PyMca_normalization(inputs={"xas_obj": out})(xas_obj=out)
assert isinstance(out, XASObject) assert isinstance(out, XASObject)
assert out.linked_h5_file is self.h5_file assert out.linked_h5_file is self.h5_file
# then check all process are correctly registered with the valid id... # then check all process are correctly registered with the valid id...
...@@ -209,20 +209,20 @@ class TestWorkflowAndH5LinkedFile(unittest.TestCase): ...@@ -209,20 +209,20 @@ class TestWorkflowAndH5LinkedFile(unittest.TestCase):
"""Same test as test_h5_link_xas_object but with a dict pass between """Same test as test_h5_link_xas_object but with a dict pass between
processes""" processes"""
self.assertTrue(self.xas_obj.linked_h5_file is not None) self.assertTrue(self.xas_obj.linked_h5_file is not None)
out = PyMca_normalization()(xas_obj=self.xas_obj.to_dict()) out = PyMca_normalization(inputs={"xas_obj": self.xas_obj.to_dict()})()
exafs_process = PyMca_exafs() exafs_process = PyMca_exafs(inputs={"xas_obj": out})
configuration = { configuration = {
"Knots": {"Values": (1, 2, 5), "Number": 3, "Orders": [3, 3, 3]}, "Knots": {"Values": (1, 2, 5), "Number": 3, "Orders": [3, 3, 3]},
"KMin": 0, "KMin": 0,
"KMax": 2.3, "KMax": 2.3,
} }
exafs_process.setConfiguration(configuration=configuration) exafs_process.setConfiguration(configuration=configuration)
out = exafs_process(xas_obj=out.to_dict()) out = exafs_process()
k_weight_process = PyMca_k_weight() k_weight_process = PyMca_k_weight(inputs={"xas_obj": out})
k_weight_process.setConfiguration({"k_weight": 0}) k_weight_process.setConfiguration({"k_weight": 0})
out = k_weight_process(xas_obj=out.to_dict()) out = k_weight_process(xas_obj=out.to_dict())
out = PyMca_ft()(xas_obj=out.to_dict()) out = PyMca_ft(inputs={"xas_obj": out.to_dict()})()
out = PyMca_normalization()(xas_obj=out.to_dict()) out = PyMca_normalization(inputs={"xas_obj": out.to_dict()})()
assert isinstance(out, XASObject) assert isinstance(out, XASObject)
assert out.linked_h5_file assert out.linked_h5_file
assert out.linked_h5_file == self.h5_file assert out.linked_h5_file == self.h5_file
...@@ -261,20 +261,20 @@ class TestSaveFlowAuto(unittest.TestCase): ...@@ -261,20 +261,20 @@ class TestSaveFlowAuto(unittest.TestCase):
def test(self): def test(self):
self.assertTrue(self.xas_obj.linked_h5_file is not None) self.assertTrue(self.xas_obj.linked_h5_file is not None)
out = PyMca_normalization()(xas_obj=self.xas_obj) out = PyMca_normalization(inputs={"xas_obj": self.xas_obj})()
exafs = PyMca_exafs() exafs = PyMca_exafs(inputs={"xas_obj": out})
configuration = { configuration = {
"Knots": {"Values": (1, 2, 5), "Number": 3, "Orders": [3, 3, 3]}, "Knots": {"Values": (1, 2, 5), "Number": 3, "Orders": [3, 3, 3]},
"KMin": 0, "KMin": 0,
"KMax": 2.3, "KMax": 2.3,
} }
exafs.setConfiguration(configuration) exafs.setConfiguration(configuration)
out = exafs(xas_obj=out) out = exafs()
kweight_process = PyMca_k_weight() kweight_process = PyMca_k_weight(inputs={"xas_obj": out})
kweight_process.setConfiguration({"k_weight": 0}) kweight_process.setConfiguration({"k_weight": 0})
out = kweight_process(xas_obj=out) out = kweight_process()
out = PyMca_ft()(xas_obj=out) out = PyMca_ft(inputs={"xas_obj": out})()
out = PyMca_normalization()(xas_obj=out) out = PyMca_normalization(inputs={"xas_obj": out})()
writer = XASWriter() writer = XASWriter()
writer.output_file = self.h5_file writer.output_file = self.h5_file
......
...@@ -92,15 +92,15 @@ class TestMeldWorkflow(unittest.TestCase): ...@@ -92,15 +92,15 @@ class TestMeldWorkflow(unittest.TestCase):
""" """
self.xas_obj.configuration = {"EXAFS": self.configuration_exafs} self.xas_obj.configuration = {"EXAFS": self.configuration_exafs}
# pymca normalization # pymca normalization
out = PyMca_normalization()(xas_obj=self.xas_obj) out = PyMca_normalization(inputs={"xas_obj": self.xas_obj})()
# larch autobk # larch autobk
out = Larch_autobk()(xas_obj=out) out = Larch_autobk(inputs={"xas_obj": out}).run()
# k weight # k weight
kweight_process = PyMca_k_weight() kweight_process = PyMca_k_weight(inputs={"xas_obj": out})
kweight_process.setConfiguration({"k_weight": 0}) kweight_process.setConfiguration({"k_weight": 0})
out = kweight_process(xas_obj=out) out = kweight_process()
# pymca ft # pymca ft
out = PyMca_ft()(xas_obj=out) out = PyMca_ft(inputs={"xas_obj": out})()
self.assertTrue(out.spectra.data.flat[0].ft.intensity is not None) self.assertTrue(out.spectra.data.flat[0].ft.intensity is not None)
self.assertTrue(len(out.spectra.data.flat[0].ft.intensity) > 1) self.assertTrue(len(out.spectra.data.flat[0].ft.intensity) > 1)
...@@ -110,12 +110,12 @@ class TestMeldWorkflow(unittest.TestCase): ...@@ -110,12 +110,12 @@ class TestMeldWorkflow(unittest.TestCase):
larch pre_edge -> pymca exafs -> larch xftf larch pre_edge -> pymca exafs -> larch xftf
""" """
# larch pre edge # larch pre edge
out = Larch_pre_edge()(self.xas_obj) out = Larch_pre_edge(inputs={"xas_obj": self.xas_obj}).run()
# pymca exafs # pymca exafs
exafs = PyMca_exafs() exafs = PyMca_exafs(inputs={"xas_obj": out})
exafs.setConfiguration(self.configuration_exafs) exafs.setConfiguration(self.configuration_exafs)
out = exafs(xas_obj=out) out = exafs()
# for now we cannot link xftf because chi is not set by pymca exafs # for now we cannot link xftf because chi is not set by pymca exafs
spectrum_0 = out.spectra.data.flat[0] spectrum_0 = out.spectra.data.flat[0]
self.assertFalse(spectrum_0["EXAFSSignal"] is None) self.assertFalse(spectrum_0["EXAFSSignal"] is None)
...@@ -123,7 +123,7 @@ class TestMeldWorkflow(unittest.TestCase): ...@@ -123,7 +123,7 @@ class TestMeldWorkflow(unittest.TestCase):
self.assertFalse(spectrum_0.chi is None) self.assertFalse(spectrum_0.chi is None)
self.assertFalse(spectrum_0.k is None) self.assertFalse(spectrum_0.k is None)
# larch xftf # larch xftf
out = Larch_xftf()(xas_obj=out) out = Larch_xftf(inputs={"xas_obj": out})()
writer = XASWriter() writer = XASWriter()
writer.output_file = self.h5_file writer.output_file = self.h5_file
......
...@@ -74,8 +74,8 @@ class TestWriteProcess(unittest.TestCase): ...@@ -74,8 +74,8 @@ class TestWriteProcess(unittest.TestCase):
def testProcess(self): def testProcess(self):
self.assertTrue(self.spectrum.pre_edge is None) self.assertTrue(self.spectrum.pre_edge is None)
self.assertTrue(self.spectrum.e0 is None) self.assertTrue(self.spectrum.e0 is None)
process = Larch_pre_edge() process = Larch_pre_edge(inputs={"xas_obj": self.xas_obj})
process.process(self.xas_obj) process.run()
self.assertTrue(self.spectrum.pre_edge is not None) self.assertTrue(self.spectrum.pre_edge is not None)
self.assertTrue(self.spectrum.e0 is not None) self.assertTrue(self.spectrum.e0 is not None)
# check process # check process
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment