Author: Matti Picus <[email protected]>
Branch:
Changeset: r64886:c9e36178fe49
Date: 2013-06-14 18:02 +0300
http://bitbucket.org/pypy/pypy/changeset/c9e36178fe49/
Log: merge argsort-segfault which fixes issue 1510
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -52,3 +52,7 @@
.. branch: ctypes-byref
Add the '_obj' attribute on ctypes pointer() and byref() objects
+
+.. branch: argsort-segfault
+Fix a segfault in argsort when sorting by chunks on multidim numpypy arrays
(mikefc)
+
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
@@ -20,7 +20,7 @@
def make_sort_function(space, itemtype, comp_type, count=1):
TP = itemtype.T
step = rffi.sizeof(TP)
-
+
class Repr(object):
def __init__(self, index_stride_size, stride_size, size, values,
indexes, index_start, start):
@@ -71,11 +71,11 @@
def __init__(self, index_stride_size, stride_size, size):
start = 0
dtype = interp_dtype.get_dtype_cache(space).w_longdtype
- self.indexes = dtype.itemtype.malloc(size*dtype.get_size())
- self.values = alloc_raw_storage(size * stride_size,
+ indexes = dtype.itemtype.malloc(size*dtype.get_size())
+ values = alloc_raw_storage(size * stride_size,
track_allocation=False)
- Repr.__init__(self, index_stride_size, stride_size,
- size, self.values, self.indexes, start, start)
+ Repr.__init__(self, dtype.get_size(), stride_size,
+ size, values, indexes, start, start)
def __del__(self):
free_raw_storage(self.indexes, track_allocation=False)
@@ -96,7 +96,7 @@
for i in range(stop-start):
retval.setitem(i, lst.getitem(i+start))
return retval
-
+
if count < 2:
def arg_lt(a, b):
# Does numpy do <= ?
@@ -108,7 +108,7 @@
return True
elif a[0][i] > b[0][i]:
return False
- # Does numpy do True?
+ # Does numpy do True?
return False
ArgSort = make_timsort_class(arg_getitem, arg_setitem, arg_length,
@@ -180,7 +180,7 @@
class SortCache(object):
built = False
-
+
def __init__(self, space):
if self.built:
return
diff --git a/pypy/module/micronumpy/test/test_numarray.py
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -2499,6 +2499,13 @@
b = a.argsort()
assert (b[:3] == [0, 100, 200]).all()
+ def test_argsort_random(self):
+ from numpypy import array
+ from _random import Random
+ rnd = Random(1)
+ a = array([rnd.random() for i in range(512*2)]).reshape(512,2)
+ a.argsort()
+
def test_argsort_axis(self):
from numpypy import array
a = array([[4, 2], [1, 3]])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit