Skip to content

Commit 0ff6735

Browse files
committed
fix: isinside and init with list
1 parent 6bc2f00 commit 0ff6735

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

LoopStructural/datatypes/_bounding_box.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def __init__(
1212
maximum: Optional[np.ndarray] = None,
1313
nsteps: Optional[np.ndarray] = None,
1414
):
15-
self._origin = origin
16-
self._maximum = maximum
15+
self._origin = np.array(origin)
16+
self._maximum = np.array(maximum)
1717
self.dimensions = dimensions
1818
if nsteps is None:
1919
self.nsteps = np.array([50, 50, 25])
@@ -122,7 +122,13 @@ def __getitem__(self, name):
122122
return self.get_value(name)
123123

124124
def is_inside(self, xyz):
125-
inside = np.zeros(xyz.shape[0], dtype=bool)
125+
if len(xyz.shape) == 1:
126+
xyz = xyz.reshape((1, -1))
127+
if xyz.shape[1] != 3:
128+
raise LoopValueError(
129+
f"locations array is {xyz.shape[1]}D but bounding box is {self.dimensions}"
130+
)
131+
inside = np.ones(xyz.shape[0], dtype=bool)
126132
inside = np.logical_and(inside, xyz[:, 0] > self.origin[0])
127133
inside = np.logical_and(inside, xyz[:, 0] < self.maximum[0])
128134
inside = np.logical_and(inside, xyz[:, 1] > self.origin[1])

0 commit comments

Comments
 (0)