[Numpy-discussion] poly1d left versus right multiplication with np numbers

josef.pktd@gmai... josef.pktd@gmai...
Wed Feb 4 10:44:11 CST 2009

On Wed, Feb 4, 2009 at 11:19 AM, Pierre GM <pgmdevlist@gmail.com> wrote:
> On Feb 4, 2009, at 11:00 AM, josef.pktd@gmail.com wrote:
>> I just had a hard to find bug in my program. poly1d  treats numpy
>> scalars differently than python numbers when left or right
>> multiplication is used.
>> Essentially, if the first term is the numpy scalar, multiplied by a
>> polynomial, then the result is an np.array.
>> If the order is reversed, then the result is an instance of np.poly1d.
>> The return types are also the same for numpy arrays, which is at least
>> understandable, although a warning would be good)
>> When using plain (python) numbers, then both left and right
>> multiplication of the number with the polynomial returns a polynomial.
>> Is this a bug or a feature? I didn't see it mentioned in the docs.
> Looks like yet another example of ticket #826:
> http://scipy.org/scipy/numpy/ticket/826
> This one is getting quite a problem, and I have no idea how to fix
> it...

Thanks, yes it looks exactly like this ticket. At least, once I know
about it, it is not too difficult to work around, but it costs a lot
of debugging time to figure this out.


More information about the Numpy-discussion mailing list