[SciPy-dev] numpy.float64*poly1d = array

Ryan Krauss ryanlists@gmail....
Wed Sep 5 21:52:43 CDT 2007


I filed a ticket for this and I guess it is technically a numpy
problem, but I am curious about it.  One line recreates the problem
for me:

numpy.float64(10.0)*poly1d([1,-1])

returns
array([ 10., -10.])

I went in and added a little debugging print statement to the __mul__
and __rmul__ methods of poly1d, and neither is called when the
numpy.float64 instance is on the left.

poly1d([1,-1])*numpy.float64(10.0)
calls __mul__ and works fine.

10.0*poly1d([1,-1])
calls __rmul__ and works fine.

I got myself in this situation by multiplying a poly1d by a constant
taken from an array, which is a numpy.float64 instance.

This seems to indicate that
numpy.float64(10.0)*poly1d([1,-1])

is handled entirely by the float64 __mul__ method without calling
__rmul__ of poly1d.  Does that seem possible?  I think that is what is
happening because my cheesy
print('in rmul')  statement isn't triggered.

Thanks,

Ryan


More information about the Scipy-dev mailing list