Skip to content

Commit

Permalink
fix warning for n_range containing 0
Browse files Browse the repository at this point in the history
  • Loading branch information
nschloe committed Feb 10, 2021
1 parent 95190fa commit 461658a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions perfplot/main.py
Expand Up @@ -60,7 +60,7 @@ def __init__(
labels,
xlabel,
):
self.n_range = n_range
self.n_range = numpy.asarray(n_range)
self.timings = timings
self.flop = flop
self.labels = labels
Expand All @@ -75,11 +75,14 @@ def plot( # noqa: C901
):
if logx == "auto":
# Check if the x values are approximately equally spaced in log
log_n_range = numpy.log(self.n_range)
diff = log_n_range - numpy.linspace(
log_n_range[0], log_n_range[-1], len(log_n_range)
)
logx = numpy.all(numpy.abs(diff) < 1.0e-5)
if numpy.any(self.n_range <= 0):
logx = False
else:
log_n_range = numpy.log(self.n_range)
diff = log_n_range - numpy.linspace(
log_n_range[0], log_n_range[-1], len(log_n_range)
)
logx = numpy.all(numpy.abs(diff) < 1.0e-5)

if logy == "auto":
if relative_to is not None:
Expand Down

0 comments on commit 461658a

Please sign in to comment.