Skip to content

Commit

Permalink
jsantize
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmshn committed Feb 4, 2021
1 parent 2012d20 commit 93be748
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
15 changes: 2 additions & 13 deletions emmet-builders/emmet/builders/materials/electrodes.py
Expand Up @@ -11,6 +11,7 @@
from emmet.core.structure_group import StructureGroupDoc
from maggma.builders import Builder, MapBuilder
from maggma.stores import MongoStore
from monty.json import MontyEncoder
from numpy import unique
from pymatgen import Composition
from pymatgen.analysis.structure_matcher import StructureMatcher, ElementComparator
Expand Down Expand Up @@ -402,17 +403,5 @@ def unary_function(self, item):
)
if ie is None:
return {"failed_reason": "unable to create InsertionElectrode document"}

return ie.dict()
# failed = False
# try:
# ie = InsertionElectrode.from_entries(entries, working_ion_entry)
# except Exception:
# failed = True
#
# if failed or ie.num_steps < 1:
# res = {"task_id": item["task_id"], "has_step": False}
# else:
# res = {"task_id": item["task_id"], "has_step": True}
# res.update(ie.get_summary_dict())
# res["InsertionElectrode"] = ie.as_dict()
# return res
4 changes: 4 additions & 0 deletions emmet-core/emmet/core/electrode.py
Expand Up @@ -9,6 +9,7 @@
from pymatgen.core.periodic_table import Element
from pymatgen.entries.computed_entries import ComputedEntry

from emmet.core.utils import jsanitize
from emmet.stubs import Composition, Structure


Expand Down Expand Up @@ -57,6 +58,9 @@ def from_sub_electrode(cls, sub_electrode: AbstractElectrode, **kwargs):
"""
return cls(**sub_electrode.get_summary_dict(), **kwargs)

def dict(self, *args, **kwargs):
return jsanitize(super().dict(*args, **kwargs))


class InsertionVoltagePairDoc(VoltagePairDoc):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/emmet-core/test_electrodes.py
Expand Up @@ -73,6 +73,7 @@ def test_InsertionDocs(insertion_elec):
for sub_elec in elec.get_sub_electrodes(adjacent_only=True):
vp = InsertionVoltagePairDoc.from_sub_electrode(sub_electrode=sub_elec)
assert vp.average_voltage == sub_elec.get_average_voltage()
assert type(ie.dict()["host_structure"]) == dict


def test_ConversionDocs_from_entries(conversion_elec):
Expand Down

0 comments on commit 93be748

Please sign in to comment.