[pypy-commit] pypy default: clean up order argument for reshape
bdkearns
noreply at buildbot.pypy.org
Mon Nov 4 02:47:30 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r67820:c649a2a354b0
Date: 2013-11-03 20:46 -0500
http://bitbucket.org/pypy/pypy/changeset/c649a2a354b0/
Log: clean up order argument for reshape
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
@@ -345,17 +345,20 @@
numpypy.reshape : equivalent function
"""
args_w, kw_w = __args__.unpack()
- order = 'C'
+ order = NPY_CORDER
if kw_w:
if "order" in kw_w:
- order = space.str_w(kw_w["order"])
+ order = order_converter(space, kw_w["order"], order)
del kw_w["order"]
if kw_w:
raise OperationError(space.w_TypeError, space.wrap(
"reshape() got unexpected keyword argument(s)"))
- if order != 'C':
+ if order == NPY_KEEPORDER:
+ raise OperationError(space.w_ValueError, space.wrap(
+ "order 'K' is not permitted for reshaping"))
+ if order != NPY_CORDER and order != NPY_ANYORDER:
raise OperationError(space.w_NotImplementedError, space.wrap(
- "order not implemented"))
+ "unsupported value for order"))
if len(args_w) == 1:
w_shape = args_w[0]
else:
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
@@ -715,7 +715,9 @@
a = array([[[[]]]])
assert a.reshape((0,)).shape == (0,)
assert a.reshape((0,), order='C').shape == (0,)
+ assert a.reshape((0,), order='A').shape == (0,)
raises(TypeError, a.reshape, (0,), badarg="C")
+ raises(ValueError, a.reshape, (0,), order="K")
import sys
if '__pypy__' in sys.builtin_module_names:
raises(NotImplementedError, a.reshape, (0,), order='F')
More information about the pypy-commit
mailing list