New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Printing a Numpy structured array containing a string column throws an error #5777
Comments
Thanks for the report, I can reproduce. |
This seems to fix it: from numba import njit, objmode
import numpy as np
values_dtype = np.dtype([
('one', 'U10'),
('two', 'f8')
])
@njit
def my_test():
values = np.zeros(2, dtype=values_dtype)
values['one'][0] = 'test'
print(values['one'][0])
return values
result = my_test()
print(my_test.py_func().dtype)
print(my_test().dtype)
print(my_test()) it's probably junk in memory/string not null-terminated. |
@stuartarchibald I also wanted to share (just in case it is helpful), that when you instantiate the structured array containing a unicode/string field and then try to print it inside of the jitted function, Python as whole crashes. (I am using Jupyter notebook for these tests on a Mac). For example:
|
Thanks, it's probably an invalid/OOB read from
This would be fine: from numba import njit, gdb
import numpy as np
values_dtype = np.dtype([
('one', 'U10'),
('two', 'f8')
])
@njit(debug=True)
def my_test():
values = np.zeros(2, dtype=values_dtype)
print(values)
return values
result = my_test() |
This works:
But when jitting the function, it doesn't:
Note that the error is thrown by the
print
statement:UnicodeDecodeError: 'utf-32-le' codec can't decode bytes in position 0-3: code point not in range(0x110000)
numba: 0.49.1
numpy: 1.18.4
python: 3.7.1
the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).
The text was updated successfully, but these errors were encountered: