Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from materialsproject/reconcile
Reconcile changes on updates branch
- Loading branch information
Showing
13 changed files
with
293 additions
and
126 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
emmet-builders/emmet/builders/materials/oxidation_states.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Dict, List, Optional | ||
|
||
from maggma.builders.map_builder import MapBuilder | ||
from maggma.core import Store | ||
from pymatgen.core import Structure | ||
|
||
from pymatgen.core import __version__ as pymatgen_version | ||
|
||
|
||
from emmet.core.oxidation_states import OxidationStateDoc | ||
|
||
|
||
class OxidationStatesBuilder(MapBuilder): | ||
def __init__( | ||
self, | ||
materials: Store, | ||
oxidation_states: Store, | ||
**kwargs, | ||
): | ||
""" | ||
Creates Oxidation State documents from materials | ||
Args: | ||
materials: Store of materials docs | ||
oxidation_states: Store to update with oxidation state document | ||
query : query on materials to limit search | ||
""" | ||
self.materials = materials | ||
self.oxidation_states = oxidation_states | ||
self.kwargs = kwargs | ||
|
||
# Enforce that we key on material_id | ||
self.materials.key = "material_id" | ||
self.oxidation_states.key = "material_id" | ||
super().__init__( | ||
source=materials, | ||
target=oxidation_states, | ||
projection=["structure"], | ||
**kwargs, | ||
) | ||
|
||
def unary_function(self, item): | ||
structure = Structure.from_dict(item["structure"]) | ||
oxi_doc = OxidationStateDoc.from_structure(structure) | ||
doc = oxi_doc.dict() | ||
|
||
doc.update( | ||
{ | ||
"pymatgen_version": pymatgen_version, | ||
"successful": True, | ||
} | ||
) | ||
|
||
return doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.