Alcampopiano / hypothesize

Robust statistics in Python
https://alcampopiano.github.io/hypothesize/
BSD 3-Clause "New" or "Revised" License
62 stars 3 forks source link

test_corb fails #7

Closed arbennett closed 4 years ago

arbennett commented 4 years ago

When running tests the test_corb function fails with the message:

E       AssertionError: assert {'ci': [-0.3537591633617352, 0.2968061934534894],\n 'cor': -0.07149960819769877,\n 'p_value': 0.5800000000000001} == {'ci': [-0.35375916336173524, 0.2968061934534894],\n 'cor': -0.07149960819769878,\n 'p_value': 0.5800000000000001}
E         Common items:
E         {'p_value': 0.5800000000000001}
E         Differing items:
E         {'cor': -0.07149960819769877} != {'cor': -0.07149960819769878}
E         {'ci': [-0.3537591633617352, 0.2968061934534894]} != {'ci': [-0.35375916336173524, 0.2968061934534894]}
E         Full diff:
E           {
E         -  'ci': [-0.35375916336173524, 0.2968061934534894],
E         ?                            -
E         +  'ci': [-0.3537591633617352, 0.2968061934534894],
E         -  'cor': -0.07149960819769878,
E         ?                            ^
E         +  'cor': -0.07149960819769877,
E         ?                            ^
E            'p_value': 0.5800000000000001,
E           }

It looks like this error is being thrown most likely due to slight version differences, numerical roundoff, or differences in machine architectures since the actual values are very close. Perhaps instead of looking for absolute equality these tests could use something like np.allclose?

Alcampopiano commented 4 years ago

Hello @arbennett,

This makes so much sense. Thank you very much for pointing this out to me. I've added more tolerant assertions now as you've suggested (for arrays and DataFrames). I will close this issue but feel free to reopen if I have not addressed your suggestion sufficiently.