[Numpy-discussion] Assigning complex values to a real array

Darren Dale dsdale24 at gmail.com
Sat Mar 7 10:15:10 EST 2009


On Sat, Mar 7, 2009 at 5:18 AM, Robert Kern <robert.kern at gmail.com> wrote:

> On Sat, Mar 7, 2009 at 04:10, Stéfan van der Walt <stefan at sun.ac.za>
> wrote:
> > 2009/3/7 Robert Kern <robert.kern at gmail.com>:
> >> In [5]: z = zeros(3, int)
> >>
> >> In [6]: z[1] = 1.5
> >>
> >> In [7]: z
> >> Out[7]: array([0, 1, 0])
> >
> > Blind moment, sorry.  So, what is your take -- should this kind of
> > thing pass silently?
>
> Downcasting data is a necessary operation sometimes. We explicitly
> made a choice a long time ago to allow this.
>

In that case, do you know why this raises an exception:

np.int64(10+20j)


Darren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090307/1306d805/attachment.html>


More information about the NumPy-Discussion mailing list