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
{{ message }}
Repository navigation
BUG(DEP?): Incorrect string length for mixed string and non-string array coercion #15327
This is because of t he current "retry-with-string" logic. The logic itself is sound, however, the first pass runs out_dtype = np.promote_types(np.int_, np.dtype("S4")) and then uses the result of this as the initial value for the second "retry" pass. When the string is first, this happens as well, but it does not affect the result.
The fix is to simply reset the elsize to 0, or even simpler just set out_dtype to NULL to begin with (I assume that no requested dtype is ever passed into that function currently, this needs a quick check though).
I would like to deprecate the above behaviour entirely forcing users to write dtype="S" or a future dtype=np.StringDType to get the behaviour.
This means making np.promote_types error for the above input. However, since we currently do not have any universal functions, this seems OK. It would also deprecate np.concatenate((["asdf"], [0.5])), but arguable that may be a good thing...
Closing the initial issue is long fixed by my array-coercion rewrite (of course we still need to just remove the string promotion in any case). The second comment example runs into a FutureWarning now, which is probably "correct".
Activity
seberg commentedon May 4, 2020
Another issue about strings:
seberg commentedon Nov 19, 2022
Closing the initial issue is long fixed by my array-coercion rewrite (of course we still need to just remove the string promotion in any case). The second comment example runs into a FutureWarning now, which is probably "correct".