[Numpy-discussion] Unpleasant behavior with poly1d and numpy scalar multiplication

Charles R Harris charlesr.harris@gmail....
Sun Feb 14 01:17:42 CST 2010

On Sun, Feb 14, 2010 at 12:10 AM, Fernando Perez <fperez.net@gmail.com>wrote:

> On Sat, Feb 13, 2010 at 10:32 PM, Charles R Harris
> <charlesr.harris@gmail.com> wrote:
> > Note that ipython calls __repr__ to print the output. __repr__ is
> supposed
> > to provide a string that can be used to recreate the object, a pretty
> > printed version of __repr__ doesn't provide that. Also, an array or list
> of
> IPython calls repr because that's the convention the standard python
> shell uses, and I decided long ago to follow suit.
> > polynomials, having pretty printed entries looks pretty ugly with the
> > newlines and all -- try it with Poly1d. I was also thinking that someone
> > might want to provide a better display at some point, drawing on a
> canvas,
> > for instance. And what happens when the degree gets up over 100, which is
> > quite reasonable with the Cheybshev polynomials?
> sympy has pretty remarkable pretty-printing support, perhaps some of
> that could  be reused.  Just a thought.
> I do agree that 2d printing is tricky, but it doesn't mean it's
> useless.  For long and complicated expressions, getting the layout
> correct is not trivial.
> But even good ole' poly1d's display is actually useful for small
> polynomials, which can aid if one is debugging a more complex code
> with test cases that lead to small polys.  I realize this isn't always
> viable, but it does happen in practice.
> But again, small nits, otherwise happy :)  So if you don't see it as
> useful or don't have the time/interest, no worries.  I don't see it as
> important enough to work on it myself, so I'm not going to complain
> further either :)
> >> out of the box.  I don't like using 'training wheels' classes, people
> >> tend to learn one thing and use it for a long time, so I think objects
> >> should be as fully usable as possible from the get-go.  I suspect I
> >> wouldn't use/teach a PrettyPoly if it existed.
> >>
> >
> > I thought the pretty print in the original was intended as a teaching
> aid,
> > but I didn't think it was a good interface for programming work. That
> said,
> > I could add a pretty print option, or a pretty print function. I would be
> > happy to provide another method that ipython could look for and call for
> > pretty printing if that seems reasonable to you.
> In IPython we're already shipping the 'pretty' extension:
> http://bazaar.launchpad.net/~ipython-dev/ipython/trunk/annotate/head%3A/IPython/external/pretty.py<http://bazaar.launchpad.net/%7Eipython-dev/ipython/trunk/annotate/head%3A/IPython/external/pretty.py>
> So I guess we could just start adding __pretty__ to certain objects
> for such fancy representations.
That's what I was looking for. I see that it works for python >= 2.4 with
some work. Does it work for python 3.1 also?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100214/260506bd/attachment.html 

More information about the NumPy-Discussion mailing list