diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2016-11-06 17:56:06 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-06 17:56:06 +1300 |
commit | e287741d60205bb920dea15d4e70178453db2788 (patch) | |
tree | 126c74deebdb141ce355319d60ac5f18e4c3ebc0 /numpy/lib/function_base.py | |
parent | 9aff656065f2749b83abf127472cafc28e235222 (diff) | |
parent | ecf11a6710a354db52dfb5fe073ee1ce6e15bd3e (diff) | |
download | numpy-e287741d60205bb920dea15d4e70178453db2788.tar.gz |
Merge pull request #5302 from idfah/master
Fixed meshgrid to return arrays with same dtype as arguments.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 98b0413a1..4172c26b5 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -4530,18 +4530,14 @@ def meshgrid(*xi, **kwargs): output[1].shape = (-1, 1) + (1,)*(ndim - 2) shape[0], shape[1] = shape[1], shape[0] - if sparse: - if copy_: - return [x.copy() for x in output] - else: - return output - else: + if copy_: + output = [x.copy() for x in output] + + if not sparse and len(output) > 0: # Return the full N-D matrix (not only the 1-D vector) - if copy_: - mult_fact = np.ones(shape, dtype=int) - return [x * mult_fact for x in output] - else: - return np.broadcast_arrays(*output) + output = np.broadcast_arrays(*output, subok=True) + + return output def delete(arr, obj, axis=None): |