Skip to content

Commit a48d365

Browse files
committed
Check diff with respect to the original PR
1 parent a3c331d commit a48d365

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ def set_3d_properties(self, zs=0, zdir='z'):
141141
xs = self.get_xdata()
142142
ys = self.get_ydata()
143143

144-
if not cbook.iterable(zs):
145-
zs = np.ones(len(xs)) * zs
144+
zs = np.broadcast_to(zs, len(xs))
146145
xyz = np.asarray([xs, ys, zs])
147146
self._verts3d = juggle_axes_vec(xyz, zdir)
148147
self.stale = True
@@ -170,7 +169,7 @@ def path_to_3d_segment(path, zs=0, zdir='z'):
170169

171170
# Works either if zs is array or scalar
172171
seg3d[2] *= zs
173-
172+
174173
pathsegs = path.iter_segments(simplify=False, curves=False)
175174
for i, ((x, y), code) in enumerate(pathsegs):
176175
seg3d[0:2, i] = x, y
@@ -181,13 +180,11 @@ def path_to_3d_segment(path, zs=0, zdir='z'):
181180
def paths_to_3d_segments(paths, zs=0, zdir='z'):
182181
"""Convert paths from a collection object to 3D segments."""
183182

184-
if not cbook.iterable(zs):
185-
zs = np.ones(len(paths)) * zs
183+
zs = np.broadcast_to(zs, len(paths))
186184

187-
segments = []
188-
for path, pathz in zip(paths, zs):
189-
segments.append(path_to_3d_segment(path, pathz, zdir))
190-
return np.asarray(segments)
185+
segs = [path_to_3d_segment(path, pathz, zdir)
186+
for path, pathz in zip(paths, zs)]
187+
return np.asarray(segs)
191188

192189

193190
def path_to_3d_segment_with_codes(path, zs=0, zdir='z'):
@@ -196,7 +193,7 @@ def path_to_3d_segment_with_codes(path, zs=0, zdir='z'):
196193
# XXX should we consider a 4d array?
197194
seg3d = np.ones((3, len(path)))
198195

199-
# Works either if zs is array or scalar
196+
# Works both if zs is an array and a scalar
200197
seg3d[2] *= zs
201198

202199
pathsegs = path.iter_segments(simplify=False, curves=False)
@@ -235,7 +232,7 @@ def set_sort_zpos(self, val):
235232

236233
def set_segments(self, segments):
237234
"""
238-
Set 3D segments
235+
Set 3D segments.
239236
"""
240237
self._seg_sizes = [len(c) for c in segments]
241238
self._segments3d = []
@@ -296,7 +293,8 @@ def __init__(self, *args, zs=(), zdir='z', **kwargs):
296293
self.set_3d_properties(zs, zdir)
297294

298295
def set_3d_properties(self, verts, zs=0, zdir='z'):
299-
verts = np.hstack([verts, np.ones((len(verts), 1)) * zs])
296+
zs = np.broadcast_to(zs, len(verts))
297+
verts = np.hstack([verts, zs])
300298
self._segment3d = juggle_axes_vec(verts.T, zdir)
301299
self._facecolor3d = Patch.get_facecolor(self)
302300

@@ -753,7 +751,7 @@ def juggle_axes_vec(xyz, zdir):
753751
return xyz[[2, 0, 1]]
754752
elif zdir == 'y':
755753
return xyz[[0, 2, 1]]
756-
elif zdir[0] == '-':
754+
elif zdir.startswith('-'):
757755
return rotate_axes_vec(xyz, zdir)
758756
else:
759757
return xyz
@@ -769,12 +767,10 @@ def rotate_axes(xs, ys, zs, zdir):
769767
return ys, zs, xs
770768
elif zdir == '-x':
771769
return zs, xs, ys
772-
773770
elif zdir == 'y':
774771
return zs, xs, ys
775772
elif zdir == '-y':
776773
return ys, zs, xs
777-
778774
else:
779775
return xs, ys, zs
780776

lib/mpl_toolkits/mplot3d/proj3d.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ def proj_transform_vec(vec, M):
136136
def proj_transform_vec_clip(vec, M):
137137
vecw = np.dot(M, vec)
138138
# Determine clipping before rescaling
139-
tis = (vecw[0] >= 0) * (vecw[0] <= 1) * (vecw[1] >= 0) * (vecw[1] <= 1)
139+
tis = (0 <= vecw[0]) & (vecw[0] <= 1) & (0 <= vecw[1]) & (vecw[1] <= 1)
140140
# clip here..
141141
# Can anybody comment on this piece of code? I don't understand it...
142-
if np.sometrue(tis):
142+
if np.any(tis):
143143
tis = vecw[1] < 1
144144
vecw /= vecw[3]
145145
# Integrating tis in the numpy array for optimization purposes

0 commit comments

Comments
 (0)