nschloe/perfplot

[BUG] custom equality_check fails for tuples

pdemarti opened this issue · 0 comments

Describe the bug

The equality_check callback is not called with the actual results of the kernels if those results are tuples.

To Reproduce

def f(n):
    return n, 'something'

def g(n):
    return n, 'something else'

perfplot.plot(
    setup=lambda n: n,
    n_range=[3, 4],
    kernels=[f, g],
    equality_check=lambda a, b: a[0] == b[0],
)

# raises  TypeError: 'int' object is not subscriptable

When checking with a custom function (def check(*args): ...), I noticed that the function is called with args=[1, 1] instead of the expected args=[(3,0), (3,1)] (when n==3). Looking at the code src/perfplot/_main.py#L265, it looks like there is some special and undocumented handling of tuple results: equality_check() is called on each pair of elements of the tuples.

Diagnose

conda list perfplot
# packages in environment at /mnt/miniconda3/envs/py39:
#
# Name                    Version                   Build  Channel
perfplot                  0.10.2             pyh6c4a22f_0    conda-forge

Did I help?

If I was able to resolve your problem, consider sponsoring my work on perfplot, or buy me a coffee to say thanks.