8000 BUG: Fix concatenation when the output is "S" or "U" by charris · Pull Request #18063 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix concatenation when the output is "S" or "U" #18063

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

Merged
merged 1 commit into from
Dec 23, 2020

Conversation

charris
Copy link
Member
@charris charris commented Dec 23, 2020

Backport of #18052.

Previously, the dtype was used, this now assumes that we want to
cast to a string of (unknown) length. This is a simplified version
of what happens in np.array() or arr.astype() (it does never
inspect the values, e.g. for object casts).

This is more complex as I would like, and with the refactor of
ResultType and similar can be cleaned up a bit more hopefully.

Note that currently, object to "S" or "U" casts simply return
length 64 strings, but with the new version, this will be an error
(although the error message probably needs improvement).
This is a behaviour inherited from other places however.


The issue here is that NumPy 1.20 is just broken if you pass dtype="U" in concatenate. Unfortunately, this is about as "minimal" as I could think of (some things around it should be cleaned up also in the new code paths). Things are simply fairly complicated if you have "flexible dtypes" or DType (type/class) in my way of thinking about it...

There is of course more inanity here, e.g. concatenate uses result_type which uses value-based casting for 0-D objects, but there is not much to do about it right at this instance.

Previously, the dtype was used, this now assumes that we want to
cast to a string of (unknown) length.  This is a simplified version
of what happens in `np.array()` or `arr.astype()` (it does never
inspect the values, e.g. for object casts).

This is more complex as I would like, and with the refactor of
ResultType and similar can be cleaned up a bit more hopefully.

Note that currently, object to "S" or "U" casts simply return
length 64 strings, but with the new version, this will be an error
(although the error message probably needs improvement).
This is a behaviour inherited from other places however.
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Dec 23, 2020
@charris charris added this to the 1.20.0 release milestone Dec 23, 2020
@charris charris merged commit 924bc88 into numpy:maintenance/1.20.x Dec 23, 2020
@charris charris deleted the backport-18052 branch December 23, 2020 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0