Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5f5fce3

Browse filesBrowse files
authored
Merge pull request #18661 from anntzer/gfp
Define GridFinder.{,inv_}transform_xy as normal methods.
2 parents 654ad7c + 66cc32a commit 5f5fce3
Copy full SHA for 5f5fce3

File tree

Expand file treeCollapse file tree

1 file changed

+18
-16
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-16
lines changed

‎lib/mpl_toolkits/axisartist/grid_finder.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/grid_finder.py
+18-16Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,26 @@ def _clip_grid_lines_and_find_ticks(self, lines, values, levs, bb):
176176
return gi
177177

178178
def update_transform(self, aux_trans):
179-
if isinstance(aux_trans, Transform):
180-
def transform_xy(x, y):
181-
ll1 = np.column_stack([x, y])
182-
ll2 = aux_trans.transform(ll1)
183-
lon, lat = ll2[:, 0], ll2[:, 1]
184-
return lon, lat
185-
186-
def inv_transform_xy(x, y):
187-
ll1 = np.column_stack([x, y])
188-
ll2 = aux_trans.inverted().transform(ll1)
189-
lon, lat = ll2[:, 0], ll2[:, 1]
190-
return lon, lat
191-
179+
if not isinstance(aux_trans, Transform) and len(aux_trans) != 2:
180+
raise TypeError("'aux_trans' must be either a Transform instance "
181+
"or a pair of callables")
182+
self._aux_transform = aux_trans
183+
184+
def transform_xy(self, x, y):
185+
aux_trf = self._aux_transform
186+
if isinstance(aux_trf, Transform):
187+
return aux_trf.transform(np.column_stack([x, y])).T
192188
else:
193-
transform_xy, inv_transform_xy = aux_trans
189+
transform_xy, inv_transform_xy = aux_trf
190+
return transform_xy(x, y)
194191

195-
self.transform_xy = transform_xy
196-
self.inv_transform_xy = inv_transform_xy
192+
def inv_transform_xy(self, x, y):
193+
aux_trf = self._aux_transform
194+
if isinstance(aux_trf, Transform):
195+
return aux_trf.inverted().transform(np.column_stack([x, y])).T
196+
else:
197+
transform_xy, inv_transform_xy = aux_trf
198+
return inv_transform_xy(x, y)
197199

198200
def update(self, **kw):
199201
for k in kw:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.