Open sturmianseq opened 3 years ago
Test lithoxyl/tests/test_stats.py::test_acc_random
is also dependent on the random seed. It passes when executing the test class together (i.e., running pytest lithoxyl/tests/test_stats.py
), but fails when running in isolation (i.e., running pytest lithoxyl/tests/test_stats.py::test_acc_random
) with the following failure message:
============================================================================== FAILURES ===============================================================================
___________________________________________________________________________ test_acc_random ___________________________________________________________________________
def test_acc_random():
data = test_sets['random.random 0.0-1.0']
qa = ReservoirAccumulator(data)
capqa = ReservoirAccumulator(data, cap=True)
p2qa = P2Accumulator(data)
for acc in (qa, capqa, p2qa):
for qp, v in acc.get_quantiles():
if qp > 0:
> assert 0.95 < (v / qp) < 1.05
E assert (0.010605121375992893 / 0.01) < 1.05
lithoxyl/tests/test_stats.py:106: AssertionError
If adding
random.seed(0)
to the beginning of testlithoxyl/tests/test_stats.py::test_momentacc_norm
, and runningpytest lithoxyl/tests/test_stats.py::test_momentacc_norm
, you will see this error message:IMHO, the current way to assert that the skewness is close to
0
is not reasonable, because it in fact asserts that2*round(skewness,2)<0.1*skewness
, which is only true whenskewness<0.005
andround(skewness,2)=0
. However, the skewness of 5000 random samples can often be greater than0.005
.