Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7b6cf7f

Browse files
Speed up _vec_pad_ones
1 parent 962210c commit 7b6cf7f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/mpl_toolkits/mplot3d/proj3d.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,17 @@ def inv_transform(xs, ys, zs, invM):
221221

222222

223223
def _vec_pad_ones(xs, ys, zs):
224+
# Allocate and then fill for speed
225+
shape = (4,) + np.shape(xs)
224226
if np.ma.isMA(xs) or np.ma.isMA(ys) or np.ma.isMA(zs):
225-
return np.ma.array([xs, ys, zs, np.ones_like(xs)])
227+
result = np.ma.empty(shape)
226228
else:
227-
return np.array([xs, ys, zs, np.ones_like(xs)])
229+
result = np.empty(shape)
230+
result[0] = xs
231+
result[1] = ys
232+
result[2] = zs
233+
result[3] = 1
234+
return result
228235

229236

230237
def proj_transform(xs, ys, zs, M):

0 commit comments

Comments
 (0)