8000 Deprecate axisartist.grid_finder.GridFinderBase. by anntzer · Pull Request #13885 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Deprecate axisartist.grid_finder.GridFinderBase. #13885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/api/next_api_changes/2019-04-04-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Deprecations
````````````

``mpl_toolkits.axisartist.grid_finder.GridFinderBase`` is deprecated (its
only use is to be inherited by the `GridFinder` class which just provides
more defaults in the constructor and directly sets the transforms, so
``GridFinderBase``'s methods were just moved to `GridFinder`).
65 changes: 27 additions & 38 deletions lib/mpl_toolkits/axisartist/grid_finder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

import matplotlib.ticker as mticker
from matplotlib import cbook, ticker as mticker
from matplotlib.transforms import Bbox, Transform
from .clip_path import clip_line_to_rect

Expand Down Expand Up @@ -40,26 +40,38 @@ def _add_pad(self, lon_min, lon_max, lat_min, lat_max):
return lon_min, lon_max, lat_min, lat_max


class GridFinderBase(object):
class GridFinder:
def __init__(self,
extreme_finder,
grid_locator1,
grid_locator2,
transform,
extreme_finder=None,
grid_locator1=None,
grid_locator2=None,
tick_formatter1=None,
tick_formatter2=None):
"""
transform : transform from the image coordinate (which will be
the transData of the axes to the world coordinate.
locator1, locator2 : grid locator for 1st and 2nd axis.

Derived must define "transform_xy, inv_transform_xy"
(may use update_transform)
or transform = (transform_xy, inv_transform_xy)

locator1, locator2 : grid locator for 1st and 2nd axis.
"""
super().__init__()
if extreme_finder is None:
extreme_finder = ExtremeFinderSimple(20, 20)
if grid_locator1 is None:
grid_locator1 = MaxNLocator()
if grid_locator2 is None:
grid_locator2 = MaxNLocator()
if tick_formatter1 is None:
tick_formatter1 = FormatterPrettyPrint()
if tick_formatter2 is None:
tick_formatter2 = FormatterPrettyPrint()
self.extreme_finder = extreme_finder
self.grid_locator1 = grid_locator1
self.grid_locator2 = grid_locator2
self.tick_formatter1 = tick_formatter1
self.tick_formatter2 = tick_formatter2
self.update_transform(transform)

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


class GridFinder(GridFinderBase):

@cbook.deprecated("3.2")
class GridFinderBase(GridFinder):
def __init__(self,
transform,
extreme_finder=None,
extreme_finder,
grid_locator1=None,
grid_locator2=None,
tick_formatter1=None,
tick_formatter2=None):
"""
transform : transform from the image coordinate (which will be
the transData of the axes to the world coordinate.

or transform = (transform_xy, inv_transform_xy)

locator1, locator2 : grid locator for 1st and 2nd axis.
"""
if extreme_finder is None:
extreme_finder = ExtremeFinderSimple(20, 20)
if grid_locator1 is None:
grid_locator1 = MaxNLocator()
if grid_locator2 is None:
grid_locator2 = MaxNLocator()
if tick_formatter1 is None:
tick_formatter1 = FormatterPrettyPrint()
if tick_formatter2 is None:
tick_formatter2 = FormatterPrettyPrint()
super().__init__(
extreme_finder,
grid_locator1,
grid_locator2,
tick_formatter1,
tick_formatter2)
self.update_transform(transform)
super().__init__((None, None), extreme_finder,
grid_locator1, grid_locator2,
tick_formatter1, tick_formatter2)


class MaxNLocator(mticker.MaxNLocator):
Expand Down
0