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: compatibility with matplotlib 3.6 #366

Closed alexander-held closed 1 year ago

alexander-held commented 1 year ago

matplotlib 3.6 (overview) deprecates set_tight_layout and slightly changes figure layout, requiring updates to references. The new layout_engine module in matplotlib is however not available in earlier versions, and matplotlib 3.6 requires Python 3.8.

We need to check the version of matplotib to correctly handle versions <3.6 and >=3.6. Using .__version__ was confirmed as a safe approach to use for matplotlib. See also https://discuss.python.org/t/dynamic-versions-in-editable-installations/15220/56. When not using .__version__, the alternative approach to use should be importlib.metadata.version (or the importlib-metadata port).

The coverage is now evaluated with Python 3.8 (previously Python 3.7 was used) to focus on the behavior with the latest matplotlib version.

Since pyhf 0.7 brought another API change (https://github.com/scikit-hep/pyhf/pull/2027) compared to RC4, pin to that RC temporarily for CI to work (will be relaxed again right afterwards via #367).

The RTD theme for Sphinx causes CI to fail in the latest version due to https://github.com/readthedocs/sphinx_rtd_theme/issues/1343, so that version is also excluded explicitly to fix this.

* refactor deprecated use of set_tight_layout
* update reference figures to matplotlib 3.6
* handle API differences between matplotlib<3.6 (for Python 3.7) and matplotlib>=3.6
* temporarily pin pyhf==0.7.0rc4
* skip latest Sphinx version for which RTD theme is broken
* switch from Python 3.7 to 3.8 for coverage evaluation
codecov[bot] commented 1 year ago

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:

Coverage data is based on head (5bcfe24) compared to base (f0f9593). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #366 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 23 23 Lines 2019 2023 +4 Branches 331 331 ========================================= + Hits 2019 2023 +4 ``` | [Impacted Files](https://codecov.io/gh/scikit-hep/cabinetry/pull/366?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/366/diff?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%> (ø)` | | | [src/cabinetry/visualize/plot\_result.py](https://codecov.io/gh/scikit-hep/cabinetry/pull/366/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep#diff-c3JjL2NhYmluZXRyeS92aXN1YWxpemUvcGxvdF9yZXN1bHQucHk=) | `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 at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.