Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Define GridFinder.{,inv_}transform_xy as normal methods. #18661

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
Oct 5, 2020
Merged
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
34 changes: 18 additions & 16 deletions lib/mpl_toolkits/axisartist/grid_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,26 @@ def _clip_grid_lines_and_find_ticks(self, lines, values, levs, bb):
return gi

def update_transform(self, aux_trans):
if isinstance(aux_trans, Transform):
def transform_xy(x, y):
ll1 = np.column_stack([x, y])
ll2 = aux_trans.transform(ll1)
lon, lat = ll2[:, 0], ll2[:, 1]
return lon, lat

def inv_transform_xy(x, y):
ll1 = np.column_stack([x, y])
ll2 = aux_trans.inverted().transform(ll1)
lon, lat = ll2[:, 0], ll2[:, 1]
return lon, lat

if not isinstance(aux_trans, Transform) and len(aux_trans) != 2:
raise TypeError("'aux_trans' must be either a Transform instance "
"or a pair of callables")
self._aux_transform = aux_trans

def transform_xy(self, x, y):
aux_trf = self._aux_transform
if isinstance(aux_trf, Transform):
return aux_trf.transform(np.column_stack([x, y])).T
else:
transform_xy, inv_transform_xy = aux_trans
transform_xy, inv_transform_xy = aux_trf
return transform_xy(x, y)

self.transform_xy = transform_xy
self.inv_transform_xy = inv_transform_xy
def inv_transform_xy(self, x, y):
aux_trf = self._aux_transform
if isinstance(aux_trf, Transform):
return aux_trf.inverted().transform(np.column_stack([x, y])).T
else:
transform_xy, inv_transform_xy = aux_trf
return inv_transform_xy(x, y)

def update(self, **kw):
for k in kw:
Expand Down