Skip to content

Commit 7c2c22e

Browse files
committed
Ignore flake8 exception and code clean-up
1 parent 7a5c50d commit 7c2c22e

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ per-file-ignores =
8080
mpl_toolkits/axisartist/floating_axes.py: E225, E231, E261, E262, E302, E303, E402, E501
8181
mpl_toolkits/axisartist/grid_finder.py: E231, E261, E302, E303, E402
8282
mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E231, E261, E262, E271, E302, E303, E501
83-
mpl_toolkits/mplot3d/art3d.py: E203, E222, E225, E231
83+
mpl_toolkits/mplot3d/art3d.py: E222, E225, E231
8484
mpl_toolkits/mplot3d/axes3d.py: E203, E231, E402, E501, E701
8585
mpl_toolkits/mplot3d/axis3d.py: E231, E302
8686
mpl_toolkits/mplot3d/proj3d.py: E231, E302, E303

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,14 @@ def get_dir_vector(zdir):
7373

7474

7575
def _array_split(arr, indices_or_sections, remove_empty=False):
76-
"""Fix numpy.split to preserve the dimension of empty subarrays.
77-
"""
78-
76+
"""Fix numpy.split to preserve the dimension of empty subarrays."""
7977
arr_chunks = np.split(arr, indices_or_sections)
8078

8179
if arr_chunks[-1].size == 0:
82-
8380
if not remove_empty:
8481
# Preserve the 2D dimensionality the last chunk that can be empty
8582
# (numpy <=1.10 replaces empty chunks by a 1D empty array)
83+
8684
# TODO: The following can be removed when
8785
# support for numpy <=1.10 is dropped.
8886
arr_chunks[-1] = np.empty(shape=(0, arr.shape[1]), dtype=arr.dtype)
@@ -169,8 +167,8 @@ def set_3d_properties(self, zs=0, zdir='z'):
169167
@artist.allow_rasterization
170168
def draw(self, renderer):
171169
xs3d, ys3d, zs3d = self._verts3d
172-
xyz = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
173-
self.set_data(xyz[0], xyz[1])
170+
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
171+
self.set_data(xs, ys)
174172
lines.Line2D.draw(self, renderer)
175173
self.stale = False
176174

@@ -184,9 +182,7 @@ def line_2d_to_3d(line, zs=0, zdir='z'):
184182

185183
def path_to_3d_segment(path, zs=0, zdir='z'):
186184
"""Convert a path to a 3D segment."""
187-
# Pre allocate memory
188185
seg3d = np.ones((3, len(path)))
189-
190186
# Works both if zs is and array and a scalar
191187
seg3d[2, :] *= zs
192188

@@ -208,10 +204,7 @@ def paths_to_3d_segments(paths, zs=0, zdir='z'):
208204

209205
def path_to_3d_segment_with_codes(path, zs=0, zdir='z'):
210206
"""Convert a path to a 3D segment with path codes."""
211-
# Pre allocate memory
212-
# XXX should we consider a 4d array?
213207
seg3d = np.ones((3, len(path)))
214-
215208
# Works both if zs is an array and a scalar
216209
seg3d[2, :] *= zs
217210

@@ -230,12 +223,11 @@ def paths_to_3d_segments_with_codes(paths, zs=0, zdir='z'):
230223
"""
231224

232225
zs = np.broadcast_to(zs, len(paths))
233-
segments = []
234-
codes_list = []
235-
for path, pathz in zip(paths, zs):
236-
segs, codes = path_to_3d_segment_with_codes(path, pathz, zdir)
237-
segments.append(segs)
238-
codes_list.append(codes)
226+
227+
path_generator = (path_to_3d_segment_with_codes(path, pathz, zdir)
228+
for path, pathz in zip(paths, zs))
229+
segments, codes_list = zip(*path_generator)
230+
239231
return np.asarray(segments), np.asarray(codes_list)
240232

241233

@@ -261,14 +253,11 @@ def set_segments(self, segments):
261253

262254
self._segments3d_data = np.empty((n_segments, 4))
263255
self._segments3d_data[:, :3] = np.vstack(segments)
264-
# Add a fourth dimension for quaternions
265256
self._segments3d_data[:, 3] = 1
266257

267258
# For coveniency, store a view of the array in the original shape
268259
self._segments3d = _array_split(self._segments3d_data[:, :3],
269260
np.cumsum(self._seg_sizes))
270-
else:
271-
self._seg_sizes = np.array([])
272261

273262
LineCollection.set_segments(self, [])
274263

@@ -598,7 +587,7 @@ def get_vector(self, segments3d):
598587
n_segments = np.sum(self._seg_sizes)
599588
# Put all segments in a big array
600589
_vec = np.vstack(segments3d)
601-
# Add a fourth dimension for quaternions
590+
# Add a fourth dimension
602591
self._vec = np.hstack([_vec, np.ones((n_segments, 1))]).T
603592

604593
def set_verts(self, verts, closed=True):

lib/mpl_toolkits/mplot3d/proj3d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ def proj_transform_vec_clip(vec, M):
137137
vecw = np.dot(M, vec)
138138
# Determine clipping before rescaling
139139
tis = (0 <= vecw[0]) & (vecw[0] <= 1) & (0 <= vecw[1]) & (vecw[1] <= 1)
140-
# clip here..
141-
# Can anybody comment on this piece of code? I don't understand it...
142140
if np.any(tis):
143141
tis = vecw[1] < 1
144142
vecw /= vecw[3]

0 commit comments

Comments
 (0)