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

Skip to content

Commit 522b8e9

Browse files
Speed up _vec_pad_ones
1 parent 2306d30 commit 522b8e9

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
@@ -197,10 +197,17 @@ def inv_transform(xs, ys, zs, invM):
197197

198198

199199
def _vec_pad_ones(xs, ys, zs):
200+
# Allocate and then fill for speed
201+
shape = (4,) + np.shape(xs)
200202
if np.ma.isMA(xs) or np.ma.isMA(ys) or np.ma.isMA(zs):
201-
return np.ma.array([xs, ys, zs, np.ones_like(xs)])
203+
result = np.ma.empty(shape)
202204
else:
203-
return np.array([xs, ys, zs, np.ones_like(xs)])
205+
result = np.empty(shape)
206+
result[0] = xs
207+
result[1] = ys
208+
result[2] = zs
209+
result[3] = 1
210+
return result
204211

205212

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

0 commit comments

Comments
 (0)