Skip to content

Remove idiosyncratic get_tick_iterator API. #27300

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
Nov 10, 2023
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
3 changes: 3 additions & 0 deletions doc/api/next_api_changes/deprecations/27300-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``GridHelperCurveLinear.get_tick_iterator``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... is deprecated with no replacement.
22 changes: 15 additions & 7 deletions lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import functools
from itertools import chain

import numpy as np

Expand Down Expand Up @@ -76,10 +75,18 @@ def get_tick_iterators(self, axes):
"top": "bottom", "bottom": "top"}[self.side]
else:
side = self.side
g = self.grid_helper
ti1 = g.get_tick_iterator(self.nth_coord_ticks, side)
ti2 = g.get_tick_iterator(1-self.nth_coord_ticks, side, minor=True)
return chain(ti1, ti2), iter([])

angle_tangent = dict(left=90, right=90, bottom=0, top=0)[side]

def iter_major():
for nth_coord, show_labels in [
(self.nth_coord_ticks, True), (1 - self.nth_coord_ticks, False)]:
gi = self.grid_helper._grid_info[["lon", "lat"][nth_coord]]
for (xy, angle_normal), l in zip(
gi["tick_locs"][side], gi["tick_labels"][side]):
yield xy, angle_normal, angle_tangent, (l if show_labels else "")

return iter_major(), iter([])


class FloatingAxisArtistHelper(_FloatingAxisArtistHelperBase):
Expand Down Expand Up @@ -211,14 +218,14 @@ def trf_xy(x, y):
in_01 = functools.partial(
mpl.transforms._interval_contains_close, (0, 1))

def f1():
def iter_major():
for x, y, normal, tangent, lab \
in zip(xx1, yy1, angle_normal, angle_tangent, labels):
c2 = tick_to_axes.transform((x, y))
if in_01(c2[0]) and in_01(c2[1]):
yield [x, y], *np.rad2deg([normal, tangent]), lab

return f1(), iter([])
return iter_major(), iter([])

def get_line_transform(self, axes):
return axes.transData
Expand Down Expand Up @@ -309,6 +316,7 @@ def get_gridlines(self, which="major", axis="both"):
grid_lines.extend(gl)
return grid_lines

@_api.deprecated("3.9")
def get_tick_iterator(self, nth_coord, axis_side, minor=False):
angle_tangent = dict(left=90, right=90, bottom=0, top=0)[axis_side]
lon_or_lat = ["lon", "lat"][nth_coord]
Expand Down