[pypy-commit] pypy default: support order=K in array ctors (issue1711)

bdkearns noreply at buildbot.pypy.org
Wed Mar 26 19:08:16 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r70298:db6f95b7c608
Date: 2014-03-26 14:05 -0400
http://bitbucket.org/pypy/pypy/changeset/db6f95b7c608/

Log:	support order=K in array ctors (issue1711)

diff --git a/pypy/module/micronumpy/ctors.py b/pypy/module/micronumpy/ctors.py
--- a/pypy/module/micronumpy/ctors.py
+++ b/pypy/module/micronumpy/ctors.py
@@ -48,6 +48,8 @@
         order = 'C'
     else:
         order = space.str_w(w_order)
+        if order == 'K':
+            order = 'C'
         if order != 'C':  # or order != 'F':
             raise oefmt(space.w_ValueError, "Unknown order: %s", order)
 
diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -334,6 +334,15 @@
         b = array(a, dtype=float)
         assert b == 123.0
 
+        a = array([[123, 456]])
+        assert a.flags['C']
+        b = array(a, order='K')
+        assert b.flags['C']
+        assert (b == a).all()
+        b = array(a, order='K', copy=True)
+        assert b.flags['C']
+        assert (b == a).all()
+
     def test_dtype_attribute(self):
         import numpy as np
         a = np.array(40000, dtype='uint16')


More information about the pypy-commit mailing list