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
The main reason why I believe this behavior is broken is because when one converts an integer array to strings, it's not sorted anymore.
I believe that the least surprising result would be an exception, especially because this is what happens if the array contains floats and not integers.
P.S. I initially asked about this on StackOverflow, and @jaimefrio suggested creating a bug report in the comments.
The text was updated successfully, but these errors were encountered:
I think fixing this boils down to whether it is a searchsorted bug, and we need to put a special check there, or it really is a can_cast bug, and we should disallow safe casting of ints to strings, as we already do for floats.
+1 to making int->str considered not-safe. Generally "safe" for us means
"should be implicitly coerceable", and python in general does not allow
implicit coercion of int->str, so this seems pretty correct to me.
On Jul 10, 2015 12:33 PM, "Jaime" notifications@github.com wrote:
I think fixing this boils down to whether it is a searchsorted bug, and
we need to put a special check there, or it really is a can_cast bug, and
we should disallow safe casting of ints to strings, as we already do for
floats.
—
Reply to this email directly or view it on GitHub #6061 (comment).
vestuto
added a commit
to vestuto/numpy
that referenced
this issue
Jul 11, 2015
- Fixes issue numpy#6061
- Updated _npy_can_cast_safely_table to define such casts as not safe.
- Updated existing python tests to be in agreement with this change.
- Added new test case to test_regression.py to check safe cast example cited in issue numpy#6061
With
numpy 1.9.2
I see quite counter-intuitive behavior ofsearchsorted
on integer arrays with astr
needle:The main reason why I believe this behavior is broken is because when one converts an integer array to strings, it's not sorted anymore.
I believe that the least surprising result would be an exception, especially because this is what happens if the array contains floats and not integers.
P.S. I initially asked about this on StackOverflow, and @jaimefrio suggested creating a bug report in the comments.
The text was updated successfully, but these errors were encountered: