On Sat, Feb 13, 2010 at 10:04 AM, Fernando Perez <fperez.net@gmail.com> wrote:
On Sat, Feb 13, 2010 at 10:34 AM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
> The new polynomials don't have that problem.
> In [1]: from numpy.polynomial import Polynomial as Poly
> In [2]: p = Poly([1,2])

Aha, great!  Many thanks, I can tell my students this, and just show
them the caveat of calling float(x) on any scalar they want to use
with the 'old' ones for now.

I remember being excited about your work on the new Polys, but since
I'm teaching with stock 1.3,  I hadn't found them recently and just
forgot about them.  Excellent.

One minor suggestion:  I think it would be useful to have the new
polys have some form of pretty-printing like the old ones.  It is
actually useful when working, to verify what one has at hand, to see
an expanded printout like the old ones do:

I thought about that, but decided it was best left to a derived class, say PrettyPoly ;) Overriding __repr__ and __str__ is an example where inheritance makes sense.
In [26]: p_old = numpy.poly1d([3, 2, 1])

In [27]: p_old
Out[27]: poly1d([3, 2, 1])

In [28]: print(p_old)
3 x + 2 x + 1

Just yesterday I was validating some code against a symbolic
construction with sympy, and it was handy to pretty-print them; I also
think it makes them much easier to grasp for students new to the

In any case, thanks both for the tip and especially the code contribution!