def test_phase2dict(self, phase_list): phase_dict = phase2dict(phase_list[0]) this_dict = {"hello": "there"} this_dict = phase2dict(phase_list[0], dictionary=this_dict) this_dict.pop("hello") assert_dictionaries_are_equal(phase_dict, this_dict)
def test_crystalmap2dict(self, temp_file_path, crystal_map_input): cm = CrystalMap(**crystal_map_input) cm_dict = crystalmap2dict(cm) this_dict = {"hello": "there"} cm_dict2 = crystalmap2dict(cm, dictionary=this_dict) cm_dict2.pop("hello") assert_dictionaries_are_equal(cm_dict, cm_dict2) assert np.allclose(cm_dict["data"]["x"], crystal_map_input["x"]) assert cm_dict["header"]["z_step"] == cm.dz
def test_structure2dict(self, phase_list): structure = phase_list[0].structure structure_dict = structure2dict(structure) this_dict = {"hello": "there"} this_dict = structure2dict(structure, this_dict) this_dict.pop("hello") lattice1 = structure_dict["lattice"] lattice2 = this_dict["lattice"] assert np.allclose(lattice1["abcABG"], lattice2["abcABG"]) assert np.allclose(lattice1["baserot"], lattice2["baserot"]) assert_dictionaries_are_equal(structure_dict["atoms"], this_dict["atoms"])
def test_dict2crystalmap(self, crystal_map): cm2 = dict2crystalmap(crystalmap2dict(crystal_map)) assert_dictionaries_are_equal(crystal_map.__dict__, cm2.__dict__)
def test_file_reader(self, crystal_map, temp_file_path): save(filename=temp_file_path, object2write=crystal_map) cm2 = load(filename=temp_file_path) assert_dictionaries_are_equal(crystal_map.__dict__, cm2.__dict__)