Author: mattip <[email protected]>
Branch: fortran-order
Changeset: r79913:76c343105002
Date: 2015-09-30 23:52 +0300
http://bitbucket.org/pypy/pypy/changeset/76c343105002/
Log: convert 'order' in cpyext from char to int
diff --git a/pypy/module/cpyext/ndarrayobject.py
b/pypy/module/cpyext/ndarrayobject.py
--- a/pypy/module/cpyext/ndarrayobject.py
+++ b/pypy/module/cpyext/ndarrayobject.py
@@ -12,6 +12,7 @@
from pypy.module.micronumpy.descriptor import get_dtype_cache, W_Dtype
from pypy.module.micronumpy.concrete import ConcreteArray
from pypy.module.micronumpy import ufuncs
+import pypy.module.micronumpy.constants as NPY
from rpython.rlib.rawstorage import RAW_STORAGE_PTR
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.baseobjspace import W_Root
@@ -203,12 +204,12 @@
return shape, dtype
def simple_new(space, nd, dims, typenum,
- order='C', owning=False, w_subtype=None):
+ order=NPY.CORDER, owning=False, w_subtype=None):
shape, dtype = get_shape_and_dtype(space, nd, dims, typenum)
return W_NDimArray.from_shape(space, shape, dtype)
def simple_new_from_data(space, nd, dims, typenum, data,
- order='C', owning=False, w_subtype=None):
+ order=NPY.CORDER, owning=False, w_subtype=None):
shape, dtype = get_shape_and_dtype(space, nd, dims, typenum)
storage = rffi.cast(RAW_STORAGE_PTR, data)
return W_NDimArray.from_shape_and_storage(space, shape, storage, dtype,
@@ -238,7 +239,7 @@
raise OperationError(space.w_NotImplementedError,
space.wrap("strides must be NULL"))
- order = 'C' if flags & NPY_C_CONTIGUOUS else 'F'
+ order = NPY.CORDER if flags & NPY_C_CONTIGUOUS else NPY.FORTRANORDER
owning = True if flags & NPY_OWNDATA else False
w_subtype = None
diff --git a/pypy/module/cpyext/test/test_ndarrayobject.py
b/pypy/module/cpyext/test/test_ndarrayobject.py
--- a/pypy/module/cpyext/test/test_ndarrayobject.py
+++ b/pypy/module/cpyext/test/test_ndarrayobject.py
@@ -4,16 +4,17 @@
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.micronumpy.ndarray import W_NDimArray
from pypy.module.micronumpy.descriptor import get_dtype_cache
+import pypy.module.micronumpy.constants as NPY
def scalar(space):
dtype = get_dtype_cache(space).w_float64dtype
return W_NDimArray.new_scalar(space, dtype, space.wrap(10.))
-def array(space, shape, order='C'):
+def array(space, shape, order=NPY.CORDER):
dtype = get_dtype_cache(space).w_float64dtype
return W_NDimArray.from_shape(space, shape, dtype, order=order)
-def iarray(space, shape, order='C'):
+def iarray(space, shape, order=NPY.CORDER):
dtype = get_dtype_cache(space).w_int64dtype
return W_NDimArray.from_shape(space, shape, dtype, order=order)
@@ -32,8 +33,8 @@
def test_FLAGS(self, space, api):
s = array(space, [10])
- c = array(space, [10, 5, 3], order='C')
- f = array(space, [10, 5, 3], order='F')
+ c = array(space, [10, 5, 3], order=NPY.CORDER)
+ f = array(space, [10, 5, 3], order=NPY.FORTRANORDER)
assert api._PyArray_FLAGS(s) & 0x0001
assert api._PyArray_FLAGS(s) & 0x0002
assert api._PyArray_FLAGS(c) & 0x0001
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit