Skip to content

Commit

Permalink
default_equality_check: accept strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nschloe committed Mar 3, 2022
1 parent 2c55564 commit 505a259
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/perfplot/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
}


def default_equality_check(a, b):
if isinstance(a, str):
return a == b

return np.allclose(a, b)


def _auto_time_unit(time_s: float) -> str:
"""Automatically obtains a readable unit at which to plot :py:attr:`timings` of the
benchmarking process. This is accomplished by converting the minimum measured
Expand Down Expand Up @@ -351,7 +358,7 @@ def live(
xlabel: str | None = None,
target_time_per_measurement: float = 1.0,
max_time: float | None = None,
equality_check: Callable | None = np.allclose,
equality_check: Callable | None = default_equality_check,
show_progress: bool = True,
logx: Literal["auto"] | bool = "auto",
logy: Literal["auto"] | bool = "auto",
Expand Down Expand Up @@ -472,7 +479,7 @@ def bench(
title: str | None = None,
target_time_per_measurement: float = 1.0,
max_time: float | None = None,
equality_check: Callable | None = np.allclose,
equality_check: Callable | None = default_equality_check,
show_progress: bool = True,
):
if labels is None:
Expand Down

0 comments on commit 505a259

Please sign in to comment.