On Wed, Feb 1, 2012 at 12:26 PM, Andreas Kloeckner
<[email protected]>wrote:

> Hi all,
>
> here's something I don't understand. Consider the following code snippet:
>
> ---------------------------------------------------
> class A(object):
>    def __radd__(self, other):
>        print(type(other))
>
> import numpy as np
> np.complex64(1j) + A()
> ---------------------------------------------------
>
> In my world, this should print <type 'numpy.complex64'>.
> It does print <type 'complex'>.
>
> Who is casting my sized complex to a built-in complex, and why?
>
> It can be Python's type coercion, because the behavior is the same in
> Python 3.2. (And the docs say Python 3 doesn't support coercion.)
>
>
It gets called once for every scalar in the array, or in your case, just
the scalar, and the scalars are converted to python types for the call. At
least, that is what it looks like.

Chuck
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to