summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 2aa104174..ae1420b72 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -4505,24 +4505,21 @@ def meshgrid(*xi, **kwargs):
"Valid values for `indexing` are 'xy' and 'ij'.")
s0 = (1,) * ndim
- output = [np.asanyarray(x).reshape(s0[:i] + (-1,) + s0[i + 1::])
+ output = [np.asanyarray(x).reshape(s0[:i] + (-1,) + s0[i + 1:])
for i, x in enumerate(xi)]
- shape = [x.size for x in output]
-
if indexing == 'xy' and ndim > 1:
# switch first and second axis
- output[0].shape = (1, -1) + (1,)*(ndim - 2)
- output[1].shape = (-1, 1) + (1,)*(ndim - 2)
- shape[0], shape[1] = shape[1], shape[0]
-
- if copy_:
- output = [x.copy() for x in output]
+ output[0].shape = (1, -1) + s0[2:]
+ output[1].shape = (-1, 1) + s0[2:]
- if not sparse and len(output) > 0:
+ if not sparse:
# Return the full N-D matrix (not only the 1-D vector)
output = np.broadcast_arrays(*output, subok=True)
+ if copy_:
+ output = [x.copy() for x in output]
+
return output