Skip to content

Commit

Permalink
fix: isinside and init with list
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlangrose committed Dec 3, 2023
1 parent 6bc2f00 commit 0ff6735
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions LoopStructural/datatypes/_bounding_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def __init__(
maximum: Optional[np.ndarray] = None,
nsteps: Optional[np.ndarray] = None,
):
self._origin = origin
self._maximum = maximum
self._origin = np.array(origin)
self._maximum = np.array(maximum)
self.dimensions = dimensions
if nsteps is None:
self.nsteps = np.array([50, 50, 25])
Expand Down Expand Up @@ -122,7 +122,13 @@ def __getitem__(self, name):
return self.get_value(name)

def is_inside(self, xyz):
inside = np.zeros(xyz.shape[0], dtype=bool)
if len(xyz.shape) == 1:
xyz = xyz.reshape((1, -1))
if xyz.shape[1] != 3:
raise LoopValueError(
f"locations array is {xyz.shape[1]}D but bounding box is {self.dimensions}"
)
inside = np.ones(xyz.shape[0], dtype=bool)
inside = np.logical_and(inside, xyz[:, 0] > self.origin[0])
inside = np.logical_and(inside, xyz[:, 0] < self.maximum[0])
inside = np.logical_and(inside, xyz[:, 1] > self.origin[1])
Expand Down

0 comments on commit 0ff6735

Please sign in to comment.