Skip to content

Commit

Permalink
Merge pull request #733 from padix-key/celllist
Browse files Browse the repository at this point in the history
Check that finite values are given as query to `CellList`
  • Loading branch information
padix-key authored Jan 23, 2025
2 parents fab175e + 961959e commit 6aae94c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/biotite/structure/celllist.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,14 @@ cdef class CellList:

cdef ptr[:,:,:] cells = self._cells
cdef int[:,:,:] cell_length = self._cell_length
cdef uint8[:] finite_mask = (
np.isfinite(np.asarray(coord)).all(axis=-1).astype(np.uint8, copy=False)
)

for pos_i in range(coord.shape[0]):
if not finite_mask[pos_i]:
# For non-finite coordinates, there are no adjacent atoms
continue
array_i = 0
cell_r = cell_radius[pos_i]
x = coord[pos_i, 0]
Expand Down Expand Up @@ -757,8 +763,8 @@ def _check_coord(coord):
raise ValueError("Coordinates must not be empty")
if coord.shape[1] != 3:
raise ValueError("Coordinates must have form (x,y,z)")
if np.isnan(coord).any():
raise ValueError("Coordinates contain NaN values")
if not np.isfinite(coord).all():
raise ValueError("Coordinates contain non-finite values")


def _empty_result(as_mask):
Expand Down

0 comments on commit 6aae94c

Please sign in to comment.