Skip to content

Commit

Permalink
Merge pull request #2333 from rcomer/draw-deprecations
Browse files Browse the repository at this point in the history
MNT: remove FeatureArtist.draw args and kwargs
  • Loading branch information
greglucas authored Mar 5, 2024
2 parents 36eb99e + 7d19336 commit ebae1d0
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lib/cartopy/mpl/feature_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""

from collections import OrderedDict
import warnings
import weakref

Expand All @@ -21,7 +20,6 @@
import cartopy.feature as cfeature
from cartopy.mpl import _MPL_38
import cartopy.mpl.patch as cpatch
from .style import merge as style_merge


class _GeomKey:
Expand Down Expand Up @@ -154,7 +152,7 @@ def set_paths(self, paths):
self._paths = paths

@matplotlib.artist.allow_rasterization
def draw(self, renderer, *args, **kwargs):
def draw(self, renderer):
"""
Draw the geometries of the feature that intersect with the extent of
the :class:`cartopy.mpl.geoaxes.GeoAxes` instance to which this
Expand Down Expand Up @@ -186,12 +184,13 @@ def draw(self, renderer, *args, **kwargs):
# in view.
geoms = self._feature.intersecting_geometries(extent)

# Freeze the kwargs so that we can use them as a dict key. We will
# need to unfreeze this with dict(frozen) before passing to mpl.
prepared_kwargs = _freeze(kwargs)
stylised_paths = {}
# Make an empty placeholder style dictionary for when styler is not
# used. Freeze it so that we can use it as a dict key. We will need
# to unfreeze all style dicts with dict(frozen) before passing to mpl.
no_style = _freeze({})

# Project (if necessary) and convert geometries to matplotlib paths.
stylised_paths = OrderedDict()
key = ax.projection
for geom in geoms:
# As Shapely geometries cannot be relied upon to be
Expand Down Expand Up @@ -225,14 +224,11 @@ def draw(self, renderer, *args, **kwargs):
geom_path = mpath.Path.make_compound_path(*geom_paths)
mapping[key] = geom_path

if not self._styler:
style = prepared_kwargs
if self._styler is None:
stylised_paths.setdefault(no_style, []).append(geom_path)
else:
# Unfreeze, then add the computed style, and then re-freeze.
style = style_merge(dict(prepared_kwargs), self._styler(geom))
style = _freeze(style)

stylised_paths.setdefault(style, []).append(geom_path)
style = _freeze(self._styler(geom))
stylised_paths.setdefault(style, []).append(geom_path)

self.set_clip_path(ax.patch)

Expand Down

0 comments on commit ebae1d0

Please sign in to comment.