I'm working with the perfplot library to compare the performance of three functions f1
, f2
and f3
. The functions are supposed to return the same values, so I want to do equality checks. However, all other examples of perfplot I can find on the internet use pd.DataFrame.equals
or np.allclose
as an equality checker but these don't work for my specific case.
For example, np.allclose
wouldn't work if the functions return a list of numpy arrays of different lengths.
import perfplot
import numpy as np
def f1(rng):
return [np.array(range(i)) for i in rng]
def f2(rng):
return [np.array(list(rng)[:i]) for i in range(len(rng))]
def f3(rng):
return [np.array([*range(i)]) for i in rng]
perfplot.show(
kernels=[f1, f2, f3],
n_range=[10**k for k in range(4)],
setup=lambda n: range(n),
equality_check=np.allclose # <-- doesn't work; neither does pd.DataFrame.equals
)
How do I pass a function that is different from the aforementioned functions?