def test_to_from_dict(self): d = self.entry.as_dict() gpd = self.gpentry.as_dict() entry = PDEntry.from_dict(d) self.assertEqual(entry.name, 'LiFeO2', "Wrong name!") self.assertEqual(entry.energy_per_atom, 53.0 / 4) gpentry = GrandPotPDEntry.from_dict(gpd) self.assertEqual(gpentry.name, 'LiFeO2', "Wrong name!") self.assertEqual(gpentry.energy_per_atom, 50.0 / 2)
def test_to_from_dict(self): d = self.entry.as_dict() gpd = self.gpentry.as_dict() entry = PDEntry.from_dict(d) self.assertEqual(entry.name, 'LiFeO2', "Wrong name!") self.assertEqual(entry.energy_per_atom, 53.0 / 4) gpentry = GrandPotPDEntry.from_dict(gpd) self.assertEqual(gpentry.name, 'LiFeO2', "Wrong name!") self.assertEqual(gpentry.energy_per_atom, 50.0 / 2)
def test_to_from_dict(self): d = self.entry.as_dict() gpd = self.gpentry.as_dict() entry = PDEntry.from_dict(d) self.assertEqual(entry.name, 'LiFeO2', "Wrong name!") self.assertEqual(entry.energy_per_atom, 53.0 / 4) gpentry = GrandPotPDEntry.from_dict(gpd) self.assertEqual(gpentry.name, 'LiFeO2', "Wrong name!") self.assertEqual(gpentry.energy_per_atom, 50.0 / 2) d_anon = d.copy() del d_anon['name'] try: entry = PDEntry.from_dict(d_anon) except KeyError: self.fail("Should not need to supply name!")
def test_to_from_dict(self): d = self.entry.as_dict() gpd = self.gpentry.as_dict() entry = PDEntry.from_dict(d) self.assertEqual(entry.name, "LiFeO2", "Wrong name!") self.assertEqual(entry.energy_per_atom, 53.0 / 4) gpentry = GrandPotPDEntry.from_dict(gpd) self.assertEqual(gpentry.name, "LiFeO2", "Wrong name!") self.assertEqual(gpentry.energy_per_atom, 50.0 / 2) d_anon = d.copy() del d_anon["name"] try: entry = PDEntry.from_dict(d_anon) except KeyError: self.fail("Should not need to supply name!")