Skip to content

Commit

Permalink
workaround for matplotlib-numpy v2 failures (#527)
Browse files Browse the repository at this point in the history
* workaround for matplotlib-numpy v2 failures

* changelog
  • Loading branch information
mathause committed Mar 25, 2024
1 parent 90325f2 commit 25d7b07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Expand Up @@ -38,7 +38,7 @@ Internal Changes
~~~~~~~~~~~~~~~~

- Get upstream-dev CI to run with numpy 2.0 (:pull:`522`) and fix accrued upstream failures
for rasterio (:pull:`524`) and cartopy (:pull:`525`).
for rasterio (:pull:`524`), cartopy (:pull:`525`), and matplotlib (:pull:`527`).


.. _changelog.0.12.1:
Expand Down
28 changes: 14 additions & 14 deletions regionmask/tests/test_plot.py
Expand Up @@ -285,11 +285,11 @@ def test_plot_lines(plotfunc):
with figure_context():
ax = func(tolerance=None, **maybe_no_coastlines(plotfunc))

lines = ax.collections[0].get_segments()
lines = ax.collections[0].get_paths()

assert len(lines) == 2
assert np.allclose(lines[0], outl1_closed)
assert np.allclose(lines[1], outl2_closed)
assert np.allclose(lines[0].vertices, outl1_closed)
assert np.allclose(lines[1].vertices, outl2_closed)


@requires_matplotlib
Expand All @@ -301,11 +301,11 @@ def test_plot_lines_float_numbers(plotfunc):
with figure_context():
ax = func(tolerance=None, **maybe_no_coastlines(plotfunc))

lines = ax.collections[0].get_segments()
lines = ax.collections[0].get_paths()

assert len(lines) == 2
assert np.allclose(lines[0], outl1_closed)
assert np.allclose(lines[1], outl2_closed)
assert np.allclose(lines[0].vertices, outl1_closed)
assert np.allclose(lines[1].vertices, outl2_closed)


@requires_matplotlib
Expand All @@ -319,10 +319,10 @@ def test_plot_lines_multipoly(plotfunc):
with figure_context():
ax = func(tolerance=None, **maybe_no_coastlines(plotfunc))

lines = ax.collections[0].get_segments()
lines = ax.collections[0].get_paths()
assert len(lines) == 2
assert np.allclose(lines[0], outl1_closed)
assert np.allclose(lines[1], outl2_closed)
assert np.allclose(lines[0].vertices, outl1_closed)
assert np.allclose(lines[1].vertices, outl2_closed)


# -----------------------------------------------------------------------------
Expand All @@ -336,10 +336,10 @@ def test_plot_lines_selection(plotfunc):
func = getattr(r1[0, 1], plotfunc)

ax = func(tolerance=None, **maybe_no_coastlines(plotfunc))
lines = ax.collections[0].get_segments()
lines = ax.collections[0].get_paths()
assert len(lines) == 2
assert np.allclose(lines[0], outl1_closed)
assert np.allclose(lines[1], outl2_closed)
assert np.allclose(lines[0].vertices, outl1_closed)
assert np.allclose(lines[1].vertices, outl2_closed)


@requires_matplotlib
Expand Down Expand Up @@ -430,10 +430,10 @@ def test_plot_lines_from_poly(plotfunc):

with figure_context():
ax = func(**maybe_no_coastlines(plotfunc))
lines = ax.collections[0].get_segments()
lines = ax.collections[0].get_paths()

assert len(lines) == 2
assert np.allclose(lines[0], r2.polygons[0].exterior.coords)
assert np.allclose(lines[0].vertices, r2.polygons[0].exterior.coords)


# -----------------------------------------------------------------------------
Expand Down

0 comments on commit 25d7b07

Please sign in to comment.