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

2010-02-15 Thread Dave Hirschfeld
Charles R Harris gmail.com> writes: > 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? There may well be be

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

2010-02-14 Thread Fernando Perez
On Sun, Feb 14, 2010 at 2:17 AM, Charles R Harris wrote: > 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? I haven't tried, but a quick scan of the code makes me think it would be pretty easy to port it to 3.1. It's all fai

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

2010-02-14 Thread Fernando Perez
On Sun, Feb 14, 2010 at 2:40 AM, David Goldsmith wrote: > > Curious: how is sympy at deducing recursion relations and/or index > functions?  Reason: my first thought about Chuck's high-degree issue was > that in such cases perhaps PrettyPoly (or __pretty__) could attempt to use > summation notatio

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

2010-02-13 Thread David Goldsmith
On Sat, Feb 13, 2010 at 11:10 PM, Fernando Perez wrote: > On Sat, Feb 13, 2010 at 10:32 PM, Charles R Harris > 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 _

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

2010-02-13 Thread Charles R Harris
On Sun, Feb 14, 2010 at 12:10 AM, Fernando Perez wrote: > On Sat, Feb 13, 2010 at 10:32 PM, Charles R Harris > 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 _

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

2010-02-13 Thread Fernando Perez
On Sat, Feb 13, 2010 at 10:32 PM, Charles R Harris 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 call

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

2010-02-13 Thread Charles R Harris
On Sat, Feb 13, 2010 at 8:32 PM, Charles R Harris wrote: > > > On Sat, Feb 13, 2010 at 8:02 PM, Fernando Perez wrote: > >> On Sat, Feb 13, 2010 at 12:24 PM, Charles R Harris >> wrote: >> >> One minor suggestion: I think it would be useful to have the new >> >> polys have some form of pretty-pri

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

2010-02-13 Thread Charles R Harris
On Sat, Feb 13, 2010 at 8:02 PM, Fernando Perez wrote: > On Sat, Feb 13, 2010 at 12:24 PM, Charles R Harris > wrote: > >> 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

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

2010-02-13 Thread Fernando Perez
On Sat, Feb 13, 2010 at 12:24 PM, Charles R Harris wrote: >> 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 t

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

2010-02-13 Thread Charles R Harris
On Sat, Feb 13, 2010 at 10:24 AM, Charles R Harris < charlesr.har...@gmail.com> wrote: > > > On Sat, Feb 13, 2010 at 10:04 AM, Fernando Perez wrote: > >> On Sat, Feb 13, 2010 at 10:34 AM, Charles R Harris >> wrote: >> > The new polynomials don't have that problem. >> > >> > In [1]: from numpy.pol

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

2010-02-13 Thread Charles R Harris
On Sat, Feb 13, 2010 at 10:04 AM, Fernando Perez wrote: > On Sat, Feb 13, 2010 at 10:34 AM, Charles R Harris > 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 ca

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

2010-02-13 Thread Fernando Perez
On Sat, Feb 13, 2010 at 10:34 AM, Charles R Harris 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)

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

2010-02-13 Thread Charles R Harris
On Sat, Feb 13, 2010 at 1:11 AM, Fernando Perez wrote: > Mmh, today I got bitten by this again. It took me a while to figure > out what was going on while trying to construct a pedagogical example > manipulating numpy poly1d objects, and after searching for 'poly1d > multiplication float' in my g

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

2010-02-13 Thread Charles R Harris
On Sat, Feb 13, 2010 at 1:41 AM, wrote: > On Sat, Feb 13, 2010 at 3:11 AM, Fernando Perez > wrote: > > Mmh, today I got bitten by this again. It took me a while to figure > > out what was going on while trying to construct a pedagogical example > > manipulating numpy poly1d objects, and after s

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

2010-02-13 Thread josef . pktd
On Sat, Feb 13, 2010 at 3:11 AM, Fernando Perez wrote: > Mmh, today I got bitten by this again.  It took me a while to figure > out what was going on while trying to construct a pedagogical example > manipulating numpy poly1d objects, and after searching for 'poly1d > multiplication float' in my g

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

2010-02-13 Thread Fernando Perez
Mmh, today I got bitten by this again. It took me a while to figure out what was going on while trying to construct a pedagogical example manipulating numpy poly1d objects, and after searching for 'poly1d multiplication float' in my gmail inbox, the *only* post I found was this old one of mine, so

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

2007-07-31 Thread Timothy Hochberg
On 7/31/07, Fernando Perez <[EMAIL PROTECTED]> wrote: > > Hi all, > > consider this little script: > > from numpy import poly1d, float, float32 > p=poly1d([1.,2.]) > three=float(3) > three32=float32(3) > > print 'three*p:',three*p > print 'three32*p:',three32*p > print 'p*three32:',p*three32 > > >

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

2007-07-31 Thread Fernando Perez
Hi all, consider this little script: from numpy import poly1d, float, float32 p=poly1d([1.,2.]) three=float(3) three32=float32(3) print 'three*p:',three*p print 'three32*p:',three32*p print 'p*three32:',p*three32 which produces when run: In [3]: run pol1d.py three*p: 3 x + 6 three32*p: [ 3.