Re: [Numpy-discussion] NaN, min, and max

2007-02-07 Thread Christian
Keith Goodman gmail.com> writes: > matrix([[ 0.94425407, 0.02216611, 0.999475 ], > [ 0.40444129, nan, 0.23264341], > [ 0.24202372, 0.05344269, 0.37967564]]) > >> x.max() > 0.379675636032 < Wrong (for me) > >> x[1,1] = 0 > >> x.max() > 0.999474999444 <- Bea

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Charles R Harris
On 2/7/07, Christian <[EMAIL PROTECTED]> wrote: Sven Schreiber gmx.net> writes: > So I think what's needed is: > > b = array(yourlist) > b.reshape(b.shape[0], -1) Row vectors are easy to get. In [1]: asmatrix([1,2,3,4]) Out[1]: matrix([[1, 2, 3, 4]]) And nested lists work, but you will be

Re: [Numpy-discussion] Comparing x and x.view

2007-02-07 Thread Robert Kern
Pierre GM wrote: > On Wednesday 07 February 2007 22:38:30 Robert Kern wrote: >> Pierre GM wrote: >>> All, >>> >>> I want to compare whether two arrays point to the same data. >>> I've been using 'is' so far, but I'm wondering whether it's the right >>> approach. >> It isn't. Your analysis is correc

Re: [Numpy-discussion] Comparing x and x.view

2007-02-07 Thread Travis Oliphant
Pierre GM wrote: > On Wednesday 07 February 2007 22:38:30 Robert Kern wrote: > >> Pierre GM wrote: >> >>> All, >>> >>> I want to compare whether two arrays point to the same data. >>> I've been using 'is' so far, but I'm wondering whether it's the right >>> approach. >>> >> It isn't.

Re: [Numpy-discussion] Comparing x and x.view

2007-02-07 Thread Pierre GM
On Wednesday 07 February 2007 22:38:30 Robert Kern wrote: > Pierre GM wrote: > > All, > > > > I want to compare whether two arrays point to the same data. > > I've been using 'is' so far, but I'm wondering whether it's the right > > approach. > > It isn't. Your analysis is correct. So, there's no

Re: [Numpy-discussion] Comparing x and x.view

2007-02-07 Thread Robert Kern
Pierre GM wrote: > All, > > I want to compare whether two arrays point to the same data. > I've been using 'is' so far, but I'm wondering whether it's the right > approach. It isn't. Your analysis is correct. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless

[Numpy-discussion] Comparing x and x.view

2007-02-07 Thread Pierre GM
All, I want to compare whether two arrays point to the same data. I've been using 'is' so far, but I'm wondering whether it's the right approach. If x is a plain ndarray, `x is x`, and `x is not x.view()`. I understand the second one (I think so...), `x` and `x.view `are two different Python

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Christian
Sven Schreiber gmx.net> writes: > So I think what's needed is: > > b = array(yourlist) > b.reshape(b.shape[0], -1) Yes! That is it. Thanks, Christian ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listi

Re: [Numpy-discussion] getting indices for array positions

2007-02-07 Thread Christian
Christian Meesters uni-mainz.de> writes: > Since searchsorted returns the index of the first item in a that is >= or > > the key, it can't make the distinction between 0.1 and 0.2 as I would like to Then how about a.searchsorted(val+0.5) Christian _

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Christian
Christopher Barker noaa.gov> writes: > I'm not sure I understand the specification of the problem. I would > think that the definition of a column vector is that it's shape is: > > (-1,1) I was not aware of that possibility althoug I own the book I - shame on me. Thank you (and all others) for

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-07 Thread Travis Oliphant
Sturla Molden wrote: >>Good point. I guess I thought the OP had tried that already. It turns >>out it works fine, too. >> >>The __array_finalize__ is useful if you want the attribute to be carried >>around when arrays are created automatically internally (after math >>operations for example). >>

Re: [Numpy-discussion] SciPy '07 ???

2007-02-07 Thread Christopher Barker
Robert Kern wrote: >> Does anyone know if there will be a SciPy '07 conference, and if so, when? > > Yes, there will be one. We are currently speaking with the venue (Caltech in > Pasadena, CA) to set the dates. Expect the conference to be either late August > or perhaps earlyish in September. Ni

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-07 Thread Sturla Molden
> Good point. I guess I thought the OP had tried that already. It turns > out it works fine, too. > > The __array_finalize__ is useful if you want the attribute to be carried > around when arrays are created automatically internally (after math > operations for example). I too may be missing so

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-07 Thread Travis Oliphant
Reggie Dugard wrote: >On Wed, 2007-02-07 at 14:36 -0700, Travis Oliphant wrote: > > >>Sturla Molden wrote: >> >> >> def __new__(cls,...) ... (H, edges) = numpy.histogramdd(..) cls.__defaultedges = edges def __array_finalize__(self, obj): if not hasa

Re: [Numpy-discussion] Bug in numpy user-define types mechanism causes segfault on multiple calls to a ufunc

