Skip to content

Commit 018d15a

Browse files
committed
Fix fig.format/grid.format issues with basemap projections
1 parent c7fe3e7 commit 018d15a

5 files changed

Lines changed: 22 additions & 22 deletions

File tree

proplot/axes/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,8 @@ def __init__(self, *args, **kwargs):
706706
kw_format = _pop_props(kwargs, 'patch') # background properties
707707
if 'zorder' in kw_format: # special case: refers to the entire axes
708708
kwargs['zorder'] = kw_format.pop('zorder')
709-
for name in {None, self._name}: # base method and class method (if it exists)
710-
kw_format.update(_pop_params(kwargs, self._format_signatures.get(name)))
709+
for cls in {Axes, type(self)}:
710+
kw_format.update(_pop_params(kwargs, self._format_signatures.get(cls)))
711711
super().__init__(*args, **kwargs)
712712

713713
# Varous scalar properties
@@ -3048,5 +3048,5 @@ def number(self, num):
30483048

30493049
# Apply signature obfuscation after storing previous signature
30503050
# NOTE: This is needed for __init__
3051-
Axes._format_signatures = {None: inspect.signature(Axes.format)}
3051+
Axes._format_signatures = {Axes: inspect.signature(Axes.format)}
30523052
Axes.format = docstring._obfuscate_kwargs(Axes.format)

proplot/axes/cartesian.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ def _parse_alt(self, x, **kwargs):
12191219
"""
12201220
Optionally omit the leading x or y from "twin axes" methods.
12211221
"""
1222-
sig = self._format_signatures[self._name]
1222+
sig = self._format_signatures[type(self)]
12231223
keys = tuple(key[1:] for key in sig.parameters if key[0] == x)
12241224
kwargs = {(x + key if key in keys else key): val for key, val in kwargs.items()}
12251225
for axis in 'xy': # standardize format() location aliases
@@ -1351,5 +1351,5 @@ def get_tightbbox(self, renderer, *args, **kwargs):
13511351

13521352
# Apply signature obfuscation after storing previous signature
13531353
# NOTE: This is needed for __init__, altx, and alty
1354-
CartesianAxes._format_signatures[CartesianAxes._name] = inspect.signature(CartesianAxes.format) # noqa: E501
1354+
CartesianAxes._format_signatures[CartesianAxes] = inspect.signature(CartesianAxes.format) # noqa: E501
13551355
CartesianAxes.format = docstring._obfuscate_kwargs(CartesianAxes.format)

proplot/axes/geo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,5 @@ def _update_minor_gridlines(self, longrid=None, latgrid=None, nsteps=None):
14181418

14191419

14201420
# Apply signature obfuscation after storing previous signature
1421-
GeoAxes._format_signatures[_CartopyAxes._name] = inspect.signature(GeoAxes.format)
1422-
GeoAxes._format_signatures[_BasemapAxes._name] = inspect.signature(GeoAxes.format)
1421+
GeoAxes._format_signatures[GeoAxes] = inspect.signature(GeoAxes.format)
14231422
GeoAxes.format = docstring._obfuscate_kwargs(GeoAxes.format)

proplot/axes/polar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,5 +335,5 @@ def format(
335335

336336
# Apply signature obfuscation after storing previous signature
337337
# NOTE: This is needed for __init__
338-
PolarAxes._format_signatures[PolarAxes._name] = inspect.signature(PolarAxes.format)
338+
PolarAxes._format_signatures[PolarAxes] = inspect.signature(PolarAxes.format)
339339
PolarAxes.format = docstring._obfuscate_kwargs(PolarAxes.format)

proplot/figure.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,26 +1542,27 @@ def format(
15421542
# Update the main axes
15431543
if skip_axes: # avoid recursion
15441544
return
1545-
names = set() # track used dictionaries
1546-
dicts = {
1547-
name: _pop_params(kwargs, sig)
1548-
for name, sig in paxes.Axes._format_signatures.items()
1545+
kws = {
1546+
cls: _pop_params(kwargs, sig)
1547+
for cls, sig in paxes.Axes._format_signatures.items()
15491548
}
1549+
classes = set() # track used dictionaries
15501550
for ax in axs:
1551-
dict_ = {}
1552-
for name in {None, ax._name}:
1553-
names.add(name)
1554-
dict_.update(dicts.get(name, {}))
1555-
ax.format(rc_kw=rc_kw, rc_mode=rc_mode, skip_figure=True, **dict_, **kwargs)
1551+
kw = {
1552+
key: value for cls, kw in kws.items()
1553+
for key, value in kw.items()
1554+
if isinstance(ax, cls) and not classes.add(cls)
1555+
}
1556+
ax.format(rc_kw=rc_kw, rc_mode=rc_mode, skip_figure=True, **kw, **kwargs)
15561557

15571558
# Warn unused keyword argument(s)
1558-
other = {
1559-
key: value for name in dicts.keys() - names
1560-
for key, value in dicts[name].items()
1559+
kw = {
1560+
key: value for name in kws.keys() - classes
1561+
for key, value in kws[name].items()
15611562
}
1562-
if other:
1563+
if kw:
15631564
warnings._warn_proplot(
1564-
f'Ignoring unused projection-specific format() keyword argument(s): {other}' # noqa: E501
1565+
f'Ignoring unused projection-specific format() keyword argument(s): {kw}' # noqa: E501
15651566
)
15661567

15671568
@docstring._concatenate_inherited

0 commit comments

Comments
 (0)