cta-observatory / cta-lstchain

LST prototype testbench chain
https://cta-observatory.github.io/cta-lstchain/
BSD 3-Clause "New" or "Revised" License
26 stars 77 forks source link

Simplify test for scaling true energy in IRFs and try to make it deterministic #1300

Closed morcuended closed 1 month ago

morcuended commented 1 month ago

This test was failing from now and then giving IndexErrors. Here I try to simplify the search for maxima of the EDISP PDF and avoid loops inside the test using pytest parametrization decorator that runs the test for every combination of scaling factor and true energy value.

See action job: https://github.com/cta-observatory/cta-lstchain/actions/runs/11127968103/job/30921574910?pr=1289

         # Check that the maximum of the density probability of the migration has shifted
        order_max = []
        order_max_mod = []
        for idx, _ in enumerate(e_true_list):
            for j in range(len(e_migra)):
                if e_migra_prob[idx][j] > e_migra_prob[idx][j - 1]:
                    order_max.append(j)
                if e_migra_prob_mod[idx][j] > e_migra_prob_mod[idx][j - 1]:
                    order_max_mod.append(j)

        for i in range(len(order_max)):
>           assert order_max[i] != order_max_mod[i]
E           IndexError: list index out of range
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 73.47%. Comparing base (cc1441f) to head (7221fd5). Report is 17 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1300 +/- ## ========================================== - Coverage 73.50% 73.47% -0.04% ========================================== Files 134 134 Lines 14210 14193 -17 ========================================== - Hits 10445 10428 -17 Misses 3765 3765 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.