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

2009-02-04 Thread Pierre GM

On Feb 4, 2009, at 11:00 AM, josef.p...@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... 
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


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

2009-02-04 Thread josef . pktd
On Wed, Feb 4, 2009 at 11:19 AM, Pierre GM pgmdevl...@gmail.com wrote:

 On Feb 4, 2009, at 11:00 AM, josef.p...@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.

Josef
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion