Skip to content

Commit

Permalink
Merge pull request #292 from TheoChem-VU/291-add-dummy-atom-data-to-t…
Browse files Browse the repository at this point in the history
…cutilitydataatoms

Added dummy atom data to `tcutility.data.atoms`
  • Loading branch information
SiebeLeDe authored Aug 18, 2024
2 parents fe378b2 + f37315c commit 5989c93
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/tcutility/data/_atom_data_info/color.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0, 128, 0, 128
1, 255, 255, 255
2, 217, 255, 255
3, 204, 128, 255
Expand Down
1 change: 1 addition & 0 deletions src/tcutility/data/_atom_data_info/name.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0, dummy
1, hydrogen
2, helium
3, lithium
Expand Down
1 change: 1 addition & 0 deletions src/tcutility/data/_atom_data_info/radius.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0, 0.15
1, 0.31
2, 0.28
3, 1.28
Expand Down
1 change: 1 addition & 0 deletions src/tcutility/data/_atom_data_info/symbol.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0, Xx
1, H
2, He
3, Li
Expand Down
10 changes: 5 additions & 5 deletions src/tcutility/data/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def parse_element(val):
# if it is not an int it should be a string
if val.lower() in _element_order:
# first try to get it in the element name list
return _element_order.index(val.lower()) + 1
return _element_order.index(val.lower())
if val in _symbol_order:
# alternatively try to get it in the symbol list
return _symbol_order.index(val) + 1
return _symbol_order.index(val)
raise KeyError(f'Element "{val}" not parsable.')


Expand Down Expand Up @@ -81,13 +81,13 @@ def atom_number(element):

def symbol(element):
num = parse_element(element)
return _symbol_order[num - 1]
return _symbol_order[num]


def element(element):
num = parse_element(element)
return _element_order[num - 1]
return _element_order[num]


if __name__ == "__main__":
print(symbol(2))
print(symbol(0))

0 comments on commit 5989c93

Please sign in to comment.