Skip to content

Commit

Permalink
catch zero division
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Aug 6, 2023
1 parent 8e4e496 commit e877dc5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/useq/_z.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ def _start_stop_step(self) -> tuple[float, float, float]:

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

def num_positions(self) -> int:
start, stop, step = self._start_stop_step()
if step == 0:
return 1
nsteps = (stop + step - start) / step
return math.ceil(round(nsteps, 6))

Expand Down

0 comments on commit e877dc5

Please sign in to comment.