Skip to content

Commit e877dc5

Browse files
committed
catch zero division
1 parent 8e4e496 commit e877dc5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/useq/_z.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ def _start_stop_step(self) -> tuple[float, float, float]:
2828

2929
def positions(self) -> Sequence[float]:
3030
start, stop, step = self._start_stop_step()
31+
if step == 0:
32+
return [start]
3133
stop += step / 2 # make sure we include the last point
3234
return list(np.arange(start, stop, step))
3335

3436
def num_positions(self) -> int:
3537
start, stop, step = self._start_stop_step()
38+
if step == 0:
39+
return 1
3640
nsteps = (stop + step - start) / step
3741
return math.ceil(round(nsteps, 6))
3842

0 commit comments

Comments
 (0)