From 9d1d920f50b950ee500a953e639f3369ba5bc30b Mon Sep 17 00:00:00 2001 From: hrocho Date: Mon, 22 Jan 2018 00:37:22 +0100 Subject: [PATCH] python module --- catima.pyx | 16 ++++++++++++++++ tests/test.py | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/catima.pyx b/catima.pyx index 5cc9812..17de386 100644 --- a/catima.pyx +++ b/catima.pyx @@ -310,6 +310,22 @@ cdef class Config: return self.cbase.dedx_straggling else: self.cbase.dedx_straggling = val + def set(self,other): + if("z_effective" in other): + self.cbase.z_effective = other["z_effective"] + if("dedx" in other): + self.cbase.dedx = other["dedx"] + if("dedx_straggling" in other): + self.cbase.dedx_straggling = other["dedx_straggling"] + + def get(self): + res = {} + res["z_effective"] = self.cbase.z_effective + res["dedx"] = self.cbase.dedx + res["dedx_straggling"] = self.cbase.dedx_straggling + res["skip"] = self.cbase.skip + return res + def print_info(self): print("z_effective = %s"%z_eff_type(self.cbase.z_effective)) print("dedx_straggling = %s"%omega_type(self.cbase.dedx_straggling)) diff --git a/tests/test.py b/tests/test.py index 0ff7bcf..c96ac69 100644 --- a/tests/test.py +++ b/tests/test.py @@ -75,7 +75,7 @@ class TestStructures(unittest.TestCase): self.assertAlmostEqual(m2.molar_mass(),18,1) self.assertAlmostEqual(m2.density(),1.0,1) - m3 = catima.get_material(301) + m3 = catima.get_material(3001) self.assertEqual(m3.ncomponents(),0) self.assertAlmostEqual(m3.molar_mass(),0,1) self.assertAlmostEqual(m3.density(),0.0,1) @@ -254,5 +254,15 @@ class TestStructures(unittest.TestCase): #self.assertAlmostEqual(catima.da2de(p,water,et[100]),data[2][100],6) #self.assertAlmostEqual(catima.da2de(p,water,et[400]),data[2][400],6) + def test_config(self): + c1 = catima.Config() + self.assertEqual(c1.z_effective(),catima.z_eff_type.pierce_blann); + + d = {} + d["z_effective"] = catima.z_eff_type.atima14; + c1.set(d); + self.assertEqual(c1.z_effective(),catima.z_eff_type.atima14); + + if __name__ == "__main__": unittest.main()