Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6686f97

Browse filesBrowse files
authored
Merge pull request #25588 from ksunden/param_renames
Rename parameters for consistency
2 parents d4e92ce + ffbd01a commit 6686f97
Copy full SHA for 6686f97

File tree

10 files changed

+136
-117
lines changed
Filter options

10 files changed

+136
-117
lines changed

‎ci/mypy-stubtest-allowlist.txt

Copy file name to clipboardExpand all lines: ci/mypy-stubtest-allowlist.txt
-29Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,38 +64,9 @@ matplotlib.ticker.MultipleLocator.set_params
6464
matplotlib.text.Annotation.get_window_extent
6565

6666
# Inconsistent super/sub class parameter name (maybe rename for consistency)
67-
matplotlib.axis.Axis.set_clip_path
68-
matplotlib.axis.Tick.set_clip_path
69-
matplotlib.image.NonUniformImage.set_filternorm
70-
matplotlib.image.NonUniformImage.set_filterrad
71-
matplotlib.projections.geo.AitoffAxes.AitoffTransform.transform_non_affine
72-
matplotlib.projections.geo.AitoffAxes.InvertedAitoffTransform.transform_non_affine
73-
matplotlib.projections.geo.HammerAxes.HammerTransform.transform_non_affine
74-
matplotlib.projections.geo.HammerAxes.InvertedHammerTransform.transform_non_affine
75-
matplotlib.projections.geo.LambertAxes.InvertedLambertTransform.transform_non_affine
76-
matplotlib.projections.geo.LambertAxes.LambertTransform.transform_non_affine
77-
matplotlib.projections.geo.MollweideAxes.InvertedMollweideTransform.transform_non_affine
78-
matplotlib.projections.geo.MollweideAxes.MollweideTransform.transform_non_affine
79-
matplotlib.projections.polar.InvertedPolarTransform.transform_non_affine
80-
matplotlib.projections.polar.PolarTransform.transform_non_affine
8167
matplotlib.projections.polar.RadialLocator.nonsingular
82-
matplotlib.scale.AsinhTransform.transform_non_affine
83-
matplotlib.scale.InvertedAsinhTransform.transform_non_affine
84-
matplotlib.scale.InvertedSymmetricalLogTransform.transform_non_affine
85-
matplotlib.scale.LogisticTransform.transform_non_affine
86-
matplotlib.scale.LogitTransform.transform_non_affine
87-
matplotlib.scale.SymmetricalLogTransform.transform_non_affine
88-
matplotlib.table.Cell.set_transform
8968
matplotlib.ticker.LogLocator.nonsingular
9069
matplotlib.ticker.LogitLocator.nonsingular
91-
matplotlib.transforms.Affine2DBase.transform_affine
92-
matplotlib.transforms.AffineBase.transform_non_affine
93-
matplotlib.transforms.BlendedGenericTransform.transform_non_affine
94-
matplotlib.transforms.CompositeGenericTransform.transform_affine
95-
matplotlib.transforms.CompositeGenericTransform.transform_non_affine
96-
matplotlib.transforms.IdentityTransform.transform_affine
97-
matplotlib.transforms.IdentityTransform.transform_non_affine
98-
matplotlib.transforms.IdentityTransform.transform
9970

10071
# Stdlib/Enum considered inconsistent (no fault of ours, I don't think)
10172
matplotlib.backend_bases._Mode.__new__
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Method parameters renamed to match base classes
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The only parameter of ``transform_affine`` and ``transform_non_affine`` in ``Transform`` subclasses is renamed
5+
to *values*.
6+
7+
The *points* parameter of ``transforms.IdentityTransform.transform`` is renamed to *values*.
8+
9+
The *trans* parameter of ``table.Cell.set_transform`` is renamed to *t* consistently with
10+
`.Artist.set_transform`.
11+
12+
The *clippath* parameters of ``axis.Axis.set_clip_path`` and ``axis.Tick.set_clip_path`` are
13+
renamed to *path* consistently with `.Artist.set_clip_path`.
14+
15+
The *s* parameter of ``images.NonUniformImage.set_filternorm`` is renamed to *filternorm*
16+
consistently with ```_ImageBase.set_filternorm``.
17+
18+
The *s* parameter of ``images.NonUniformImage.set_filterrad`` is renamed to *filterrad*
19+
consistently with ```_ImageBase.set_filterrad``.

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,11 @@ def get_children(self):
229229
self.gridline, self.label1, self.label2]
230230
return children
231231

232-
def set_clip_path(self, clippath, transform=None):
232+
@_api.rename_parameter("3.8", "clippath", "path")
233+
def set_clip_path(self, path, transform=None):
233234
# docstring inherited
234-
super().set_clip_path(clippath, transform)
235-
self.gridline.set_clip_path(clippath, transform)
235+
super().set_clip_path(path, transform)
236+
self.gridline.set_clip_path(path, transform)
236237
self.stale = True
237238

238239
def contains(self, mouseevent):
@@ -1079,10 +1080,11 @@ def _translate_tick_params(kw, reverse=False):
10791080
kwtrans.update(kw_)
10801081
return kwtrans
10811082

1082-
def set_clip_path(self, clippath, transform=None):
1083-
super().set_clip_path(clippath, transform)
1083+
@_api.rename_parameter("3.8", "clippath", "path")
1084+
def set_clip_path(self, path, transform=None):
1085+
super().set_clip_path(path, transform)
10841086
for child in self.majorTicks + self.minorTicks:
1085-
child.set_clip_path(clippath, transform)
1087+
child.set_clip_path(path, transform)
10861088
self.stale = True
10871089

10881090
def get_view_interval(self):

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,10 +1188,12 @@ def get_extent(self):
11881188
raise RuntimeError('Must set data first')
11891189
return self._Ax[0], self._Ax[-1], self._Ay[0], self._Ay[-1]
11901190

1191-
def set_filternorm(self, s):
1191+
@_api.rename_parameter("3.8", "s", "filternorm")
1192+
def set_filternorm(self, filternorm):
11921193
pass
11931194

1194-
def set_filterrad(self, s):
1195+
@_api.rename_parameter("3.8", "s", "filterrad")
1196+
def set_filterrad(self, filterrad):
11951197
pass
11961198

11971199
def set_norm(self, norm):

‎lib/matplotlib/projections/geo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/geo.py
+25-17Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,10 @@ class AitoffAxes(GeoAxes):
251251
class AitoffTransform(_GeoTransform):
252252
"""The base Aitoff transform."""
253253

254-
def transform_non_affine(self, ll):
254+
@_api.rename_parameter("3.8", "ll", "values")
255+
def transform_non_affine(self, values):
255256
# docstring inherited
256-
longitude, latitude = ll.T
257+
longitude, latitude = values.T
257258

258259
# Pre-compute some values
259260
half_long = longitude / 2.0
@@ -272,10 +273,11 @@ def inverted(self):
272273

273274
class InvertedAitoffTransform(_GeoTransform):
274275

275-
def transform_non_affine(self, xy):
276+
@_api.rename_parameter("3.8", "xy", "values")
277+
def transform_non_affine(self, values):
276278
# docstring inherited
277279
# MGDTODO: Math is hard ;(
278-
return np.full_like(xy, np.nan)
280+
return np.full_like(values, np.nan)
279281

280282
def inverted(self):
281283
# docstring inherited
@@ -297,9 +299,10 @@ class HammerAxes(GeoAxes):
297299
class HammerTransform(_GeoTransform):
298300
"""The base Hammer transform."""
299301

300-
def transform_non_affine(self, ll):
302+
@_api.rename_parameter("3.8", "ll", "values")
303+
def transform_non_affine(self, values):
301304
# docstring inherited
302-
longitude, latitude = ll.T
305+
longitude, latitude = values.T
303306
half_long = longitude / 2.0
304307
cos_latitude = np.cos(latitude)
305308
sqrt2 = np.sqrt(2.0)
@@ -314,9 +317,10 @@ def inverted(self):
314317

315318
class InvertedHammerTransform(_GeoTransform):
316319

317-
def transform_non_affine(self, xy):
320+
@_api.rename_parameter("3.8", "xy", "values")
321+
def transform_non_affine(self, values):
318322
# docstring inherited
319-
x, y = xy.T
323+
x, y = values.T
320324
z = np.sqrt(1 - (x / 4) ** 2 - (y / 2) ** 2)
321325
longitude = 2 * np.arctan((z * x) / (2 * (2 * z ** 2 - 1)))
322326
latitude = np.arcsin(y*z)
@@ -342,14 +346,15 @@ class MollweideAxes(GeoAxes):
342346
class MollweideTransform(_GeoTransform):
343347
"""The base Mollweide transform."""
344348

345-
def transform_non_affine(self, ll):
349+
@_api.rename_parameter("3.8", "ll", "values")
350+
def transform_non_affine(self, values):
346351
# docstring inherited
347352
def d(theta):
348353
delta = (-(theta + np.sin(theta) - pi_sin_l)
349354
/ (1 + np.cos(theta)))
350355
return delta, np.abs(delta) > 0.001
351356

352-
longitude, latitude = ll.T
357+
longitude, latitude = values.T
353358

354359
clat = np.pi/2 - np.abs(latitude)
355360
ihigh = clat < 0.087 # within 5 degrees of the poles
@@ -370,7 +375,7 @@ def d(theta):
370375
d = 0.5 * (3 * np.pi * e**2) ** (1.0/3)
371376
aux[ihigh] = (np.pi/2 - d) * np.sign(latitude[ihigh])
372377

373-
xy = np.empty(ll.shape, dtype=float)
378+
xy = np.empty(values.shape, dtype=float)
374379
xy[:, 0] = (2.0 * np.sqrt(2.0) / np.pi) * longitude * np.cos(aux)
375380
xy[:, 1] = np.sqrt(2.0) * np.sin(aux)
376381

@@ -382,9 +387,10 @@ def inverted(self):
382387

383388
class InvertedMollweideTransform(_GeoTransform):
384389

385-
def transform_non_affine(self, xy):
390+
@_api.rename_parameter("3.8", "xy", "values")
391+
def transform_non_affine(self, values):
386392
# docstring inherited
387-
x, y = xy.T
393+
x, y = values.T
388394
# from Equations (7, 8) of
389395
# https://mathworld.wolfram.com/MollweideProjection.html
390396
theta = np.arcsin(y / np.sqrt(2))
@@ -422,9 +428,10 @@ def __init__(self, center_longitude, center_latitude, resolution):
422428
self._center_longitude = center_longitude
423429
self._center_latitude = center_latitude
424430

425-
def transform_non_affine(self, ll):
431+
@_api.rename_parameter("3.8", "ll", "values")
432+
def transform_non_affine(self, values):
426433
# docstring inherited
427-
longitude, latitude = ll.T
434+
longitude, latitude = values.T
428435
clong = self._center_longitude
429436
clat = self._center_latitude
430437
cos_lat = np.cos(latitude)
@@ -455,9 +462,10 @@ def __init__(self, center_longitude, center_latitude, resolution):
455462
self._center_longitude = center_longitude
456463
self._center_latitude = center_latitude
457464

458-
def transform_non_affine(self, xy):
465+
@_api.rename_parameter("3.8", "xy", "values")
466+
def transform_non_affine(self, values):
459467
# docstring inherited
460-
x, y = xy.T
468+
x, y = values.T
461469
clong = self._center_longitude
462470
clat = self._center_latitude
463471
p = np.maximum(np.hypot(x, y), 1e-9)

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ def _get_rorigin(self):
6363
return self._scale_transform.transform(
6464
(0, self._axis.get_rorigin()))[1]
6565

