Re: [Numpy-discussion] searchsorted bug

2008-02-01 Thread James Philbin
Try out latest SVN. It should have this problem fixed. Thanks for this. I've realized that for my case, using object arrays is probably best. I still think that long term it would be good to allow comparison functions to take different types, so that one could compare say integer arrays with

[Numpy-discussion] searchsorted bug

2008-01-31 Thread James Philbin
Hi, The following gives the wrong answer: In [2]: A = array(['a','aa','b']) In [3]: B = array(['d','e']) In [4]: A.searchsorted(B) Out[4]: array([3, 0]) The answer should be [3,3]. I've come across this while trying to come up with an ismember function which works for strings (setmember1d

Re: [Numpy-discussion] [numpy-discussion] searchsorted bug

2008-01-31 Thread James Philbin
Hi, OK, i'm using: In [6]: numpy.__version__ Out[6]: '1.0.3' Should I try the development version? Which version of numpy would people generally recommend? James ___ Numpy-discussion mailing list Numpy-discussion@scipy.org

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread lorenzo bolla
works fine for me. In [33]: A = numpy.array(['a','aa','b']) In [34]: B = numpy.array(['d','e']) In [35]: A.searchsorted(B) Out[35]: array([3, 3]) In [36]: numpy.__version__ Out[36]: '1.0.5.dev4567' L. On 1/31/08, James Philbin [EMAIL PROTECTED] wrote: Hi, The following gives the

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread James Philbin
Hmmm. Just downloaded and installed 1.0.4 and i'm still getting this error. Are you guys using the bleeding edge version or the official 1.0.4 tarball from the webpage? James ___ Numpy-discussion mailing list Numpy-discussion@scipy.org

[Numpy-discussion] [numpy-discussion] searchsorted bug

2008-01-31 Thread James Philbin
Hi, The following gives the wrong answer: In [2]: A = array(['a','aa','b']) In [3]: B = array(['d','e']) In [4]: A.searchsorted(B) Out[4]: array([3, 0]) The answer should be [3,3]. I've come across this while trying to come up with an ismember function which works for strings (setmember1d

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Nadav Horesh
It works fine also for me (numpy 1.04 gentoo linux on amd64) Nadav On Thu, 2008-01-31 at 15:51 +0100, lorenzo bolla wrote: works fine for me. In [33]: A = numpy.array(['a','aa','b']) In [34]: B = numpy.array(['d','e']) In [35]: A.searchsorted(B) Out[35]: array([3, 3]) In [36]:

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread lorenzo bolla
I use a dev version (1.0.5.dev4567). L. On 1/31/08, James Philbin [EMAIL PROTECTED] wrote: Hmmm. Just downloaded and installed 1.0.4 and i'm still getting this error. Are you guys using the bleeding edge version or the official 1.0.4 tarball from the webpage? James

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread James Philbin
Hi, Just tried with numpy from svn and still get this problem: import numpy numpy.__version__ '1.0.5.dev4763' A = numpy.array(['a','aa','b']) B = numpy.array(['d','e']) A.searchsorted(B) array([3, 0]) I guess this must be a platform-dependent bug. I'm running python version: Python 2.5

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Matthieu Brucher
No problem for me (also a svn version) : Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11) [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2 import numpy A = numpy.array(['a','aa','b']) B = numpy.array(['d','e']) A.searchsorted(B) array([3, 3]) Matthieu 2008/1/31, lorenzo bolla [EMAIL

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Robin
I do get the problem with a recent(ish) svn, on OS X 10.5.1, python 2.5.1 (from python.org): In [76]: A = array(['a','aa','b']) In [77]: B = array(['d','e']) In [78]: A.searchsorted(B) Out[78]: array([3, 0]) In [79]: numpy.__version__ Out[79]: '1.0.5.dev4722'

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Bruce Southey
Hi, With my system running x86_64 SUSE10.0 AMD opteron: Under Python 2.5.1 (Python 2.5.1 -r251:54863) and numpy 1.0.4 (download of released version) I have the same bug. Under Python 2.4.1 (May 25 2007, 18:41:31) and numpy 1.0.3 I have no problem. Perhaps a 32/64 bit problem? Bruce On Jan 31,

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Hans Meine
Am Donnerstag, 31. Januar 2008 15:35:25 schrieb James Philbin: The following gives the wrong answer: In [2]: A = array(['a','aa','b']) In [3]: B = array(['d','e']) In [4]: A.searchsorted(B) Out[4]: array([3, 0]) The answer should be [3,3]. Heh, I got both answers in the same session (not

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Alan G Isaac
Problem also with Windows P3 binaries. fwiw, Alan Isaac Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import numpy numpy.__version__ '1.0.4' A = numpy.array(['a','aa','b']) B =

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread lorenzo bolla
from docstring in multiarraymodule.c /** @brief Use bisection of sorted array to find first entries = keys. * * For each key use bisection to find the first index i s.t. key = arr[i]. * When there is no such index i, set i = len(arr). Return the results in ret. * All arrays are assumed

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread lorenzo bolla
oops. it fails also on an SGI Altix with Suse Linux on it: Linux pico 2.6.16.27-0.9-default #1 SMP Tue Feb 13 09:35:18 UTC 2007 ia64 ia64 ia64 GNU/Linux In [33]: A = numpy.array(['a','aa','b']) In [34]: B = numpy.array(['d','e']) In [35]:

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Christopher Barker
lorenzo bolla wrote: * All arrays are assumed contiguous on entry and both arr and key must be of- * the same comparable type. - A and B are not of the same type ('|S2' is not '|S1'). This should be mentioned somewhere more accessible. It should also raise an exception --

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread James Philbin
Hi, In particular: * All arrays are assumed contiguous on entry and both arr and key must be of- * the same comparable type. - In which case, this seems to be an overly strict implementation of searchsorted. Surely all that should be required is that the comparison function can

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread James Philbin
True. The problem is knowing when that is the case. The subroutine in question is at the bottom of the heap and don't know nothin'. IIRC, it just sits there and does the comparison by calling through a pointer with char* arguments. What does the comparison function actually look like for the

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Charles R Harris
On Jan 31, 2008 10:49 AM, James Philbin [EMAIL PROTECTED] wrote: Well, i've digged around in the source code and here is a patch which makes it work for the case I wanted: --- multiarraymodule.c.old 2008-01-31 17:42:32.0 + +++ multiarraymodule.c 2008-01-31

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Charles R Harris
On Jan 31, 2008 10:55 AM, James Philbin [EMAIL PROTECTED] wrote: True. The problem is knowing when that is the case. The subroutine in question is at the bottom of the heap and don't know nothin'. IIRC, it just sits there and does the comparison by calling through a pointer with char*

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Travis E. Oliphant
James Philbin wrote: I can't fathom where the comparison functions exist in the code. It seems that the comparison signature is of the form (void*, void*, PyArrayObject*), so it doesn't seem possible at the moment to specify a compare function which can reason about the underlying types of the

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread James Philbin
I can't fathom where the comparison functions exist in the code. It seems that the comparison signature is of the form (void*, void*, PyArrayObject*), so it doesn't seem possible at the moment to specify a compare function which can reason about the underlying types of the two void*'s. However, I

Re: [Numpy-discussion] searchsorted bug

2008-01-31 Thread Travis E. Oliphant
James Philbin wrote: I can't fathom where the comparison functions exist in the code. It seems that the comparison signature is of the form (void*, void*, PyArrayObject*), so it doesn't seem possible at the moment to specify a compare function which can reason about the underlying types of the