Skip to content

Commit bff079f

Browse files
committed
fix: if nsteps <0 raise error for support reshape
1 parent 10535e9 commit bff079f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

LoopStructural/interpolators/supports/_3d_base_structured.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ def origin(self, origin):
134134
origin = np.array(origin)
135135
length = self.maximum - origin
136136
length /= self.step_vector
137-
self._nsteps = np.ceil(length).astype(int)
137+
self._nsteps = np.ceil(length).astype(np.int64)
138+
self._nsteps[self._nsteps == 0] = (
139+
3 # need to have a minimum of 3 elements to apply the finite difference mask
140+
)
141+
if np.any(~(self._nsteps > 0)):
142+
logger.error(
143+
f"Cannot resize the interpolation support. The proposed number of steps is {self._nsteps}, these must be all > 0"
144+
)
145+
raise ValueError("Cannot resize the interpolation support.")
138146
self._origin = origin
139147
self.onGeometryChange()
140148

@@ -150,7 +158,8 @@ def maximum(self, maximum):
150158
maximum = np.array(maximum, dtype=float)
151159
length = maximum - self.origin
152160
length /= self.step_vector
153-
self._nsteps = np.ceil(length).astype(np.int64) + 1
161+
self._nsteps = np.ceil(length).astype(np.int64)
162+
self._nsteps[self._nsteps == 0] = 3
154163
if np.any(~(self._nsteps > 0)):
155164
logger.error(
156165
f"Cannot resize the interpolation support. The proposed number of steps is {self._nsteps}, these must be all > 0"

0 commit comments

Comments
 (0)