Skip to content

Commit

Permalink
Merge pull request #138 from nschloe/add-title
Browse files Browse the repository at this point in the history
Add title
  • Loading branch information
nschloe committed Jan 14, 2022
2 parents f1a8cfd + e34f875 commit 76e2836
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<!--[![PyPi downloads](https://img.shields.io/pypi/dm/perfplot.svg?style=flat-square)](https://pypistats.org/packages/perfplot)-->

[![Discord](https://img.shields.io/static/v1?logo=discord&label=chat&message=on%20discord&color=7289da&style=flat-square)](https://discord.gg/hnTJ5MRX2Y)
[![Discord](https://img.shields.io/static/v1?logo=discord&logoColor=white&label=chat&message=on%20discord&color=7289da&style=flat-square)](https://discord.gg/hnTJ5MRX2Y)

[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/perfplot/ci?style=flat-square)](https://github.com/nschloe/perfplot/actions?query=workflow%3Aci)
[![codecov](https://img.shields.io/codecov/c/github/nschloe/perfplot.svg?style=flat-square)](https://codecov.io/gh/nschloe/perfplot)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = perfplot
version = 0.9.13
version = 0.9.14
author = Nico Schlömer
author_email = nico.schloemer@gmail.com
description = Performance plots for Python code snippets
Expand Down
12 changes: 10 additions & 2 deletions src/perfplot/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ def __init__(
flop,
labels: list[str],
xlabel: str | None,
title: str | None,
):
self.n_range = np.asarray(n_range)
self.timings_s = timings_s
self.flop = flop
self.labels = labels
self.xlabel = xlabel
self.title = title

def plot( # noqa: C901
self,
Expand Down Expand Up @@ -136,6 +138,8 @@ def plot( # noqa: C901

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 @@ -257,7 +261,10 @@ def __next__(self):
if not is_equal:
raise PerfplotError(
"Equality check failure. "
+ f"({self.labels[0]}, {self.labels[k]})"
+ f"{self.labels[0]}:\n"
+ f"{reference}:\n\n"
+ f"{self.labels[k]}:\n"
+ f"{val}:\n"
)

# First try with one repetition only.
Expand Down Expand Up @@ -449,6 +456,7 @@ def bench(
flops: Callable | None = None,
labels: list[str] | None = None,
xlabel: str | None = None,
title: str | None = None,
target_time_per_measurement: float = 1.0,
max_time: float | None = None,
equality_check: Callable | None = np.allclose,
Expand Down Expand Up @@ -504,7 +512,7 @@ def callback():
timings_s = timings_s[:i]
n_range = n_range[:i]

return PerfplotData(n_range, timings_s.T, flop, labels, xlabel)
return PerfplotData(n_range, timings_s.T, flop, labels, xlabel, title)


# For backward compatibility:
Expand Down
1 change: 1 addition & 0 deletions tests/test_perfplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_automatic_scale(exp_unit, time_ns, time_unit):
timings_s=timings,
labels=["."], # Suppress no handle error # TODO fix this
xlabel="",
title="",
flop=None,
)
# Has the correct unit been applied to the y_label?
Expand Down

0 comments on commit 76e2836

Please sign in to comment.