AxFoundation / strax

Stream analysis for xenon TPCs
BSD 3-Clause "New" or "Revised" License
27 stars 38 forks source link

Bug observed in a corner case of `conditional_entropy` #818

Open dachengx opened 5 months ago

dachengx commented 5 months ago

Describe the bug Originally from https://github.com/AxFoundation/strax/actions/runs/8616664551/job/23614765492?pr=816.

Because that log of GitHub action will not be kept forever, I copy-paste the information here:

=========================== short test summary info ============================
FAILED tests/test_hitlet.py::test_conditional_entropy - AssertionError: Hitlet entropy is -279097920.0, but expected np.nan
assert False
 +  where False = <ufunc 'isnan'>(-279097920.0)
 +    where <ufunc 'isnan'> = np.isnan
Falsifying example: test_conditional_entropy(
    data=array([-1.0000001,  0.       , -1.       ,  1.0000001,  1.       ,
            0.       ,  0.       ,  0.       ], dtype=float32),
    size_template_and_ind_max_template=[0, 1],  # or any other generated value
)

You can reproduce this example by temporarily adding @reproduce_failure('6.98.15', b'AXicY2dkYGBgbAASDA5ABhMQM0AAIyMzkITLsDDAASMDMmAEAEo/AZo=') as a decorator on your test case
=========== 1 failed, 188 passed, 114 warnings in 558.93s (0:09:18) ============

Though the bug is observed in a PR, the error can be reproduced in master branch with commit hash: a1e921fce2519db5e58ac710487a6690475f0438.

To Reproduce Decorate test_conditional_entropy by:

@reproduce_failure('6.98.15', b'AXicY2dkYGBgbAASDA5ABhMQM0AAIyMzkITLsDDAASMDMmAEAEo/AZo=')

then run pytest -xv ./tests/ -k test_conditional_entropy at the top level of strax repo.

Error:

============================================== short test summary info ==============================================
FAILED tests/test_hitlet.py::test_conditional_entropy - AssertionError: Hitlet entropy is -279097920.0, but expected np.nan
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================= 1 failed, 188 deselected in 2.18s =========================================

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Versions a1e921fce2519db5e58ac710487a6690475f0438