[Numpy-discussion] Assigning complex value to real array
Andrew P. Mullhaupt
doc at zen-pharaohs.com
Thu Oct 7 01:07:30 EDT 2010
I came across this gem yesterday
> >> from numpy import *
> >> R = ones((2))
> >> R[0] = R[0] * 1j
> >> R
...array([ 0., 1.])
> >> R = ones((2), 'complex')
> >> R[0] = R[0] * 1j
> >> R
array([ 0.+1.j, 1.+0.j])"
and I read that this behavior is actually intended for some reason about
how Python wants relations between types to be such that this mistake is
unavoidable.
So can we have a new abstract floating type which is a complex, but is
implemented so that the numbers where the imaginary part is zero
represent and operate on that imaginary part implicitly? By containing
all these semantics within one type, then presumably we avoid problems
with ideas relationships between types.
Best regards,
Andrew Mullhaupt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20101007/9216f075/attachment.html>
More information about the NumPy-Discussion
mailing list