Author: Matti Picus <[email protected]>
Branch: missing-ndarray-attributes
Changeset: r60842:7f5153135ef0
Date: 2013-02-03 22:57 +0200
http://bitbucket.org/pypy/pypy/changeset/7f5153135ef0/
Log: fix test to fail for the right reason, avoid non-native argsort via
astype() rather than copy()
diff --git a/pypy/module/micronumpy/interp_numarray.py
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -420,8 +420,13 @@
# happily ignore the kind
# create a contiguous copy of the array
# we must do that, because we need a working set. otherwise
- # we would modify the array in-place
- contig = self.descr_copy(space)
+ # we would modify the array in-place. Use this to our advantage
+ # by converting nonnative byte order.
+ s = self.get_dtype().name
+ if not self.get_dtype().native:
+ s = s[1:]
+ dtype = interp_dtype.get_dtype_cache(space).dtypes_by_name[s]
+ contig = self.implementation.astype(space, dtype)
return contig.implementation.argsort(space, w_axis)
def descr_astype(self, space, w_dtype):
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
@@ -2373,7 +2373,7 @@
from _numpypy import array, arange
assert array(2.0).argsort() == 0
nnp = self.non_native_prefix
- for dtype in ['int', 'float', 'int8', 'int16', 'float32',
+ for dtype in ['int', 'float', 'int16', 'float32',
nnp + 'i2']:
a = array([6, 4, -1, 3, 8, 3, 256+20, 100, 101], dtype=dtype)
c = a.copy()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit