You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For me it is not only on printing but also on creation see below where I try to assign the array to a variable.
>>> a = np.array([np.array(u"åäö")])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\python27\lib\site-packages\numpy\core\numeric.py", line 1615, in array_str
return array2string(a, max_line_width, precision, suppress_small, ' ', "", str)
File "C:\python27\lib\site-packages\numpy\core\arrayprint.py", line 448, in array2string
lst = style(x)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
Activity
pv commentedon Sep 7, 2014
The issue seems to be only in printing the arrays, creation etc. themselves seem to work fine.
juliantaylor commentedon Sep 7, 2014
array_printis called withstrwhich won't work in python2maybe one can add a try except around it and use unicode
jstenar commentedon Sep 7, 2014
For me it is not only on printing but also on creation see below where I try to assign the array to a variable.
jstenar commentedon Jun 3, 2015
I do not see this problem on python 3.4 with numpy 1.9.2 but it is still present for python 2.7 with numpy 1.9.2
eric-wieser commentedon Apr 6, 2017
Seems like something pretty nasty is going on here -
array_strshould definitely not be on the construction path fornp.array.If you modify
array2stringto catch this array and emit a new string, then this string ends up in the array instead!eric-wieser commentedon Apr 6, 2017
Reproduction on python 3 with this small function
giving
And
eric-wieser commentedon Apr 6, 2017
Cause:
UNICODE_setitemis alarmingly different fromSTRING_setitem, and each probably have their own set of bugseric-wieser commentedon Apr 11, 2017
Thanks for the report, @jstenar!