def test_export_load(): L = LorentzianLine( name="Lorentzian", domain=(-5.0, 5.0), x0=-0.5, width=0.4, c=0.2 ) L.export_to_jsonfile(f"{testdir}/resources/test_export_load_file.json") L2 = LorentzianLine.load_from_jsonfile(f"{testdir}/resources/test_export_load_file.json") assert L.name == L2.name L3 = LorentzianLine.load_from_dict(**L2.export_to_dict())
def test_export_load(): L = LorentzianLine(name="Lorentzian", domain=(-5.0, 5.0), x0=-0.5, width=0.4, c=0.2) L.export_to_jsonfile(f"{testdir}/resources/test_export_load_file.json") L2 = LorentzianLine.load_from_jsonfile( f"{testdir}/resources/test_export_load_file.json") assert L.name == L2.name L3 = LorentzianLine.load_from_dict(**L2.export_to_dict()) F_c1 = LineFactory.create("f_c", name="FcLine1", domain=(-15, 15), x0=0.0, width=0.02, A=350.0, q=0.023, c=0.0, weight=1.0) F_c1.export_to_jsonfile( f"{testdir}/resources/test_export_load_F_c_file.json") F_c2 = F_cLine.load_from_jsonfile( f"{testdir}/resources/test_export_load_F_c_file.json") assert F_c1.line_params["width"] == F_c2.line_params["width"] F_c3 = F_cLine.load_from_dict(**F_c2.export_to_dict()) assert min(F_c3.domain) == min(F_c1.domain) F_I1 = LineFactory.create("f_I", name="FILine1", domain=(-15, 15), x0=0.0, width=0.02, A=350.0, q=0.023, c=0.0, weight=1.0, kappa=0.01) F_I1.export_to_jsonfile( f"{testdir}/resources/test_export_load_F_I_file.json") F_I2 = F_ILine.load_from_jsonfile( f"{testdir}/resources/test_export_load_F_I_file.json") assert F_I1.line_params["width"] == F_I2.line_params["width"] F_I3 = F_ILine.load_from_dict(**F_I2.export_to_dict()) assert min(F_I3.domain) == min(F_I1.domain)