Skip to content

Commit

Permalink
add radical smiles support
Browse files Browse the repository at this point in the history
  • Loading branch information
corinwagen committed Mar 27, 2024
1 parent 702b737 commit e1968b5
Show file tree
Hide file tree
Showing 23 changed files with 2,059 additions and 907 deletions.
18 changes: 11 additions & 7 deletions cctk/array.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import copy


class OneIndexedArray(np.ndarray):
"""
Wrapper for ``np.ndarray`` that's indexed from one, not zero, to store atomic numbers and geometries.
Expand Down Expand Up @@ -28,7 +29,7 @@ def __getitem__(self, index):
return super().__getitem__(new_index)
elif isinstance(index, int):
if index > 0:
return super().__getitem__(index-1)
return super().__getitem__(index - 1)
elif index == 0:
raise IndexError("this is a 1-indexed array: no element 0!")
elif index < 0:
Expand All @@ -37,7 +38,7 @@ def __getitem__(self, index):
if index[0] is None:
return super().__getitem__((index[0], index[1]))
elif index[0] > 0:
return super().__getitem__((index[0]-1, index[1]))
return super().__getitem__((index[0] - 1, index[1]))
elif index[0] == 0:
raise IndexError("this is a 1-indexed array: no element 0!")
elif index[0] < 0:
Expand Down Expand Up @@ -76,11 +77,13 @@ def __setitem__(self, index, value):
if isinstance(index, int):
if index > 0:
if self.ndim == 1:
super().__setitem__(index-1, value)
super().__setitem__(index - 1, value)
elif self.ndim == 2:
super().__setitem__(index, value)
else:
raise TypeError("this datatype is only defined for 1D and 2D ndarrays")
raise TypeError(
"this datatype is only defined for 1D and 2D ndarrays"
)
elif index == 0:
raise IndexError("this is a 1-indexed array: no element 0!")
elif index < 0:
Expand All @@ -89,7 +92,7 @@ def __setitem__(self, index, value):
if index[0] is None:
super().__setitem__((index[0], index[1]), value)
elif index[0] > 0:
super().__setitem__((index[0]-1, index[1]), value)
super().__setitem__((index[0] - 1, index[1]), value)
elif index[0] == 0:
raise IndexError("this is a 1-indexed array: no element 0!")
elif index[0] < 0:
Expand Down Expand Up @@ -122,10 +125,11 @@ def __setitem__(self, index, value):
super().__setitem__(index, value)
else:
super().__setitem__(index, value)
# raise IndexError(f"invalid index {index} for OneIndexedArray")

# raise IndexError(f"invalid index {index} for OneIndexedArray")

def __iter__(self):
for idx in range(1,len(self)+1):
for idx in range(1, len(self) + 1):
yield self.__getitem__(idx)

def __hash__(self):
Expand Down
189 changes: 130 additions & 59 deletions cctk/ensemble.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion cctk/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ def read_file(filename, lazy=False):
with open(filename, "r") as filehandle:
lines = filehandle.read().splitlines()
return lines

0 comments on commit e1968b5

Please sign in to comment.