addition, multiplication of a polynomial and np.{float, int}
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. -- Denis
On Tue, Mar 6, 2012 at 2:03 PM, Denis Laxalde <denis.laxalde@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
Hi, Le 06/03/2012 22:19, Charles R Harris a écrit :
Use polynomial.Polynomial and you won't have this problem. I was not familiar with the "poly1d vs. Polynomial" choice.
Now, I found in the doc some more or less explicit guidelines in: http://docs.scipy.org/doc/numpy/reference/routines.polynomials.html "The polynomial package is newer and more complete than poly1d and the convenience classes are better behaved in the numpy environment." However, poly1d, which is nicely documented doesn't mention the "competitor". Going further in this transition, do you feel it would make sense adding a "See Also" section in poly1d function ? Best, Pierre
On Wed, Mar 7, 2012 at 9:45 AM, Pierre Haessig <pierre.haessig@crans.org>wrote:
Hi, Le 06/03/2012 22:19, Charles R Harris a écrit :
Use polynomial.Polynomial and you won't have this problem. I was not familiar with the "poly1d vs. Polynomial" choice.
Now, I found in the doc some more or less explicit guidelines in: http://docs.scipy.org/doc/numpy/reference/routines.polynomials.html "The polynomial package is newer and more complete than poly1d and the convenience classes are better behaved in the numpy environment."
However, poly1d, which is nicely documented doesn't mention the "competitor". Going further in this transition, do you feel it would make sense adding a "See Also" section in poly1d function ?
That's a good idea, I'll take care of it. Note the caveat about the coefficients going in the opposite direction. Chuck
Hi Charles, Le 07/03/2012 18:00, Charles R Harris a écrit :
That's a good idea, I'll take care of it. Note the caveat about the coefficients going in the opposite direction.
Great ! In the mean time I changed a bit the root polynomials reference to emphasize the new Polynomial class. http://docs.scipy.org/numpy/docs/numpy-docs/reference/routines.polynomials.r... I feel like that the preexisting text was more targeting people with a preexisting knowledge of Poly1d than people looking for Polynomials in NumPy in general. (Poly1d is unfortunately the number 1 Google result for "polynomials numpy"...) Please make sure I didn't write something completely stupid. Also, I tried to include links using :doc: but the editor complains. I hope it will work after a sphinx compilation. There is a build bot, isn't it ? The aim of the first link is that the "user-in-a-hurry" ends up on the best piece of documentation available, namely "Using the Convenience Classes" after a short intro. Does this sounds good ? Best, Pierre
On Wed, Mar 7, 2012 at 11:02 PM, Pierre Haessig <pierre.haessig@crans.org>wrote:
Hi Charles, Le 07/03/2012 18:00, Charles R Harris a écrit :
That's a good idea, I'll take care of it. Note the caveat about the coefficients going in the opposite direction.
Great ! In the mean time I changed a bit the root polynomials reference to emphasize the new Polynomial class.
http://docs.scipy.org/numpy/docs/numpy-docs/reference/routines.polynomials.r...
Thanks Pierre.
I feel like that the preexisting text was more targeting people with a preexisting knowledge of Poly1d than people looking for Polynomials in NumPy in general. (Poly1d is unfortunately the number 1 Google result for "polynomials numpy"...)
Please make sure I didn't write something completely stupid. Also, I tried to include links using :doc: but the editor complains. I hope it will work after a sphinx compilation. There is a build bot, isn't it ? The aim of the first link is that the "user-in-a-hurry" ends up on the best piece of documentation available, namely "Using the Convenience Classes" after a short intro. Does this sounds good ?
The buildbot doesn't check the doc build. I've edited a few of the links. The :doc: link should work I think, but I'll make sure to check when merging your edit into the master branch. The text looks good. Cheers, Ralf
On Fri, Mar 9, 2012 at 3:57 PM, Ralf Gommers <ralf.gommers@googlemail.com>wrote:
On Wed, Mar 7, 2012 at 11:02 PM, Pierre Haessig <pierre.haessig@crans.org>wrote:
Hi Charles, Le 07/03/2012 18:00, Charles R Harris a écrit :
That's a good idea, I'll take care of it. Note the caveat about the coefficients going in the opposite direction.
Great ! In the mean time I changed a bit the root polynomials reference to emphasize the new Polynomial class.
http://docs.scipy.org/numpy/docs/numpy-docs/reference/routines.polynomials.r...
Thanks Pierre.
I feel like that the preexisting text was more targeting people with a preexisting knowledge of Poly1d than people looking for Polynomials in NumPy in general. (Poly1d is unfortunately the number 1 Google result for "polynomials numpy"...)
Please make sure I didn't write something completely stupid. Also, I tried to include links using :doc: but the editor complains. I hope it will work after a sphinx compilation. There is a build bot, isn't it ? The aim of the first link is that the "user-in-a-hurry" ends up on the best piece of documentation available, namely "Using the Convenience Classes" after a short intro. Does this sounds good ?
The buildbot doesn't check the doc build. I've edited a few of the links. The :doc: link should work I think, but I'll make sure to check when merging your edit into the master branch. The text looks good.
Thanks Pierre, that reads nicely. The lack of knowledge about the package is probably my fault, since I neglected to do more than the minimal amount of reference documentation until recently. Undocumented features are ghostly creatures without tangible reality... Chuck
Le 09/03/2012 23:57, Ralf Gommers a écrit :
The buildbot doesn't check the doc build. I've edited a few of the links.
Thanks for checking ! I had not realized that simply using the `numpy.package` notation was enough to get a link to the package. Best, Pierre
participants (4)
-
Charles R Harris -
Denis Laxalde -
Pierre Haessig -
Ralf Gommers