Skip to content

Commit

Permalink
Add __len__ to class
Browse files Browse the repository at this point in the history
  • Loading branch information
c-feldmann committed Sep 13, 2024
1 parent ce55a52 commit 9e72d67
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scikit_mol/_invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def __init__(self, array_list: list[npt.NDArray[Any] | InvalidInstance]):
self.value_array = np.vstack(valid_vector_list)
self.invalid_list = filter_by_list(array_list, ~self.is_valid_array)

def __len__(self):
return self.is_valid_array.shape[0]

def __getitem__(self, item: int) -> npt.NDArray[Any] | InvalidInstance:
n_invalids_prior = sum(~self.is_valid_array[:item - 1])
if self.is_valid_array[item]:
Expand Down

0 comments on commit 9e72d67

Please sign in to comment.