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 a5511c3

Browse filesBrowse files
committed
More floating_axes cleanup.
... in particular merging two consecutive `if ... else ...; if ... else ...` that use the same condition, and replacing `astype(float, copy=True)` by just `copy()` as it is clear that the arrays are already float at that point. Also some minor whitespace fixes.
1 parent 9e7a235 commit a5511c3
Copy full SHA for a5511c3

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+10
-16
lines changed

‎lib/mpl_toolkits/axisartist/axis_artist.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/axis_artist.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ def _update_ticks(self, renderer):
10061006
self.major_ticklabels._set_external_pad(0)
10071007
self.minor_ticklabels._set_external_pad(0)
10081008

1009-
majortick_iter, minortick_iter = \
1009+
majortick_iter, minortick_iter = \
10101010
self._axis_artist_helper.get_tick_iterators(self.axes)
10111011

10121012
tick_loc_angle, ticklabel_loc_angle_label = \
@@ -1054,7 +1054,7 @@ def _draw_ticks2(self, renderer):
10541054
self.major_ticklabels._set_external_pad(0)
10551055
self.minor_ticklabels._set_external_pad(0)
10561056

1057-
majortick_iter, minortick_iter = \
1057+
majortick_iter, minortick_iter = \
10581058
self._axis_artist_helper.get_tick_iterators(self.axes)
10591059

10601060
tick_loc_angle, ticklabel_loc_angle_label = \

‎lib/mpl_toolkits/axisartist/floating_axes.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/floating_axes.py
+8-14Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,19 @@ def get_tick_iterators(self, axes):
7070
xx0 = lon_levs
7171
dx = 0.001
7272

73-
_extremes = self.grid_helper._extremes
74-
xmin, xmax = sorted(_extremes[:2])
75-
ymin, ymax = sorted(_extremes[2:])
76-
if self.nth_coord == 0:
77-
mask = (ymin <= yy0) & (yy0 <= ymax)
78-
yy0 = yy0[mask]
79-
elif self.nth_coord == 1:
80-
mask = (xmin <= xx0) & (xx0 <= xmax)
81-
xx0 = xx0[mask]
73+
extremes = self.grid_helper._extremes
74+
xmin, xmax = sorted(extremes[:2])
75+
ymin, ymax = sorted(extremes[2:])
8276

8377
def transform_xy(x, y):
8478
x1, y1 = grid_finder.transform_xy(x, y)
85-
x2y2 = axes.transData.transform(np.array([x1, y1]).transpose())
86-
x2, y2 = x2y2.transpose()
79+
x2, y2 = axes.transData.transform(np.array([x1, y1]).T).T
8780
return x2, y2
8881

89-
# find angles
9082
if self.nth_coord == 0:
83+
mask = (ymin <= yy0) & (yy0 <= ymax)
84+
yy0 = yy0[mask]
9185
xx0 = np.full_like(yy0, self.value)
92-
9386
xx1, yy1 = transform_xy(xx0, yy0)
9487

9588
xx00 = xx0.astype(float, copy=True)
@@ -106,8 +99,9 @@ def transform_xy(x, y):
10699
labels = [l for l, m in zip(labels, mask) if m]
107100

108101
elif self.nth_coord == 1:
102+
mask = (xmin <= xx0) & (xx0 <= xmax)
103+
xx0 = xx0[mask]
109104
yy0 = np.full_like(xx0, self.value)
110-
111105
xx1, yy1 = transform_xy(xx0, yy0)
112106

113107
yy00 = yy0.astype(float, copy=True)

0 commit comments

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