def test_stitch_l23(self): self.l2_xanes.y[0] = 0.1 with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") XAS.stitch(self.l2_xanes, self.l3_xanes, 100, mode="L23") self.assertEqual(len(w), 1) self.assertIs(w[-1].category, UserWarning) self.assertIn("jump", str(w[-1].message)) self.l2_xanes = XAS.from_dict(l2_xanes_dict) l23 = XAS.stitch(self.l2_xanes, self.l3_xanes, 100, mode="L23") self.assertIsInstance(l23, XAS) self.assertEqual("L23", l23.edge) self.assertAlmostEqual(min(l23.x), min(self.l3_xanes.x), 3) self.assertAlmostEqual(max(l23.x), max(self.l3_xanes.x), 3) self.assertTrue(np.greater_equal(l23.y, self.l2_xanes.y).all()) self.assertEqual(len(l23.x), 100) self.l2_xanes.spectrum_type = "EXAFS" self.assertRaises(ValueError, XAS.stitch, self.l2_xanes, self.l3_xanes, mode="L23") self.l2_xanes.absorbing_element = Element("Pt") self.assertRaises(ValueError, XAS.stitch, self.l2_xanes, self.l3_xanes, mode="L23") self.assertRaises(ValueError, XAS.stitch, self.k_xanes, self.l3_xanes, mode="L23")
def setUp(self): self.k_xanes = XAS.from_dict(k_xanes_dict) self.k_exafs = XAS.from_dict(k_exafs_dict) self.l2_xanes = XAS.from_dict(l2_xanes_dict) self.l3_xanes = XAS.from_dict(l3_xanes_dict) self.site1_xanes = XAS.from_dict(site1_xanes_dict) self.site2_xanes = XAS.from_dict(site2_xanes_dict)
def setUp(self): self.xanes = XAS.from_dict(spect_data_dict)
def test_to_from_dict(self): s = XAS.from_dict(self.k_xanes.as_dict()) self.assertArrayAlmostEqual(s.y, self.k_xanes.y)