oracle / graalpython

GraalPy – A high-performance embeddable Python 3 runtime for Java
https://www.graalvm.org/python/
Other
1.24k stars 108 forks source link

np.ndindex fails with TypeError: data type "<%c<%c60" not understood #252

Closed blu3r4y closed 2 years ago

blu3r4y commented 2 years ago

Hi! 👋 I found a bug when using np.ndindex that can be easily reproduced like so.

import numpy as np

a = np.zeros((2, 3))

for x, y in np.ndindex(a.shape):
    print(x, y)

Expected output

0 0
0 1
0 2
1 0
1 1
1 2

Actual output

Traceback (most recent call last):
  File "/mnt/c/data/Dropbox/git/AdventOfCode2021/src/minimal.py", line 5, in <module 'minimal.py'>
    for x, y in np.ndindex(a.shape):
  File "/home/blu3r4y/.graalpython3.8/lib/python3.8/site-packages/numpy-1.16.4-py3.8-linux-x86_64.egg/numpy/lib/index_tricks.py", line 637, in __init__
    x = as_strided(_nx.zeros(1), shape=shape,
  File "/home/blu3r4y/.graalpython3.8/lib/python3.8/site-packages/numpy-1.16.4-py3.8-linux-x86_64.egg/numpy/lib/stride_tricks.py", line 103, in as_strided
    array = np.asarray(DummyArray(interface, base=x))
  File "/home/blu3r4y/.graalpython3.8/lib/python3.8/site-packages/numpy-1.16.4-py3.8-linux-x86_64.egg/numpy/core/numeric.py", line 538, in asarray
    return array(a, dtype, copy=False, order=order)
TypeError: data type "<%c<%c60" not understood

Environment information

msimacek commented 2 years ago

Hi @blu3r4y, thank you for the report. I can reproduce the bug on the current master. I'll be looking into it shortly.