[pypy-commit] pypy default: fix segfault on argsort of empty array
bdkearns
noreply at buildbot.pypy.org
Fri Dec 20 20:19:16 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r68510:5b62fe371a3d
Date: 2013-12-20 14:15 -0500
http://bitbucket.org/pypy/pypy/changeset/5b62fe371a3d/
Log: fix segfault on argsort of empty array
diff --git a/pypy/module/micronumpy/arrayimpl/sort.py b/pypy/module/micronumpy/arrayimpl/sort.py
--- a/pypy/module/micronumpy/arrayimpl/sort.py
+++ b/pypy/module/micronumpy/arrayimpl/sort.py
@@ -123,7 +123,8 @@
if w_axis is space.w_None:
# note that it's fine ot pass None here as we're not going
# to pass the result around (None is the link to base in slices)
- arr = arr.reshape(space, None, [arr.get_size()])
+ if arr.get_size() > 0:
+ arr = arr.reshape(space, None, [arr.get_size()])
axis = 0
elif w_axis is None:
axis = -1
diff --git a/pypy/module/micronumpy/test/test_sorting.py b/pypy/module/micronumpy/test/test_sorting.py
--- a/pypy/module/micronumpy/test/test_sorting.py
+++ b/pypy/module/micronumpy/test/test_sorting.py
@@ -45,6 +45,9 @@
def test_argsort_axis(self):
from numpypy import array
+ a = array([])
+ for axis in [None, -1, 0]:
+ assert a.argsort(axis=axis).shape == (0,)
a = array([[4, 2], [1, 3]])
assert (a.argsort(axis=None) == [2, 1, 3, 0]).all()
assert (a.argsort(axis=-1) == [[1, 0], [0, 1]]).all()
More information about the pypy-commit
mailing list