示例#1
0
    def from_dict(cls, d):
        """
        Reconstitute a DefectPhaseDiagram object from a dict representation created using
        as_dict().

        Args:
            d (dict): dict representation of DefectPhaseDiagram.

        Returns:
            DefectPhaseDiagram object
        """
        entries = [
            DefectEntry.from_dict(entry_dict)
            for entry_dict in d.get("entries")
        ]
        vbm = d["vbm"]
        band_gap = d["band_gap"]
        filter_compatible = d.get("filter_compatible", True)
        metadata = d.get("metadata", {})
        if 'entry_id' in d.keys() and 'entry_id' not in metadata:
            metadata['entry_id'] = d['entry_id']

        return cls(entries,
                   vbm,
                   band_gap,
                   filter_compatible=filter_compatible,
                   metadata=metadata)
    def from_dict(cls, d):
        """
        Reconstitute a DefectPhaseDiagram object from a dict representation created using
        as_dict().

        Args:
            d (dict): dict representation of DefectPhaseDiagram.

        Returns:
            DefectPhaseDiagram object
        """
        entries = [DefectEntry.from_dict(entry_dict) for entry_dict in d.get("entries")]
        vbm = d["vbm"]
        band_gap = d["band_gap"]
        filter_compatible = d.get("filter_compatible", True)
        metadata = d.get("metadata", {})
        if 'entry_id' in d.keys() and 'entry_id' not in metadata:
            metadata['entry_id'] = d['entry_id']

        return cls(entries, vbm, band_gap, filter_compatible=filter_compatible,
                   metadata=metadata)
示例#3
0
 def test_init(self):
     entry = DefectEntry(self.substitution, 2.5)
     entry_doc = entry.as_dict()
     re_entry = DefectEntry.from_dict(entry_doc)
     self.assertNotEqual(re_entry, None)
示例#4
0
 def test_init(self):
     entry = DefectEntry(self.substitution, 2.5)
     entry_doc = entry.as_dict()
     re_entry = DefectEntry.from_dict(entry_doc)
     self.assertNotEqual(re_entry, None)