-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
numpy.sign behaves oddly when dtype is numpy.object #6229
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
Comments
Looks like |
Right--zero didn't get a zero result, negative results in +1, positive results in -1. The results for numpy.object seem incorrect on all counts. |
I can't reproduce your example. get: |
Ah ok, the incorrect results occur on Python 3 only. |
Hah, it's a stupid bug, the |
There, and it the two other checks below it, right? |
Yes
|
Is this still open - it looks like an easy fix could be done. |
Closed by #6269. |
In [1]: import numpy
In [2]: foo = numpy.array([-.1, 0, .1])
In [3]: numpy.sign(foo)
Out[3]: array([-1., 0., 1.])
In [4]: numpy.sign(foo.astype(numpy.object))
Out[4]: array([1, -1, -1], dtype=object)
The underlying data is still just a float:
In [5]: type(foo.astype(numpy.object)[0])
Out[5]: float
This result when using an array of numpy.object does not seem desirable. Either it should operate correctly on the underlying numbers or if called with invalid data (strings, etc) it should throw an exception. This way I could populate an array with heterogeneous data, say a mix of integers and floats, and still get a valid result.
I tested this on:
Mac OS 10.6.8
Python 3.4.2
numpy 1.9.2
The text was updated successfully, but these errors were encountered: