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
BUG: numpy.r_ interprets first argument as array element when invoked with unicode #8818
Comments
I really don't understand why the api was chosen as There's a danger here that fixing this would break any user who deliberately wanted to concatenate unicode strings into an array. Also while we're getting angry at |
For the beginning adding a warning to the docs would be an appropriate solution I guess as it won't break any legacy code. |
I think this is correct behaviour. The only real issue is that |
It's also worth remembering that all these bugs also apply to |
This was an issue in Python 2. We no longer support Python 2, so closing. |
Consider the following code on Python 2.x:
This gives:
Apparently it considers the
u'0,2'
an array element (instead of a concatenation specifier) and casts all other array elements to the correspondingdtype
. This is quite ambiguous because if the first argument was astr
then it would use it to deduce how arrays should be concatenated:I would expect either the same behavior for
str
andunicode
arguments or raise aTypeError
forunicode
(or at least add a.. warning::
to the docs). Since the documentation just speaks of "strings" (no type mentioned here) this can lead to funny bugs in application code.Note that the same applies to Python 3.x using
b'0,2'
or encoded strings in general for the first argument (instead of unicode).Tested on:
The text was updated successfully, but these errors were encountered: