AssertionError: Equality check failure.
gchilczuk opened this issue · 3 comments
Here is my code:
import random
import perfplot
def _any(funcs):
return any(f() for f in funcs)
def _for(funcs):
for f in funcs:
if f():
return True
return False
perfplot.show(
setup=lambda k: [lambda *args, **kwargs: random.choice((True, False)) for _ in range(k)],
kernels=[_any, _for],
labels=['any', 'for'],
n_range=[2**k for k in range(15)],
xlabel='len(a)'
)
I'm not modifying the code, just trying to run it multiple times.
It's working… sometimes. And sometimes it throws an error:
AssertionError: Equality check failure. (any, any)
another time it throws:
AssertionError: Equality check failure. (any, for)
Sometimes it fails instantly and sometimes after a few visible actions (loading bar).
And, as I said, sometimes it works perfectly as I expect.
I've tested it on Python3.6.5 and Python3.7.0 and behaviour were the same.
is it something wrong with my code or is it some kind of bug?
is it something wrong with my code
Yes. If you run your function _any
twice with the same input data (which are functions), the results vary because of your use of random
. perfplot recognizes this as a bug and throws and error. If this behavior is fine for you, you can specify equality_check=None
.
Such a tiny bug, your advice helped me a lot, thank you!
Good to know about equality_check=None
!