def test_to_from_dict(self): d = self.mol.to_dict mol2 = IMolecule.from_dict(d) self.assertEqual(type(mol2), IMolecule) propertied_mol = Molecule( ["C", "H", "H", "H", "H"], self.coords, charge=1, site_properties={"magmom": [0.5, -0.5, 1, 2, 3]} ) d = propertied_mol.to_dict self.assertEqual(d["sites"][0]["properties"]["magmom"], 0.5) mol = Molecule.from_dict(d) self.assertEqual(propertied_mol, mol) self.assertEqual(mol[0].magmom, 0.5) self.assertEqual(mol.formula, "H4 C1") self.assertEqual(mol.charge, 1)
def test_to_from_dict(self): d = self.mol.to_dict mol2 = IMolecule.from_dict(d) self.assertEqual(type(mol2), IMolecule) propertied_mol = Molecule( ["C", "H", "H", "H", "H"], self.coords, charge=1, site_properties={'magmom': [0.5, -0.5, 1, 2, 3]}) d = propertied_mol.to_dict self.assertEqual(d['sites'][0]['properties']['magmom'], 0.5) mol = Molecule.from_dict(d) self.assertEqual(propertied_mol, mol) self.assertEqual(mol[0].magmom, 0.5) self.assertEqual(mol.formula, "H4 C1") self.assertEqual(mol.charge, 1)
def test_to_from_dict(self): d = self.mol.to_dict mol2 = IMolecule.from_dict(d) self.assertEqual(type(mol2), IMolecule)