2007-02-07 Thread Tom Denniston
Many thanks, Travis. I'll test the new version tonight. --Tom On 2/7/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Tom Denniston wrote: > > >I am trying to register a custom type to numpy. When I do so it works > >and the ufuncs work but then when I invoke any ufunc twice the second > >time

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-07 Thread Reggie Dugard
On Wed, 2007-02-07 at 14:36 -0700, Travis Oliphant wrote: > Sturla Molden wrote: > > >>def __new__(cls,...) > >> ... > >>(H, edges) = numpy.histogramdd(..) > >>cls.__defaultedges = edges > >> > >>def __array_finalize__(self, obj): > >>if not hasattr(self, 'edges'): > >>sel

Re: [Numpy-discussion] Bug in numpy user-define types mechanism causes segfault on multiple calls to a ufunc

2007-02-07 Thread Travis Oliphant
Tom Denniston wrote: >I am trying to register a custom type to numpy. When I do so it works >and the ufuncs work but then when I invoke any ufunc twice the second >time my python interpretter segfaults. I think i know what the >problem is. In the select_types method in ufuncobject.c in >numpy/c

Re: [Numpy-discussion] SciPy '07 ???

2007-02-07 Thread Robert Kern
Christopher Barker wrote: > Hi, > > Does anyone know if there will be a SciPy '07 conference, and if so, when? Yes, there will be one. We are currently speaking with the venue (Caltech in Pasadena, CA) to set the dates. Expect the conference to be either late August or perhaps earlyish in Septemb

[Numpy-discussion] Bug in numpy user-define types mechanism causes segfault on multiple calls to a ufunc

2007-02-07 Thread Tom Denniston
I am trying to register a custom type to numpy. When I do so it works and the ufuncs work but then when I invoke any ufunc twice the second time my python interpretter segfaults. I think i know what the problem is. In the select_types method in ufuncobject.c in numpy/core/src/ numpy gets a refer

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Robert Kern
Keith Goodman wrote: > I'd like to know what the -1 means. It means "fill in with whatever is necessary to make the size correct given the other specified dimensions". > But first I'm trying to figure out > why there are two reshapes? reshape() used to be simply a function, not a method. > Do t

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Keith Goodman
On 2/7/07, Sven Schreiber <[EMAIL PROTECTED]> wrote: > Christopher Barker schrieb: > > Christian wrote: > >> when creating an ndarray from a list, how can I force the result to be > >> 2d *and* a column vector? So in case I pass a nested list, there will be no > >> modification of the shape and whe

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Sven Schreiber
Christopher Barker schrieb: > Christian wrote: >> when creating an ndarray from a list, how can I force the result to be >> 2d *and* a column vector? So in case I pass a nested list, there will be no >> modification of the shape and when I pass a simple list, it will be >> converted to a 2d column

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-07 Thread Travis Oliphant
Sturla Molden wrote: >>def __new__(cls,...) >> ... >>(H, edges) = numpy.histogramdd(..) >>cls.__defaultedges = edges >> >>def __array_finalize__(self, obj): >>if not hasattr(self, 'edges'): >>self.edges = self.__defaultedges >> >> > >So in order to get an instance attr

[Numpy-discussion] numpy.linalg.qr bug on 64-bit platforms

