Skip to content

Commit

Permalink
Merge pull request #49 from rsdefever/switch-to-numeric-key
Browse files Browse the repository at this point in the history
Switch JSON dict key to atomic number
  • Loading branch information
rsdefever authored Apr 1, 2021
2 parents c1472db + 3720e25 commit 1d568ba
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 119 deletions.
4 changes: 3 additions & 1 deletion ele/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ def infer_element_from_string(string):
elements = []
with open(JSON_PATH) as json_file:
elements_dict = json.load(json_file)
elements_dict = {int(key): value for key, value in elements_dict.items()}

for element_name, element_properties in elements_dict.items():
for atomic_number, element_properties in elements_dict.items():
assert atomic_number == element_properties["atomic number"]
elements.append(
Element(
atomic_number=element_properties["atomic number"],
Expand Down
Loading

0 comments on commit 1d568ba

Please sign in to comment.