[NumPy-Tickets] [NumPy] #1898: Casting complex numpy array scalars to Python scalars
NumPy Trac
numpy-tickets@scipy....
Fri Jul 8 10:18:21 CDT 2011
#1898: Casting complex numpy array scalars to Python scalars
------------------------------+---------------------------------------------
Reporter: AndreasKloeckner | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: Other | Version: 1.6.0
Keywords: |
------------------------------+---------------------------------------------
Contrast this:
{{{
>>> x = np.array(17+3j, dtype=np.complex128)
>>> complex(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert complex to float
}}}
with this:
{{{
>>> x = np.array(17, dtype=np.float64)
>>> float(x)
17.0
}}}
There's no obvious reason why one should work, but not the other. (In
other words, numpy implements .__float__() but not .__complex__().)
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1898>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list