66-
def transform_non_affine(self, tr):
66+
@_api.rename_parameter("3.8", "tr", "values")
67+
def transform_non_affine(self, values):
6768
# docstring inherited
68-
theta, r = np.transpose(tr)
69+
theta, r = np.transpose(values)
6970
# PolarAxes does not use the theta transforms here, but apply them for
7071
# backwards-compatibility if not being used by it.
7172
if self._apply_theta_transforms and self._axis is not None:
@@ -214,9 +215,10 @@ def __init__(self, axis=None, use_rmin=True,
214215
use_rmin="_use_rmin",
215216
_apply_theta_transforms="_apply_theta_transforms")
216217

217-
def transform_non_affine(self, xy):
218+
@_api.rename_parameter("3.8", "xy", "values")
219+
def transform_non_affine(self, values):
218220
# docstring inherited
219-
x, y = xy.T
221+
x, y = values.T
220222
r = np.hypot(x, y)
221223
theta = (np.arctan2(y, x) + 2 * np.pi) % (2 * np.pi)
222224
# PolarAxes does not use the theta transforms here, but apply them for

‎lib/matplotlib/scale.py

Copy file name to clipboardExpand all lines: lib/matplotlib/scale.py
+32-24Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,15 @@ def __str__(self):
213213
return "{}(base={}, nonpositive={!r})".format(
214214
type(self).__name__, self.base, "clip" if self._clip else "mask")
215215

216-
def transform_non_affine(self, a):
216+
@_api.rename_parameter("3.8", "a", "values")
217+
def transform_non_affine(self, values):
217218
# Ignore invalid values due to nans being passed to the transform.
218219
with np.errstate(divide="ignore", invalid="ignore"):
219220
log = {np.e: np.log, 2: np.log2, 10: np.log10}.get(self.base)
220221
if log: # If possible, do everything in a single call to NumPy.
221-
out = log(a)
222+
out = log(values)
222223
else:
223-
out = np.log(a)
224+
out = np.log(values)
224225
out /= np.log(self.base)
225226
if self._clip:
226227
# SVG spec says that conforming viewers must support values up
@@ -232,7 +233,7 @@ def transform_non_affine(self, a):
232233
# pass. On the other hand, in practice, we want to clip beyond
233234
# np.log10(np.nextafter(0, 1)) ~ -323
234235
# so 1000 seems safe.
235-
out[a <= 0] = -1000
236+
out[values <= 0] = -1000
236237
return out
237238

238239
def inverted(self):
@@ -249,8 +250,9 @@ def __init__(self, base):
249250
def __str__(self):
250251
return f"{type(self).__name__}(base={self.base})"
251252

252-
def transform_non_affine(self, a):
253-
return np.power(self.base, a)
253+
@_api.rename_parameter("3.8", "a", "values")
254+
def transform_non_affine(self, values):
255+
return np.power(self.base, values)
254256

255257
def inverted(self):
256258
return LogTransform(self.base)
@@ -360,14 +362,15 @@ def __init__(self, base, linthresh, linscale):
360362
self._linscale_adj = (linscale / (1.0 - self.base ** -1))
361363
self._log_base = np.log(base)
362364

