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 ca72ba0

Browse filesBrowse files
author
Oscar Gustafsson
committed
Micro-optimizations related to list handling
1 parent ca946ac commit ca72ba0
Copy full SHA for ca72ba0

File tree

Expand file treeCollapse file tree

2 files changed

+5
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-8
lines changed

‎lib/mpl_toolkits/axisartist/axislines.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/axislines.py
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ def get_gridlines(self, which="major", axis="both"):
354354
locs.extend(self.axes.xaxis.major.locator())
355355
if which in ("both", "minor"):
356356
locs.extend(self.axes.xaxis.minor.locator())
357-
358-
for x in locs:
359-
gridlines.append([[x, x], [y1, y2]])
357+
gridlines.extend([[x, x], [y1, y2]] for x in locs)
360358

361359
if axis in ("both", "y"):
362360
x1, x2 = self.axes.get_xlim()
@@ -365,9 +363,7 @@ def get_gridlines(self, which="major", axis="both"):
365363
locs.extend(self.axes.yaxis.major.locator())
366364
if self.axes.yaxis._minor_tick_kw["gridOn"]:
367365
locs.extend(self.axes.yaxis.minor.locator())
368-
369-
for y in locs:
370-
gridlines.append([[x1, x2], [y, y]])
366+
gridlines.extend([[x1, x2], [y, y]] for y in locs)
371367

372368
return gridlines
373369

‎lib/mpl_toolkits/axisartist/grid_finder.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/grid_finder.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ def _find_line_box_crossings(xys, bbox):
3434
umin, vmin = bbox.min[sl]
3535
umax, vmax = bbox.max[sl]
3636
for u0, inside in [(umin, us > umin), (umax, us < umax)]:
37-
crossings.append([])
37+
cross = []
3838
idxs, = (inside[:-1] ^ inside[1:]).nonzero()
3939
for idx in idxs:
4040
v = vs[idx] + (u0 - us[idx]) * dvs[idx] / dus[idx]
4141
if not vmin <= v <= vmax:
4242
continue
4343
crossing = (u0, v)[sl]
4444
theta = np.degrees(np.arctan2(*dxys[idx][::-1]))
45-
crossings[-1].append((crossing, theta))
45+
cross.append((crossing, theta))
46+
crossings.append(cross)
4647
return crossings
4748

4849

0 commit comments

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