Skip to content

Commit

Permalink
Make arange() endpoint-inclusive for -ve step size
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Sep 19, 2021
1 parent e210c92 commit ec1f841
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions proplot/utils.py
Expand Up @@ -168,13 +168,13 @@ def arange(min_, *args):
# All input is integer
if all(isinstance(val, Integral) for val in (min_, max_, step)):
min_, max_, step = np.int64(min_), np.int64(max_), np.int64(step)
max_ += np.sign(step) * 1
max_ += np.sign(step)
# Input is float or mixed, cast to float64
# Don't use np.nextafter with np.finfo(np.dtype(np.float64)).max, because
# round-off errors from continually adding step to min mess this up
else:
min_, max_, step = np.float64(min_), np.float64(max_), np.float64(step)
max_ += np.sign(step) * (step / 2)
max_ += 0.5 * step
return np.arange(min_, max_, step)


Expand Down

0 comments on commit ec1f841

Please sign in to comment.