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_Initialize

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] ,a

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 index

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 ... a.searchsorted(0.16) 2 I

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 converted to

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. ,

[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] 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 they

[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

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

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'): self.edges =

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 my python

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 hasattr(self, 'edges'): self.edges

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. Nice to

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). I too

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Christian
Christopher Barker Chris.Barker at 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

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

2007-02-07 Thread Christian
Christian Meesters meesters at 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
Sven Schreiber svetosch at 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

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

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Charles R Harris
On 2/7/07, Christian [EMAIL PROTECTED] wrote: Sven Schreiber svetosch at 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

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

2007-02-07 Thread Christian
Keith Goodman kwgoodman at 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 -