363-
def transform_non_affine(self, a):
364-
abs_a = np.abs(a)
365+
@_api.rename_parameter("3.8", "a", "values")
366+
def transform_non_affine(self, values):
367+
abs_a = np.abs(values)
365368
with np.errstate(divide="ignore", invalid="ignore"):
366-
out = np.sign(a) * self.linthresh * (
369+
out = np.sign(values) * self.linthresh * (
367370
self._linscale_adj +
368371
np.log(abs_a / self.linthresh) / self._log_base)
369372
inside = abs_a <= self.linthresh
370-
out[inside] = a[inside] * self._linscale_adj
373+
out[inside] = values[inside] * self._linscale_adj
371374
return out
372375

373376
def inverted(self):
@@ -387,19 +390,20 @@ def __init__(self, base, linthresh, linscale):
387390
self.linscale = linscale
388391
self._linscale_adj = (linscale / (1.0 - self.base ** -1))
389392

390-
def transform_non_affine(self, a):
391-
abs_a = np.abs(a)
393+
@_api.rename_parameter("3.8", "a", "values")
394+
def transform_non_affine(self, values):
395+
abs_a = np.abs(values)
392396
if (abs_a < self.linthresh).all():
393397
_api.warn_external(
394398
"All values for SymLogScale are below linthresh, making "
395399
"it effectively linear. You likely should lower the value "
396400
"of linthresh. ")
397401
with np.errstate(divide="ignore", invalid="ignore"):
398-
out = np.sign(a) * self.linthresh * (
402+
out = np.sign(values) * self.linthresh * (
399403
np.power(self.base,
400404
abs_a / self.linthresh - self._linscale_adj))
401405
inside = abs_a <= self.invlinthresh
402-
out[inside] = a[inside] / self._linscale_adj
406+
out[inside] = values[inside] / self._linscale_adj
403407
return out
404408

405409
def inverted(self):
@@ -473,8 +477,9 @@ def __init__(self, linear_width):
473477
"must be strictly positive")
474478
self.linear_width = linear_width
475479

476-
def transform_non_affine(self, a):
477-
return self.linear_width * np.arcsinh(a / self.linear_width)
480+
@_api.rename_parameter("3.8", "a", "values")
481+
def transform_non_affine(self, values):
482+
return self.linear_width * np.arcsinh(values / self.linear_width)
478483

479484
def inverted(self):
480485
return InvertedAsinhTransform(self.linear_width)
@@ -488,8 +493,9 @@ def __init__(self, linear_width):
488493
super().__init__()
489494
self.linear_width = linear_width
490495

491-
def transform_non_affine(self, a):
492-
return self.linear_width * np.sinh(a / self.linear_width)
496+
@_api.rename_parameter("3.8", "a", "values")
497+
def transform_non_affine(self, values):
498+
return self.linear_width * np.sinh(values / self.linear_width)
493499

494500
def inverted(self):
495501
return AsinhTransform(self.linear_width)
@@ -588,13 +594,14 @@ def __init__(self, nonpositive='mask'):
588594
self._nonpositive = nonpositive
589595
self._clip = {"clip": True, "mask": False}[nonpositive]
590596

591-
def transform_non_affine(self, a):
597+
@_api.rename_parameter("3.8", "a", "values")
598+
def transform_non_affine(self, values):
592599
"""logit transform (base 10), masked or clipped"""
593600
with np.errstate(divide="ignore", invalid="ignore"):
594-
out = np.log10(a / (1 - a))
601+
out = np.log10(values / (1 - values))
595602
if self._clip: # See LogTransform for choice of clip value.
596-
out[a <= 0] = -1000
597-
out[1 <= a] = 1000
603+
out[values <= 0] = -1000
604+
out[1 <= values] = 1000
598605
return out
599606

600607
def inverted(self):
@@ -611,9 +618,10 @@ def __init__(self, nonpositive='mask'):
611618
super().__init__()
612619
self._nonpositive = nonpositive
613620

614-
def transform_non_affine(self, a):
621+
@_api.rename_parameter("3.8", "a", "values")
622+
def transform_non_affine(self, values):
615623
"""logistic transform (base 10)"""
616-
return 1.0 / (1 + 10**(-a))
624+
return 1.0 / (1 + 10**(-values))
617625

618626
def inverted(self):
619627
return LogitTransform(self._nonpositive)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.