Skip to content

Commit 6263a99

Browse files
committed
Prepare for making create_dummy_axis not necessary.
create_dummy_axis() sets up some internal _DummyAxis, which should not really have been leaked to end users; instead, we should just always attach a _DummyAxis to locators and formatters at init to start with. _DummyAxis should actually be quite cheap to create, but it does create two Bbox.unit() (dataLim and viewLim) which are *slightly* expensive to create, can be placed by plain tuples, and do not correspond to any APIs on "standard" Axises (there's Axes.dataLim/viewLim, not Axis.dataLim/viewLim). While the offending attributes are on a private class, they are publically accessible e.g. via `locator.create_dummy_axis(); locator.axis` so go through a deprecation to be extra safe.
1 parent 7b6f325 commit 6263a99

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``_DummyAxis.dataLim`` and ``_DummyAxis.viewLim``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated. Use ``get_data_interval()``, ``set_data_interval()``,
4+
``get_view_interval()``, and ``set_view_interval()`` instead.

lib/matplotlib/ticker.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,25 +154,32 @@
154154
class _DummyAxis:
155155
__name__ = "dummy"
156156

157+
# Once the deprecation elapses, replace dataLim and viewLim by plain
158+
# _view_interval and _data_interval private tuples.
159+
dataLim = _api.deprecate_privatize_attribute(
160+
"3.6", alternative="get_data_interval() and set_data_interval()")
161+
viewLim = _api.deprecate_privatize_attribute(
162+
"3.6", alternative="get_view_interval() and set_view_interval()")
163+
157164
def __init__(self, minpos=0):
158-
self.dataLim = mtransforms.Bbox.unit()
159-
self.viewLim = mtransforms.Bbox.unit()
165+
self._dataLim = mtransforms.Bbox.unit()
166+
self._viewLim = mtransforms.Bbox.unit()
160167
self._minpos = minpos
161168

162169
def get_view_interval(self):
163-
return self.viewLim.intervalx
170+
return self._viewLim.intervalx
164171

165172
def set_view_interval(self, vmin, vmax):
166-
self.viewLim.intervalx = vmin, vmax
173+
self._viewLim.intervalx = vmin, vmax
167174

168175
def get_minpos(self):
169176
return self._minpos
170177

171178
def get_data_interval(self):
172-
return self.dataLim.intervalx
179+
return self._dataLim.intervalx
173180

174181
def set_data_interval(self, vmin, vmax):
175-
self.dataLim.intervalx = vmin, vmax
182+
self._dataLim.intervalx = vmin, vmax
176183

177184
def get_tick_space(self):
178185
# Just use the long-standing default of nbins==9

0 commit comments

Comments
 (0)