8000 Deprecate axisartist.grid_finder.GridFinderBase. · matplotlib/matplotlib@3da8101 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3da8101

Browse files
committed
Deprecate axisartist.grid_finder.GridFinderBase.
See changelog for rationale. ... slowly uncrufting axisartist...
1 parent 7fd463e commit 3da8101

File tree

2 files changed

+34
-38
lines changed

2 files changed

+34
-38
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Deprecations
2+
````````````
3+
4+
``mpl_toolkits.axisartist.grid_finder.GridFinderBase`` is deprecated (its
5+
only use is to be inherited by the `GridFinder` class which just provides
6+
more defaults in the constructor and directly sets the transforms, so
7+
``GridFinderBase``'s methods were just moved to `GridFinder`).

lib/mpl_toolkits/axisartist/grid_finder.py

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22

3-
import matplotlib.ticker as mticker
3+
from matplotlib import cbook, ticker as mticker
44
from matplotlib.transforms import Bbox, Transform
55
from .clip_path import clip_line_to_rect
66

@@ -40,26 +40,38 @@ def _add_pad(self, lon_min, lon_max, lat_min, lat_max):
4040
return lon_min, lon_max, lat_min, lat_max
4141

4242

43-
class GridFinderBase(object):
43+
class GridFinder:
4444
def __init__(self,
45-
extreme_finder,
46-
grid_locator1,
47-
grid_locator2,
45+
transform,
46+
extreme_finder=None,
47+
grid_locator1=None,
48+
grid_locator2=None,
4849
tick_formatter1=None,
4950
tick_formatter2=None):
5051
"""
52+
transform : transform from the image coordinate (which will be
5153
the transData of the axes to the world coordinate.
52-
locator1, locator2 : grid locator for 1st and 2nd axis.
5354
54-
Derived must define "transform_xy, inv_transform_xy"
55-
(may use update_transform)
55+
or transform = (transform_xy, inv_transform_xy)
56+
57+
locator1, locator2 : grid locator for 1st and 2nd axis.
5658
"""
57-
super().__init__()
59+
if extreme_finder is None:
60+
extreme_finder = ExtremeFinderSimple(20, 20)
61+
if grid_locator1 is None:
62+
grid_locator1 = MaxNLocator()
63+
if grid_locator2 is None:
64+
grid_locator2 = MaxNLocator()
65+
if tick_formatter1 is None:
66+
tick_formatter1 = FormatterPrettyPrint()
67+
if tick_formatter2 is None:
68+
tick_formatter2 = FormatterPrettyPrint()
5869
self.extreme_finder = extreme_finder
5970
self.grid_locator1 = grid_locator1
6071
self.grid_locator2 = grid_locator2
6172
self.tick_formatter1 = tick_formatter1
6273
self.tick_formatter2 = tick_formatter2
74+
self.update_transform(transform)
6375

6476
def get_grid_info(self, x1, y1, x2, y2):
6577
"""
@@ -190,40 +202,17 @@ def update(self, **kw):
190202
raise ValueError("unknown update property '%s'" % k)
191203

192204

193-
class GridFinder(GridFinderBase):
194-
205+
@cbook.deprecated("3.2")
206+
class GridFinderBase(GridFinder):
195207
def __init__(self,
196-
transform,
197-
extreme_finder=None,
208+
extreme_finder,
198209
grid_locator1=None,
199210
grid_locator2=None,
200211
tick_formatter1=None,
201212
tick_formatter2=None):
202-
"""
203-
transform : transform from the image coordinate (which will be
204-
the transData of the axes to the world coordinate.
205-
206-
or transform = (transform_xy, inv_transform_xy)
207-
208-
locator1, locator2 : grid locator for 1st and 2nd axis.
209-
"""
210-
8000 if extreme_finder is None:
211-
extreme_finder = ExtremeFinderSimple(20, 20)
212-
if grid_locator1 is None:
213-
grid_locator1 = MaxNLocator()
214-
if grid_locator2 is None:
215-
grid_locator2 = MaxNLocator()
216-
if tick_formatter1 is None:
217-
tick_formatter1 = FormatterPrettyPrint()
218-
if tick_formatter2 is None:
219-
tick_formatter2 = FormatterPrettyPrint()
220-
super().__init__(
221-
extreme_finder,
222-
grid_locator1,
223-
grid_locator2,
224-
tick_formatter1,
225-
tick_formatter2)
226-
self.update_transform(transform)
213+
super().__init__((None, None), extreme_finder,
214+
grid_locator1, grid_locator2,
215+
tick_formatter1, tick_formatter2)
227216

228217

229218
class MaxNLocator(mticker.MaxNLocator):

0 commit comments

Comments
 (0)
0