Skip to content

Commit

Permalink
allow equality check on tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
nschloe committed Jan 31, 2022
1 parent 363f518 commit a614048
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black
language_version: python3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ perfplot.show(
lambda a: np.concatenate([a[:, None], a[:, None]], axis=1),
],
labels=["c_", "stack", "vstack", "column_stack", "concat"],
n_range=[2 ** k for k in range(25)],
n_range=[2**k for k in range(25)],
xlabel="len(a)",
# More optional arguments with their default values:
# logx="auto", # set to True or False to force scaling
Expand Down
2 changes: 1 addition & 1 deletion example/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
lambda a: np.concatenate([a[:, None], a[:, None]], axis=1),
],
labels=["c_", "stack", "vstack", "column_stack", "concat"],
n_range=[2 ** k for k in range(15)],
n_range=[2**k for k in range(15)],
xlabel="len(a)",
)
13 changes: 11 additions & 2 deletions src/perfplot/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,16 @@ def __next__(self):
reference = val
else:
try:
is_equal = self.equality_check(reference, val)
if isinstance(reference, tuple):
assert isinstance(val, tuple)
assert len(reference) == len(val)
is_equal = True
for r, v in zip(reference, val):
if not self.equality_check(r, v):
is_equal = False
break
else:
is_equal = self.equality_check(reference, val)
except TypeError:
raise PerfplotError(
"Error in equality_check. "
Expand All @@ -264,7 +273,7 @@ def __next__(self):
else:
if not is_equal:
raise PerfplotError(
"Equality check failure. "
"Equality check failure.\n"
+ f"{self.labels[0]}:\n"
+ f"{reference}:\n\n"
+ f"{self.labels[k]}:\n"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def test_live():
kernels = [lambda a: np.c_[a, a]]
r = [2 ** k for k in range(4)]
r = [2**k for k in range(4)]

perfplot.live(
setup=np.random.rand,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_perfplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import perfplot

kernels = [lambda a: np.c_[a, a]]
r = [2 ** k for k in range(4)]
r = [2**k for k in range(4)]


def test0():
Expand Down

0 comments on commit a614048

Please sign in to comment.