scikit-hep / cabinetry

design and steer profile likelihood fits
https://cabinetry.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
26 stars 21 forks source link

fix: handle negative model predictions in visualizations #394

Closed rmnmllr closed 1 year ago

rmnmllr commented 1 year ago

related to issue https://github.com/scikit-hep/cabinetry/issues/388.

Tried python -m pytest, did not pass all tests even before modifying anything. No additional errors though after the fix and tested with samples mantioned in issue https://github.com/scikit-hep/cabinetry/issues/388.

rmnmllr commented 1 year ago

@alexander-held I'm not sure why the python tests fail, pytest gives an error

>       assert "predicted yield is zero in 1 bin(s), excluded from ratio plot" in [
            rec.message for rec in caplog.records
        ]
E       AssertionError: assert 'predicted yield is zero in 1 bin(s), excluded from ratio plot' in ['predicted yield is zero in 1 bin(s),            excluded from ratio plot']

but this is not something I touched.

alexander-held commented 1 year ago

Thanks a lot for preparing this! I am afraid it may take me until next week to more carefully look at this, sorry for the slow feedback here.

rmnmllr commented 1 year ago

Thanks a lot for preparing this! I am afraid it may take me until next week to more carefully look at this, sorry for the slow feedback here.

No worries, I'm glad I can contribute in some way! And no rush with this, I can run stuff already locally :)

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (4645cb8) 100.00% compared to head (89b4170) 100.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #394 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 23 23 Lines 2059 2065 +6 Branches 324 326 +2 ========================================= + Hits 2059 2065 +6 ``` | [Impacted Files](https://codecov.io/gh/scikit-hep/cabinetry/pull/394?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) | Coverage Δ | | |---|---|---| | [src/cabinetry/visualize/plot\_model.py](https://codecov.io/gh/scikit-hep/cabinetry/pull/394?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep#diff-c3JjL2NhYmluZXRyeS92aXN1YWxpemUvcGxvdF9tb2RlbC5weQ==) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

alexander-held commented 1 year ago

Hi @rmnmllr, I added tests to this to get this ready for inclusion in the next version of cabinetry that I intend to release with #390 also being completed. Thanks a lot for preparing this!

* catch negative total model prediction in visualize.plot_model.data_mc
* handle negative nominal template prediction in visualize.plot_model.templates
rmnmllr commented 1 year ago

Thank you @alexander-held for completing this!