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

2007-02-08 Thread Christian Meesters
Hi Thanks for all your suggestions. Christian ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

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