Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r73870:fad9ee2fdd2c Date: 2014-10-09 15:43 -0400 http://bitbucket.org/pypy/pypy/changeset/fad9ee2fdd2c/
Log: fix searchsorted on empty input diff --git a/pypy/module/micronumpy/selection.py b/pypy/module/micronumpy/selection.py --- a/pypy/module/micronumpy/selection.py +++ b/pypy/module/micronumpy/selection.py @@ -370,7 +370,10 @@ size = arr.size imin = 0 imax = size - last = val[0] + try: + last = val[0] + except IndexError: + return for i in xrange(len(val)): key = val[i] if last < key: diff --git a/pypy/module/micronumpy/test/test_selection.py b/pypy/module/micronumpy/test/test_selection.py --- a/pypy/module/micronumpy/test/test_selection.py +++ b/pypy/module/micronumpy/test/test_selection.py @@ -363,6 +363,10 @@ assert ret == 2 assert isinstance(ret, np.generic) + ret = a.searchsorted(np.array([])) + assert isinstance(ret, np.ndarray) + assert ret.shape == (0,) + ret = a.searchsorted(np.array([3])) assert ret == 2 assert isinstance(ret, np.ndarray) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit