chao-peng / numpy

The fundamental package for scientific computing with Python.
https://numpy.org
Other
0 stars 0 forks source link

BUG: meshgrid() for 3 or 4 arrays of input is giving wrong results #1

Open chao-peng opened 1 month ago

chao-peng commented 1 month ago

Describe the issue:

meshgrid() works fine with just 2 arrays as input. When working with higher dimension(greater than 3) it fails to construct the meshgrid in the right order.

Reproduce the code example:

A = [1,2,3]
B = [311,422]
C = [0.11,0.22,0.33]
Am, Bm, Cm = np.meshgrid(A,B,C)

Error message:

Expect Bm to be:
array([[[311, 311, 311],
        [422, 422, 422]],

       [[311, 311, 311],
        [422, 422, 422]],

       [[311, 311, 311],
        [422, 422, 422]]])
But get:
array([[[311, 311, 311],
        [311, 311, 311],
        [311, 311, 311]],

       [[422, 422, 422],
        [422, 422, 422],
        [422, 422, 422]]])

Python and NumPy Versions:

1.26.4 3.9.19 | packaged by conda-forge | (main, Mar 20 2024, 12:38:46) [MSC v.1929 64 bit (AMD64)]

Runtime Environment:

[{'numpy_version': '1.26.4', 'python': '3.9.19 | packaged by conda-forge | (main, Mar 20 2024, 12:38:46) ' '[MSC v.1929 64 bit (AMD64)]', 'uname': uname_result(system='Windows', node='DESKTOP-5LVQAIH', release='10', version='10.0.22621', machine='AMD64')}, {'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'], 'found': ['SSSE3', 'SSE41', 'POPCNT', 'SSE42', 'AVX', 'F16C', 'FMA3', 'AVX2', 'AVX512F', 'AVX512CD', 'AVX512_SKX', 'AVX512_CLX', 'AVX512_CNL', 'AVX512_ICL'], 'not_found': []}}, {'architecture': 'SkylakeX', 'filepath': 'C:\Users\LabUser ' 'OPX\AppData\Roaming\Python\Python39\site-packages\numpy.libs\libopenblas64__v0.3.23-293-gc2f4bdbb-gcc_10_3_0-2bde3a66a51006b2b53eb373ff767a3f.dll', 'internal_api': 'openblas', 'num_threads': 16, 'prefix': 'libopenblas', 'threading_layer': 'pthreads', 'user_api': 'blas', 'version': '0.3.23.dev'}, {'architecture': 'SkylakeX', 'filepath': 'C:\Users\LabUser ' 'OPX\AppData\Roaming\Python\Python39\site-packages\scipy.libs\libopenblas_v0.3.27--3aa239bc726cfb0bd8e5330d8d4c15c6.dll', 'internal_api': 'openblas', 'num_threads': 16, 'prefix': 'libopenblas', 'threading_layer': 'pthreads', 'user_api': 'blas', 'version': '0.3.27'}]

Context for the issue:

No response

chao-peng commented 1 month ago

@mentatbot

mentatbot[bot] commented 1 month ago

I will start working on this issue