Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74679ab

Browse files
committed
FIX: rename to FuncScale
1 parent 8548e47 commit 74679ab

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

examples/scales/custom_scale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
Unless you are making special use of the `~.Transform` class, you probably
1010
don't need to use this verbose method, and instead can use
11-
`~.matplotlib.scale.ArbitraryScale` and the ``'arbitrary'`` option of
11+
`~.matplotlib.scale.FuncScale` and the ``'function'`` option of
1212
`~.matplotlib.axes.Axes.set_xscale` and `~.matplotlib.axes.Axes.set_yscale`.
1313
See the last example in :doc:`/gallery/scales/scales`.
1414
"""

examples/scales/scales.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Illustrate the scale transformations applied to axes, e.g. log, symlog, logit.
77
8-
The last two examples are examples of using the ``'arbitrary'`` scale by
8+
The last two examples are examples of using the ``'function'`` scale by
99
supplying forward and inverse functions for the scale transformation.
1010
"""
1111
import numpy as np
@@ -57,7 +57,7 @@
5757
ax.yaxis.set_minor_formatter(NullFormatter())
5858

5959

60-
# Arbitrary x**(1/2)
60+
# Function x**(1/2)
6161
def forward(x):
6262
return x**(1/2)
6363

@@ -68,14 +68,14 @@ def inverse(x):
6868

6969
ax = axs[2, 0]
7070
ax.plot(x, y)
71-
ax.set_yscale('arbitrary', functions=(forward, inverse))
72-
ax.set_title('arbitrary: $x^{1/2}$')
71+
ax.set_yscale('function', functions=(forward, inverse))
72+
ax.set_title('function: $x^{1/2}$')
7373
ax.grid(True)
7474
ax.yaxis.set_major_locator(FixedLocator(np.arange(0, 1, 0.2)**2))
7575
ax.yaxis.set_major_locator(FixedLocator(np.arange(0, 1, 0.2)))
7676

7777

78-
# Arbitrary Mercator transform
78+
# Function Mercator transform
7979
def forward(a):
8080
a = np.deg2rad(a)
8181
# mask values too close to +/- 90, which are ill-defined.
@@ -99,8 +99,8 @@ def inverse(a):
9999

100100
ax.plot(t, s, '-', lw=2)
101101

102-
ax.set_yscale('arbitrary', functions=(forward, inverse))
103-
ax.set_title('arbitrary: Mercator')
102+
ax.set_yscale('function', functions=(forward, inverse))
103+
ax.set_title('function: Mercator')
104104
ax.grid(True)
105105
ax.set_xlim([-180, 180])
106106
ax.yaxis.set_minor_formatter(NullFormatter())
@@ -126,4 +126,4 @@ def inverse(a):
126126
matplotlib.scale.LogScale
127127
matplotlib.scale.LinearScale
128128
matplotlib.scale.SymmetricalLogScale
129-
matplotlib.scale.ArbitraryScale
129+
matplotlib.scale.FuncScale

lib/matplotlib/scale.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_transform(self):
8282
return IdentityTransform()
8383

8484

85-
class ArbitraryTransform(Transform):
85+
class FuncTransform(Transform):
8686
"""
8787
A simple transform that takes and arbitrary function for the
8888
forward and inverse transform.
@@ -114,22 +114,22 @@ def forward(values: array-like) ->
114114
self._forward = forward
115115
self._inverse = inverse
116116
else:
117-
raise ValueError('arguments to ArbitraryTransform must '
117+
raise ValueError('arguments to FuncTransform must '
118118
'be functions')
119119

120120
def transform_non_affine(self, values):
121121
return self._forward(values)
122122

123123
def inverted(self):
124-
return ArbitraryTransform(self._inverse, self._forward)
124+
return FuncTransform(self._inverse, self._forward)
125125

126126

127-
class ArbitraryScale(ScaleBase):
127+
class FuncScale(ScaleBase):
128128
"""
129-
Provide an arbitrary scale for the axis.
129+
Provide an arbitrary scale with user-supplied function for the axis.
130130
"""
131131

132-
name = 'arbitrary'
132+
name = 'function'
133133

134134
def __init__(self, axis, functions):
135135
"""
@@ -149,7 +149,7 @@ def forward(values: array-like) ->
149149
array-likeThe forward function for the transform
150150
"""
151151
forward, inverse = functions
152-
transform = ArbitraryTransform(forward, inverse)
152+
transform = FuncTransform(forward, inverse)
153153
self._transform = transform
154154

155155
def get_transform(self):
@@ -636,7 +636,7 @@ def limit_range_for_scale(self, vmin, vmax, minpos):
636636
'log': LogScale,
637637
'symlog': SymmetricalLogScale,
638638
'logit': LogitScale,
639-
'arbitrary': ArbitraryScale,
639+
'function': FuncScale,
640640
}
641641

642642

lib/matplotlib/tests/test_scale.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def test_invalid_log_lims():
152152
assert ax.get_ylim() == original_ylim
153153

154154

155-
@image_comparison(baseline_images=['arbitrary_scales'], remove_text=True,
155+
@image_comparison(baseline_images=['function_scales'], remove_text=True,
156156
extensions=['png'], style='mpl20')
157-
def test_arbitrary_scale():
157+
def test_function_scale():
158158
def inverse(x):
159159
return x**2
160160

@@ -169,5 +169,5 @@ def forward(x):
169169
x = np.arange(1, 1000)
170170

171171
ax.plot(x, x)
172-
ax.set_xscale('arbitrary', functions=(forward, inverse))
172+
ax.set_xscale('function', functions=(forward, inverse))
173173
ax.set_xlim(1, 1000)

0 commit comments

Comments
 (0)