Skip to content

Commit 674a522

Browse files
committed
MNT: Make transforms.nonsingular private
1 parent 0088182 commit 674a522

File tree

8 files changed

+23
-17
lines changed

8 files changed

+23
-17
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5662,8 +5662,8 @@ def reduce_C_function(C: array) -> float
56625662
ymin, ymax = (ty.min(), ty.max()) if len(y) else (0, 1)
56635663

56645664
# to avoid issues with singular data, expand the min/max pairs
5665-
xmin, xmax = mtransforms.nonsingular(xmin, xmax, expander=0.1)
5666-
ymin, ymax = mtransforms.nonsingular(ymin, ymax, expander=0.1)
5665+
xmin, xmax = mtransforms._nonsingular(xmin, xmax, expander=0.1)
5666+
ymin, ymax = mtransforms._nonsingular(ymin, ymax, expander=0.1)
56675667

56685668
nx1 = nx + 1
56695669
ny1 = ny + 1

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3050,7 +3050,7 @@ def handle_single_axis(
30503050
x0, x1 = (-np.inf, np.inf)
30513051
# If x0 and x1 are nonfinite, get default limits from the locator.
30523052
locator = axis.get_major_locator()
3053-
x0, x1 = locator.nonsingular(x0, x1)
3053+
x0, x1 = locator._nonsingular(x0, x1)
30543054
# Find the minimum minpos for use in the margin calculation.
30553055
minimum_minpos = min(
30563056
getattr(ax.dataLim, f"minpos{name}") for ax in shared)

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ def _process_values(self):
10981098
# If we still aren't scaled after autoscaling, use 0, 1 as default
10991099
self.norm.vmin = 0
11001100
self.norm.vmax = 1
1101-
self.norm.vmin, self.norm.vmax = mtransforms.nonsingular(
1101+
self.norm.vmin, self.norm.vmax = mtransforms._nonsingular(
11021102
self.norm.vmin, self.norm.vmax, expander=0.1)
11031103
if (not isinstance(self.norm, colors.BoundaryNorm) and
11041104
(self.boundaries is None)):

lib/matplotlib/projections/polar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def view_limits(self, vmin, vmax):
469469
if self._zero_in_bounds() and vmax > vmin:
470470
# this allows inverted r/y-lims
471471
vmin = min(0, vmin)
472-
return mtransforms.nonsingular(vmin, vmax)
472+
return mtransforms._nonsingular(vmin, vmax)
473473

474474

475475
class _ThetaShift(mtransforms.ScaledTranslation):

lib/matplotlib/tests/test_transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ def test_nonsingular():
977977
zero_expansion = np.array([-0.001, 0.001])
978978
cases = [(0, np.nan), (0, 0), (0, 7.9e-317)]
979979
for args in cases:
980-
out = np.array(mtransforms.nonsingular(*args))
980+
out = np.array(mtransforms._nonsingular(*args))
981981
assert_array_equal(out, zero_expansion)
982982

983983

lib/matplotlib/ticker.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ def __call__(self, x, pos=None):
10291029
return ''
10301030

10311031
vmin, vmax = self.axis.get_view_interval()
1032-
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
1032+
vmin, vmax = mtransforms._nonsingular(vmin, vmax, expander=0.05)
10331033
s = self._num_to_string(x, vmin, vmax)
10341034
return self.fix_minus(s)
10351035

@@ -1730,15 +1730,15 @@ def nonsingular(self, v0, v1):
17301730
default view limits.
17311731
- Otherwise, ``(v0, v1)`` is returned without modification.
17321732
"""
1733-
return mtransforms.nonsingular(v0, v1, expander=.05)
1733+
return mtransforms._nonsingular(v0, v1, expander=.05)
17341734

17351735
def view_limits(self, vmin, vmax):
17361736
"""
17371737
Select a scale for the range from vmin to vmax.
17381738
17391739
Subclasses should override this method to change locator behaviour.
17401740
"""
1741-
return mtransforms.nonsingular(vmin, vmax)
1741+
return mtransforms._nonsingular(vmin, vmax)
17421742

17431743

17441744
class IndexLocator(Locator):
@@ -1881,7 +1881,7 @@ def __call__(self):
18811881
return self.tick_values(vmin, vmax)
18821882

18831883
def tick_values(self, vmin, vmax):
1884-
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
1884+
vmin, vmax = mtransforms._nonsingular(vmin, vmax, expander=0.05)
18851885

18861886
if (vmin, vmax) in self.presets:
18871887
return self.presets[(vmin, vmax)]
@@ -1910,7 +1910,7 @@ def view_limits(self, vmin, vmax):
19101910
vmin = math.floor(scale * vmin) / scale
19111911
vmax = math.ceil(scale * vmax) / scale
19121912

1913-
return mtransforms.nonsingular(vmin, vmax)
1913+
return mtransforms._nonsingular(vmin, vmax)
19141914

19151915

19161916
class MultipleLocator(Locator):
@@ -1980,7 +1980,7 @@ def view_limits(self, dmin, dmax):
19801980
vmin = dmin
19811981
vmax = dmax
19821982

1983-
return mtransforms.nonsingular(vmin, vmax)
1983+
return mtransforms._nonsingular(vmin, vmax)
19841984

19851985

19861986
def scale_range(vmin, vmax, n=1, threshold=100):
@@ -2236,7 +2236,7 @@ def tick_values(self, vmin, vmax):
22362236
if self._symmetric:
22372237
vmax = max(abs(vmin), abs(vmax))
22382238
vmin = -vmax
2239-
vmin, vmax = mtransforms.nonsingular(
2239+
vmin, vmax = mtransforms._nonsingular(
22402240
vmin, vmax, expander=1e-13, tiny=1e-14)
22412241
locs = self._raw_ticks(vmin, vmax)
22422242

@@ -2254,7 +2254,7 @@ def view_limits(self, dmin, dmax):
22542254
dmax = max(abs(dmin), abs(dmax))
22552255
dmin = -dmax
22562256

2257-
dmin, dmax = mtransforms.nonsingular(
2257+
dmin, dmax = mtransforms._nonsingular(
22582258
dmin, dmax, expander=1e-12, tiny=1e-13)
22592259

22602260
if mpl.rcParams['axes.autolimit_mode'] == 'round_numbers':
@@ -2718,7 +2718,7 @@ def view_limits(self, vmin, vmax):
27182718
vmin = _decade_less(vmin, b)
27192719
vmax = _decade_greater(vmax, b)
27202720

2721-
return mtransforms.nonsingular(vmin, vmax)
2721+
return mtransforms._nonsingular(vmin, vmax)
27222722

27232723

27242724
class AsinhLocator(Locator):

lib/matplotlib/transforms.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2865,7 +2865,7 @@ def _revalidate(self):
28652865
super()._revalidate()
28662866

28672867

2868-
def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
2868+
def _nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
28692869
"""
28702870
Modify the endpoints of a range as needed to avoid singularities.
28712871
@@ -2923,6 +2923,12 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
29232923
return vmin, vmax
29242924

29252925

2926+
@_api.deprecated("3.11")
2927+
def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
2928+
return _nonsingular(vmin, vmax, expander, tiny, increasing)
2929+
nonsingular.__doc__ = _nonsingular.__doc__
2930+
2931+
29262932
def interval_contains(interval, val):
29272933
"""
29282934
Check, inclusively, whether an interval includes a given value.

lib/matplotlib/transforms.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class TransformedPath(TransformNode):
316316
class TransformedPatchPath(TransformedPath):
317317
def __init__(self, patch: Patch) -> None: ...
318318

319-
def nonsingular(
319+
def _nonsingular(
320320
vmin: float,
321321
vmax: float,
322322
expander: float = ...,

0 commit comments

Comments
 (0)