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
.real doesn't work on object arrays (Trac #1142) #1740
Comments
|
Milestone changed to |
|
Milestone changed to |
|
Don't know if this makes sense or not. The |
|
Silently returning an unchanged array is, to my mind, entirely broken. Either throw an error or do something sensible. |
|
Good point. We should probably raise an error, probably for all non-numeric types. |
|
The current behaviour seems totally correct to me for numeric arrays -- in In [11]: a = np.array(["a", "b"]) In [12]: a.real In [13]: a.imag Perhaps .real and .imag should only be defined if np.issubdtype(self.dtype, On Tue, Feb 18, 2014 at 2:43 PM, Andreas Klöckner
Nathaniel J. Smith |
|
Heh, you are more terse :-) On Tue, Feb 18, 2014 at 2:52 PM, Charles Harris notifications@github.comwrote:
Nathaniel J. Smith |
|
I ran into this problem with To implement them (inefficiently) for object arrays, can't a view can simply call the element's (Related: Python objects in Numpy: compatibility issues with methods and functions) |
|
In version 1.19.2 of numpy .real for objects still doesn't work and arrays in arrays are not interpreted but with two small functions we can easily solve the problem of .real for objects
|
|
Another wrinkle with the array attributes The The |
My current plan for solving this is the following:
Both changes are possible right now without any further modifications to the new DType system. Although, the second will create some code churn, but it should be straight forward.* There could be a more generic approach (e.g. that would allow a Unit DType to add an As for The way this is currently handled for |
Original ticket http://projects.scipy.org/numpy/ticket/1142 on 2009-06-19 by @inducer, assigned to unknown.
numpy could really do a better job here by propagating the .real to the elements of the object array:
Summary by @seberg:
Object arrays could call
.realon all objects, but that would not return a view as typically promised byarr.real. It seems that moving forward here may require a new function that returns a copy?The text was updated successfully, but these errors were encountered: