Skip to content

Commit

Permalink
fix: update to work with mpl3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejnovak committed Feb 13, 2024
1 parent 048b2b4 commit 4dd7a7b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mplhep/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,8 @@ def __init__(self, xsizes, ysizes, divider):
self.div = divider

def get_size(self, renderer):
xrel, xabs = axes_size.AddList(self.xsizes).get_size(renderer)
yrel, yabs = axes_size.AddList(self.ysizes).get_size(renderer)
xrel, xabs = sum(self.xsizes, start=axes_size.Fixed(0)).get_size(renderer)
yrel, yabs = sum(self.ysizes, start=axes_size.Fixed(0)).get_size(renderer)
bb = Bbox.from_bounds(*self.div.get_position()).transformed(
self.div._fig.transFigure
)
Expand Down
Binary file added tests/baseline/test_square_cbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions tests/test_layouts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from __future__ import annotations

import os

import matplotlib.pyplot as plt
import pytest

os.environ["RUNNING_PYTEST"] = "true"

import mplhep as hep # noqa: E402

"""
To test run:
python pytest -r sa --mpl --mpl-results-path=pytest_results
When adding new tests, run:
python pytest -r sa --mpl --mpl-generate-path=tests/baseline
"""

plt.switch_backend("Agg")


@pytest.mark.mpl_image_compare(style="default", remove_text=True)
def test_square_cbar():
fig, ax = plt.subplots()
ax = hep.make_square_add_cbar(ax=ax)
return fig

0 comments on commit 4dd7a7b

Please sign in to comment.