2007-02-07 Thread Fernando Perez
Hi all, I recently got a report of a bug triggered only on 64-bit hardware, and on a machine (in case it's relevant) that runs python 2.5. This is with current numpy SVN which I just rebuilt a moment ago to triple-check: In [3]: a = numpy.array([[1.0,2],[3,4]]) In [4]: numpy.linalg.qr(a) ** On

Re: [Numpy-discussion] bug in numpy.equal?

2007-02-07 Thread Tom Denniston
got it. thanks. On 2/7/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Tom Denniston wrote: > > >The behavior below seems strange to me. The string array is type S3 > >yet it says that comparison with 'abc' is not implemented. The == > >operator seems to work though. Is there a subtlty I am m

[Numpy-discussion] NaN, min, and max

2007-02-07 Thread Keith Goodman
I keep running into this problem: >> import numpy.matlib as M >> x = M.rand(3,3) >> x[1,1] = M.nan >> x matrix([[ 0.94425407, 0.02216611, 0.999475 ], [ 0.40444129, nan, 0.23264341], [ 0.24202372, 0.05344269, 0.37967564]]) >> x.max() 0.379675636032 < Wrong (for

Re: [Numpy-discussion] bug in numpy.equal?

2007-02-07 Thread Travis Oliphant
Tom Denniston wrote: >The behavior below seems strange to me. The string array is type S3 >yet it says that comparison with 'abc' is not implemented. The == >operator seems to work though. Is there a subtlty I am missing or is >it simply a bug? > > > No bug. Ufuncs do not work with variable

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Christopher Barker
Christian wrote: > when creating an ndarray from a list, how can I force the result to be > 2d *and* a column vector? So in case I pass a nested list, there will be no > modification of the shape and when I pass a simple list, it will be > converted to a 2d column vector. I'm not sure I understan

Re: [Numpy-discussion] confused with apply_along_axis()

2007-02-07 Thread Joris De Ridder
On Wednesday 07 February 2007 15:22, Stefan van der Walt wrote: >On Wed, Feb 07, 2007 at 03:11:53PM +0100, Joris De Ridder wrote: >> I expected as output >> array([[ 1., 4.], >>[ 7., 10.]]) > >That is the answer I get with numpy 1.0.2.dev3537 under Python 2.4. Python 2.5 + numpy 1.0.

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Sven Schreiber
Christian schrieb: > Hi, > > when creating an ndarray from a list, how can I force the result to be > 2d *and* a column vector? So in case I pass a nested list, there will be no > modification of the shape and when I pass a simple list, it will be > converted to a 2d column vector. I can only thi

Re: [Numpy-discussion] confused with apply_along_axis()

2007-02-07 Thread Stefan van der Walt
Hi Joris On Wed, Feb 07, 2007 at 03:11:53PM +0100, Joris De Ridder wrote: > I expected as output > array([[ 1., 4.], >[ 7., 10.]]) That is the answer I get with numpy 1.0.2.dev3537 under Python 2.4. Cheers Stéfan ___ Numpy-discussion mailin

[Numpy-discussion] confused with apply_along_axis()

2007-02-07 Thread Joris De Ridder
Hi, I'm confused by the output of apply_along_axis() in the following very simple example: In [93]: a = arange(12.).reshape(2,2,3) In [95]: a Out[95]: array([[[ 0., 1., 2.], [ 3., 4., 5.]], [[ 6., 7., 8.], [ 9., 10., 11.]]]) In [96]: def myfunc(b): ...

Re: [Numpy-discussion] getting indices for array positions

2007-02-07 Thread Stefan van der Walt
On Wed, Feb 07, 2007 at 02:00:52PM +0100, Christian Meesters wrote: > This questions might seem stupid, but I didn't get a clever solution myself, > or found one in the archives, the cookbook, etc. . If I overlooked something, > please give a pointer. > > Well, if I have an 1D array like > [ 0.

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Stefan van der Walt
On Wed, Feb 07, 2007 at 10:35:14AM +, Christian wrote: > Hi, > > when creating an ndarray from a list, how can I force the result to be > 2d *and* a column vector? So in case I pass a nested list, there will be no > modification of the shape and when I pass a simple list, it will be > convert

Re: [Numpy-discussion] getting indices for array positions

2007-02-07 Thread Robert Cimrman
Christian Meesters wrote: >> Try searchsorted. > Thanks, but that doesn't work. Sorry, if my question wasn't clear. > > To illustrate the requirement: > For instance: a > array([ 0. , 0.1, 0.2, 0.3, 0.4]) # should be 1 > ... a.searchsorted(0.11) > 2 # should be 2 > ...

Re: [Numpy-discussion] getting indices for array positions

2007-02-07 Thread Christian Meesters
> Try searchsorted. Thanks, but that doesn't work. Sorry, if my question wasn't clear. To illustrate the requirement: For instance: >>> a array([ 0. , 0.1, 0.2, 0.3, 0.4]) >>> # should be 1 ... >>> a.searchsorted(0.11) 2 >>> # should be 2 ... >>> a.searchsorted(0.16) 2 I could correct for one

Re: [Numpy-discussion] getting indices for array positions

2007-02-07 Thread Robert Cimrman
Christian Meesters wrote: > Hi > > This questions might seem stupid, but I didn't get a clever solution myself, > or found one in the archives, the cookbook, etc. . If I overlooked something, > please give a pointer. > > Well, if I have an 1D array like > [ 0. , 0.1, 0.2, 0.3, 0.4, 0.5] >

[Numpy-discussion] getting indices for array positions

2007-02-07 Thread Christian Meesters
Hi This questions might seem stupid, but I didn't get a clever solution myself, or found one in the archives, the cookbook, etc. . If I overlooked something, please give a pointer. Well, if I have an 1D array like [ 0. , 0.1, 0.2, 0.3, 0.4, 0.5] ,a scalar like 0.122 and want to retrieve th

Re: [Numpy-discussion] importing multiarraymodule.c in Python embedding

2007-02-07 Thread Sebastien Bardeau
Hi, it seems that I have the same trouble, but using Python under Linux: > I have run into an interesting issue with multiarraymodule.c with > regards to embedding Python in a C application on Windows XP. In the > application, the following abbreviated sequence was executed > > > > 1) Py_Init

[Numpy-discussion] force column vector

2007-02-07 Thread Christian
Hi, when creating an ndarray from a list, how can I force the result to be 2d *and* a column vector? So in case I pass a nested list, there will be no modification of the shape and when I pass a simple list, it will be converted to a 2d column vector. I can only think of a solution using 'if' cla