Exemplo n.º 1
0
    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!")
Exemplo n.º 2
0
    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!")
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
 def from_dict(cls, d):
     """
     Returns a PourbaixEntry by reading in an Ion
     """
     entry_type = d["entry type"]
     if entry_type == "Ion":
         entry = IonEntry.from_dict(d["entry"])
     else:
         entry = PDEntry.from_dict(d["entry"])
     correction = d["correction"]
     entry_id = d["entry_id"]
     return PourbaixEntry(entry, correction, entry_id)