From 3da81019f5114e913d93c0be938f40c20738a1ef Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 5 Apr 2019 00:21:10 +0200 Subject: [PATCH] Deprecate axisartist.grid_finder.GridFinderBase. See changelog for rationale. ... slowly uncrufting axisartist... --- doc/api/next_api_changes/2019-04-04-AL.rst | 7 +++ lib/mpl_toolkits/axisartist/grid_finder.py | 65 +++++++++------------- 2 files changed, 34 insertions(+), 38 deletions(-) create mode 100644 doc/api/next_api_changes/2019-04-04-AL.rst diff --git a/doc/api/next_api_changes/2019-04-04-AL.rst b/doc/api/next_api_changes/2019-04-04-AL.rst new file mode 100644 index 000000000000..730c481817e7 --- /dev/null +++ b/doc/api/next_api_changes/2019-04-04-AL.rst @@ -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`). diff --git a/lib/mpl_toolkits/axisartist/grid_finder.py b/lib/mpl_toolkits/axisartist/grid_finder.py index 0c9a9231c49f..3b217a4b1d56 100644 --- a/lib/mpl_toolkits/axisartist/grid_finder.py +++ b/lib/mpl_toolkits/axisartist/grid_finder.py @@ -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 @@ -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): """ @@ -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):