From 1ca7240ab912d6a6c553f843ac8daaeb403f359b Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 20 Apr 2023 10:54:27 +0200 Subject: [PATCH] Cleanup GridHelperCurveLinear/GridFinder. - GridHelperCurveLinear: numpydocify; remove unused _aux_trans attribute. - GridFinder: This class is used nowhere else but as attribute on GridHelperCurveLinear and could probably be inlined into it; for now, remove the duplicated constructor docstring. --- lib/mpl_toolkits/axisartist/grid_finder.py | 13 ++++----- .../axisartist/grid_helper_curvelinear.py | 27 ++++++++++++------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/lib/mpl_toolkits/axisartist/grid_finder.py b/lib/mpl_toolkits/axisartist/grid_finder.py index 4468eb65f3e7..f969b011c4cd 100644 --- a/lib/mpl_toolkits/axisartist/grid_finder.py +++ b/lib/mpl_toolkits/axisartist/grid_finder.py @@ -121,6 +121,11 @@ def inverted(self): class GridFinder: + """ + Internal helper for `~.grid_helper_curvelinear.GridHelperCurveLinear`, with + the same constructor parameters; should not be directly instantiated. + """ + def __init__(self, transform, extreme_finder=None, @@ -128,14 +133,6 @@ def __init__(self, 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: diff --git a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py index e5ba2c824257..da705704604a 100644 --- a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py @@ -234,18 +234,27 @@ def __init__(self, aux_trans, tick_formatter1=None, tick_formatter2=None): """ - aux_trans : a transform from the source (curved) coordinate to - target (rectilinear) coordinate. An instance of MPL's Transform - (inverse transform should be defined) or a tuple of two callable - objects which defines the transform and its inverse. The callables - need take two arguments of array of source coordinates and - should return two target coordinates. - - e.g., ``x2, y2 = trans(x1, y1)`` + Parameters + ---------- + aux_trans : `.Transform` or tuple[Callable, Callable] + The transform from curved coordinates to rectilinear coordinate: + either a `.Transform` instance (which provides also its inverse), + or a pair of callables ``(trans, inv_trans)`` that define the + transform and its inverse. The callables should have signature:: + + x_rect, y_rect = trans(x_curved, y_curved) + x_curved, y_curved = inv_trans(x_rect, y_rect) + + extreme_finder + + grid_locator1, grid_locator2 + Grid locators for each axis. + + tick_formatter1, tick_formatter2 + Tick formatters for each axis. """ super().__init__() self._grid_info = None - self._aux_trans = aux_trans self.grid_finder = GridFinder(aux_trans, extreme_finder, grid_locator1,