Hi all, The docstring for vander() seems to contradict what the function does. In particular, the columns in the vander() output seem reversed wrt its docstring. I feel like one of the two needs to be fixed, or is there something I'm not seeing? This here is fresh from the Numpy examples page: 8< docstring  X = vander(x,N=None) The Vandermonde matrix of vector x. The ith column of X is the the ith power of x. N is the maximum power to compute; if N is None it defaults to len(x). 8< Example 
from numpy import * x = array([1,2,3,5]) N=3 vander(x,N) # Vandermonde matrix of the vector x array([[ 1, 1, 1], [ 4, 2, 1], [ 9, 3, 1], [25, 5, 1]]) 8< 
Andreas
On Wed, Mar 26, 2008 at 5:22 PM, Andreas Klöckner <lists@informa.tiker.net> wrote:
Hi all,
The docstring for vander() seems to contradict what the function does. In particular, the columns in the vander() output seem reversed wrt its docstring. I feel like one of the two needs to be fixed, or is there something I'm not seeing?
This here is fresh from the Numpy examples page:
8< docstring  X = vander(x,N=None)
The Vandermonde matrix of vector x. The ith column of X is the the ith power of x. N is the maximum power to compute; if N is None it defaults to len(x).
8< Example 
from numpy import * x = array([1,2,3,5]) N=3 vander(x,N) # Vandermonde matrix of the vector x array([[ 1, 1, 1], [ 4, 2, 1], [ 9, 3, 1], [25, 5, 1]]) 8< 
The docstring is incorrect. The Vandermonde matrix produced is compatible with numpy polynomials that also go from high to low powers. I would have done it the other way round, so index matched power, but that isn't how it is. Chuck
On Mittwoch 26 März 2008, Charles R Harris wrote:
The docstring is incorrect. The Vandermonde matrix produced is compatible with numpy polynomials that also go from high to low powers. I would have done it the other way round, so index matched power, but that isn't how it is.
Patch attached. Andreas
Hi I'm tracked down a bug in our code back to the numpy.ma s2=numpy.array([[10,60],[65,45]]) s3=numpy.ma.masked_greater(s2,50.) s3.mask.dtype.char returns: '?' In the Numeric > numpy.ma (page 35) the "?" is not listed. Is it an omission in numpy.ma ? Or is it a valid char type ? s3.dtype does say it is of type "bool" which I guess should be 'B' or 'b' no ? Thanks, C.
Sorry, I can answer my own question (page 22 of numpy book) booleans are supposed to be "?" my mistake. C. Charles Doutriaux wrote:
Hi I'm tracked down a bug in our code back to the numpy.ma
s2=numpy.array([[10,60],[65,45]]) s3=numpy.ma.masked_greater(s2,50.) s3.mask.dtype.char returns: '?'
In the Numeric > numpy.ma (page 35) the "?" is not listed. Is it an omission in numpy.ma ? Or is it a valid char type ? s3.dtype does say it is of type "bool" which I guess should be 'B' or 'b' no ?
Thanks,
C.
On 09/04/2008, Andreas Klöckner <lists@informa.tiker.net> wrote:
On Mittwoch 26 März 2008, Charles R Harris wrote:
The docstring is incorrect. The Vandermonde matrix produced is compatible with numpy polynomials that also go from high to low powers. I would have done it the other way round, so index matched power, but that isn't how it is.
I've never seen the vector powers that way around in literature. Shouldn't we fix it to correspond to the (vast) majority of publications? I'm also somewhat skeptical about including 2liners like these in the main numpy namespace, but we've been there this week already, so I'll keep quiet :) Regards Stéfan
On Wed, Apr 9, 2008 at 11:07 AM, Stéfan van der Walt <stefan@sun.ac.za> wrote:
On 09/04/2008, Andreas Klöckner <lists@informa.tiker.net> wrote:
On Mittwoch 26 März 2008, Charles R Harris wrote:
The docstring is incorrect. The Vandermonde matrix produced is compatible with numpy polynomials that also go from high to low powers. I would have done it the other way round, so index matched power, but that isn't how it is.
I've never seen the vector powers that way around in literature. Shouldn't we fix it to correspond to the (vast) majority of publications?
It would affect polyfit, where the powers correspond to the numpy polynomial coefficients. That can be fixed, and as far as I can determine that is the only numpy function that uses vander, but it might break some software out there in the wild. Maybe we can put it on the list for 1.1. I'd like to change numpy polynomials also, but that is probably a mod too far. Chuck
On Wed, 9 Apr 2008, Charles R Harris wrote:
It would affect polyfit, where the powers correspond to the numpy polynomial coefficients. That can be fixed, and as far as I can determine that is the only numpy function that uses vander, but it might break some software out there in the wild. Maybe we can put it on the list for 1.1. I'd like to change numpy polynomials also, but that is probably a mod too far.
How about tagging the coefficient order, so everyone can use these the way they prefer. Alan Isaac
Hi Chuck, all, On Mittwoch 09 April 2008, Charles R Harris wrote:
It would affect polyfit, where the powers correspond to the numpy polynomial coefficients. That can be fixed, and as far as I can determine that is the only numpy function that uses vander, but it might break some software out there in the wild. Maybe we can put it on the list for 1.1. I'd like to change numpy polynomials also, but that is probably a mod too far.
IMHO, a) 1.0.5 should ship with the docstring fixed, and nothing else. b) maybe we should deprecate the numpy.*contained polynomial functions and move this stuff to numpy.poly for 1.1, and use this opportunity to fix the ordering in the moved functions. ? Andreas
On Wed, Apr 9, 2008 at 11:07 AM, Stéfan van der Walt <stefan@sun.ac.za> wrote:
On 09/04/2008, Andreas Klöckner <lists@informa.tiker.net> wrote:
On Mittwoch 26 März 2008, Charles R Harris wrote:
The docstring is incorrect. The Vandermonde matrix produced is compatible with numpy polynomials that also go from high to low powers. I would have done it the other way round, so index matched power, but that isn't how it is.
I've never seen the vector powers that way around in literature. Shouldn't we fix it to correspond to the (vast) majority of publications?
Turns out it matches the matlab definition. Maybe we just need another function: vandermonde Chuck
On Thu, Apr 10, 2008 at 10:57 PM, Charles R Harris <charlesr.harris@gmail.com> wrote:
Turns out it matches the matlab definition. Maybe we just need another function: vandermonde
1 It's needless duplication.  Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."  Umberto Eco
On Freitag 11 April 2008, Robert Kern wrote:
On Thu, Apr 10, 2008 at 10:57 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
Turns out it matches the matlab definition. Maybe we just need another function: vandermonde
1 It's needless duplication.
Agree. Let's just live with Matlab's definition. Andreas
On 11/04/2008, Andreas Klöckner <lists@informa.tiker.net> wrote:
On Freitag 11 April 2008, Robert Kern wrote:
On Thu, Apr 10, 2008 at 10:57 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
Turns out it matches the matlab definition. Maybe we just need another function: vandermonde
1 It's needless duplication.
Agree. Let's just live with Matlab's definition.
I thought that's why I wasn't working on Octave any more! :) Have a good weekend, Stéfan
participants (6)

Alan Isaac

Andreas Klöckner

Charles Doutriaux

Charles R Harris

Robert Kern

Stéfan van der Walt