[Numpy-discussion] addition, multiplication of a polynomial and np.{float, int}
Charles R Harris
charlesr.harris at gmail.com
Tue Mar 6 16:19:29 EST 2012
On Tue, Mar 6, 2012 at 2:03 PM, Denis Laxalde <denis.laxalde at mcgill.ca>wrote:
> Hi,
>
> >>> np.__version__
> '1.7.0.dev-7c07089'
> >>> p = np.poly1d([1,1])
> >>> p + 1.0
> poly1d([ 1., 2.])
> >>> p + np.float64(1)
> poly1d([ 1., 2.])
> >>> np.float64(1.0) + p
> array([ 2., 2.])
> >>> np.int64(1) + p
> array([2, 2])
> >>> np.int(1) + p
> poly1d([1, 2])
> >>> np.int64(1)*p
> array([1, 1])
>
> What's happening here? I'd expect operations with polynomials would
> return a polynomial.
>
Use polynomial.Polynomial and you won't have this problem.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120306/847ac70f/attachment.html>
More information about the NumPy-Discussion
mailing list