Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove GeoAxes patch at next Cartopy release #5977

Closed
trexfeathers opened this issue May 24, 2024 · 7 comments · Fixed by #6171
Closed

Remove GeoAxes patch at next Cartopy release #5977

trexfeathers opened this issue May 24, 2024 · 7 comments · Fixed by #6171

Comments

@trexfeathers
Copy link
Contributor

📰 Custom Issue

SciTools/cartopy#2390

iris/lib/iris/plot.py

Lines 46 to 60 in 57096f2

class _GeoAxesPatched(cartopy.mpl.geoaxes.GeoAxes):
# TODO: see cartopy#2390
# Remove this once the bug is addressed in a Cartopy release.
def _draw_preprocess(self, renderer):
super()._draw_preprocess(renderer)
for artist in self.artists:
if hasattr(artist, "_draw_gridliner"):
# Note this is only necessary since Cartopy v0.23, but is not
# wasteful for earlier versions as _draw_gridliner() includes
# a check for whether a draw is necessary.
artist._draw_gridliner(renderer=renderer)
cartopy.mpl.geoaxes.GeoAxes = _GeoAxesPatched

@rcomer
Copy link
Member

rcomer commented Oct 8, 2024

Cartopy 0.24 is now out.

@schlunma
Copy link
Contributor

Hi!

With the release of cartopy 0.24 the current iris 3.10.0 package on conda-forge will throw the following exception when trying to plot a map:

TypeError: _GeoAxesPatched._draw_preprocess() missing 1 required positional argument: 'renderer' 

I could trace back this error to the piece of code that you mention here (i.e., removing it solves this error).

MRE:

import matplotlib.pyplot as plt

import iris
import iris.quickplot as qplt

fname = iris.sample_data_path("air_temp.pp")
temperature_cube = iris.load_cube(fname)

# Draw the contour with 25 levels.
qplt.contourf(temperature_cube, 25)

# Add coastlines to the map created by contourf.
plt.gca().coastlines()

plt.show()

@rcomer
Copy link
Member

rcomer commented Oct 10, 2024

Ah, that would be my fault again 😬 . renderer wasn't getting used in _draw_preprocess so we removed that at SciTools/cartopy#2424

@trexfeathers
Copy link
Contributor Author

trexfeathers commented Oct 10, 2024

I'm working on it right now guys: #6171.

Unfortunately updating to Cartopy 0.24 has produced some material image test failures so I need to make sure I understand why before we can move forward.

If that takes too long or I'm too dumb then I'll have to use a pin in the short term.

@valeriupredoi
Copy link

cheers, guys! We're gonna pin ESMValTool's cartopy<0.24 right now, and will release a new build with it 👍

@trexfeathers
Copy link
Contributor Author

@pp-mo I currently have no intention of removing the patch at the next Cartopy release. Could you explain the re-opening? You mentioned to me offline that in several years' time we will probably have a minimum pin >0.23, but that's a long way off and I wouldn't want to use an issue to track something like that.

@pp-mo
Copy link
Member

pp-mo commented Oct 15, 2024

@trexfeathers I currently have no intention of removing the patch at the next Cartopy release. Could you explain the re-opening? You mentioned to me offline that in several years' time we will probably have a minimum pin >0.23, but that's a long way off and I wouldn't want to use an issue to track something like that.

OK I get it, we don't have a way of scheduling this, so let's just leave it there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants