Skip to content

Commit

Permalink
use title instead of ylabel
Browse files Browse the repository at this point in the history
  • Loading branch information
nschloe committed Oct 26, 2020
1 parent 8dd5452 commit 205e6c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ perfplot.show(
# logx=False,
# logy=False,
# More optional arguments with their default values:
# title=None,
# logx="auto", # set to True or False to force scaling
# logy="auto",
# equality_check=numpy.allclose, # set to None to disable "correctness" assertion
Expand Down
15 changes: 5 additions & 10 deletions perfplot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ def __init__(
flop,
labels,
xlabel,
title,
):
self.n_range = n_range
self.timings = timings
self.flop = flop
self.labels = labels
self.xlabel = xlabel
self.title = title

def plot( # noqa: C901
self,
Expand Down Expand Up @@ -106,28 +104,26 @@ def plot( # noqa: C901
assert time_unit in si_time, "Provided `time_unit` is not valid"

scaled_timings = self.timings * (si_time["ns"] / si_time[time_unit])
plt.ylabel(f"Runtime [{time_unit}]")
plt.title(f"Runtime [{time_unit}]")
else:
scaled_timings = self.timings / self.timings[relative_to]
plt.ylabel(f"Runtime relative to {self.labels[relative_to]}()")
plt.title(f"Runtime relative to {self.labels[relative_to]}()")

for t, label in zip(scaled_timings, self.labels):
plotfun(self.n_range, t, label=label)
else:
if relative_to is None:
flops = self.flop / self.timings / si_time["ns"]
plt.ylabel("FLOPS")
plt.title("FLOPS")
else:
flops = self.timings[relative_to] / self.timings
plt.ylabel(f"FLOPS relative to {self.labels[relative_to]}")
plt.title(f"FLOPS relative to {self.labels[relative_to]}")

for fl, label in zip(flops, self.labels):
plotfun(self.n_range, fl, label=label)

if self.xlabel:
plt.xlabel(self.xlabel)
if self.title:
plt.title(self.title)
if relative_to is not None and not logy:
plt.gca().set_ylim(bottom=0)

Expand Down Expand Up @@ -165,7 +161,6 @@ def bench(
flops=None,
labels=None,
xlabel=None,
title=None,
target_time_per_measurement=1.0,
equality_check=numpy.allclose,
show_progress=True,
Expand Down Expand Up @@ -249,7 +244,7 @@ def bench(
timings = timings[:, :i]
n_range = n_range[:i]

data = PerfplotData(n_range, timings, flop, labels, xlabel, title)
data = PerfplotData(n_range, timings, flop, labels, xlabel)
return data


Expand Down
4 changes: 1 addition & 3 deletions test/perfplot_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ def test_automatic_scale(exp_unit, time_ns, time_unit):
timings=numpy.full((1, 1), time_ns, dtype=numpy.uint64),
labels=["."], # Suppress no handle error # TODO fix this
xlabel="",
title="",
flop=None,
)
# Has the correct unit been applied to the y_label?
data.plot(time_unit=time_unit)
ax = plt.gca()
plot_unit = unit_re.search(ax.get_ylabel()).groups()[0]
plot_unit = unit_re.search(ax.get_title()).groups()[0]
assert plot_unit == exp_unit


Expand All @@ -99,7 +98,6 @@ def test_save():
kernels=kernels,
n_range=r,
xlabel="len(a)",
title="mytest",
relative_to=0,
)

Expand Down

0 comments on commit 205e6c7

Please sign in to comment.