summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-03-24 22:12:48 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-03-24 22:12:48 +0000
commit28b7d9fb65da6e36eff3158f77b2a023edf7f733 (patch)
tree9075b6f51ca22d2ee6ce2934962e50ee43d47a28
parent76612bfed9caef1f619c12bdd867b4974e93d8f4 (diff)
downloadnumpy-28b7d9fb65da6e36eff3158f77b2a023edf7f733.tar.gz
Changed fortran= keywords to order= keywords
-rw-r--r--numpy/core/code_generators/multiarray_api_order.txt2
-rw-r--r--numpy/core/defchararray.py14
-rw-r--r--numpy/core/defmatrix.py8
-rw-r--r--numpy/core/include/numpy/arrayobject.h10
-rw-r--r--numpy/core/ma.py10
-rw-r--r--numpy/core/memmap.py4
-rw-r--r--numpy/core/numeric.py18
-rw-r--r--numpy/core/oldnumeric.py6
-rw-r--r--numpy/core/src/arraymethods.c28
-rw-r--r--numpy/core/src/arrayobject.c23
-rw-r--r--numpy/core/src/multiarraymodule.c112
11 files changed, 132 insertions, 103 deletions
diff --git a/numpy/core/code_generators/multiarray_api_order.txt b/numpy/core/code_generators/multiarray_api_order.txt
index d2aa995e8..e992e0da3 100644
--- a/numpy/core/code_generators/multiarray_api_order.txt
+++ b/numpy/core/code_generators/multiarray_api_order.txt
@@ -56,7 +56,7 @@ PyArray_BufferConverter
PyArray_AxisConverter
PyArray_BoolConverter
PyArray_ByteorderConverter
-PyArray_ConditionConverter
+PyArray_OrderConverter
PyArray_EquivTypes
PyArray_Zeros
PyArray_Empty
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py
index a220919c5..9ef3cb376 100644
--- a/numpy/core/defchararray.py
+++ b/numpy/core/defchararray.py
@@ -15,7 +15,7 @@ _unicode = unicode
class chararray(ndarray):
def __new__(subtype, shape, itemsize=1, unicode=False, buffer=None,
- offset=0, strides=None, fortran=0):
+ offset=0, strides=None, order=None):
global _globalvar
if unicode:
@@ -26,12 +26,12 @@ class chararray(ndarray):
_globalvar = 1
if buffer is None:
self = ndarray.__new__(subtype, shape, (dtype, itemsize),
- fortran=fortran)
+ order=order)
else:
self = ndarray.__new__(subtype, shape, (dtype, itemsize),
buffer=buffer,
offset=offset, strides=strides,
- fortran=fortran)
+ order=order)
_globalvar = 0
return self
@@ -292,7 +292,7 @@ class chararray(ndarray):
return self._generalmethod('zfill', broadcast(self, width))
-def array(obj, itemsize=None, copy=True, unicode=False, fortran=False):
+def array(obj, itemsize=None, copy=True, unicode=False, order=None):
if isinstance(obj, chararray):
if itemsize is None:
@@ -328,10 +328,10 @@ def array(obj, itemsize=None, copy=True, unicode=False, fortran=False):
buffer=obj)
# default
- val = narray(obj, dtype=dtype, fortran=fortran, subok=1)
+ val = narray(obj, dtype=dtype, order=order, subok=1)
return val.view(chararray)
-def asarray(obj, itemsize=None, unicode=False, fortran=False):
+def asarray(obj, itemsize=None, unicode=False, order=None):
return array(obj, itemsize, copy=False,
- unicode=unicode, fortran=fortran)
+ unicode=unicode, order=order)
diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py
index 388d7b1c9..662f6f62c 100644
--- a/numpy/core/defmatrix.py
+++ b/numpy/core/defmatrix.py
@@ -86,16 +86,16 @@ class matrix(N.ndarray):
elif ndim == 1:
shape = (1,shape[0])
- fortran = False
+ order = False
if (ndim == 2) and arr.flags.fortran:
- fortran = True
+ order = True
- if not (fortran or arr.flags.contiguous):
+ if not (order or arr.flags.contiguous):
arr = arr.copy()
ret = N.ndarray.__new__(subtype, shape, arr.dtype,
buffer=arr,
- fortran=fortran)
+ order=order)
return ret
def __array_finalize__(self, obj):
diff --git a/numpy/core/include/numpy/arrayobject.h b/numpy/core/include/numpy/arrayobject.h
index a301a8a1b..3298feabc 100644
--- a/numpy/core/include/numpy/arrayobject.h
+++ b/numpy/core/include/numpy/arrayobject.h
@@ -237,10 +237,12 @@ typedef enum {
} PyArray_SCALARKIND;
typedef enum {
- PyArray_DONTCARE=-1,
- PyArray_FALSE=0,
- PyArray_TRUE=1,
-} PyArray_CONDITION;
+ PyArray_ANYORDER=-1,
+ PyArray_CORDER=0,
+ PyArray_FORTRANORDER=1,
+} PyArray_ORDER;
+
+
/* Define bit-width array types and typedefs */
diff --git a/numpy/core/ma.py b/numpy/core/ma.py
index d35a96636..d6a4378a0 100644
--- a/numpy/core/ma.py
+++ b/numpy/core/ma.py
@@ -504,7 +504,7 @@ class MaskedArray (object):
any computation.
Construction:
- x = array(data, dtype=None, copy=True, fortran=False,
+ x = array(data, dtype=None, copy=True, order=False,
mask = nomask, fill_value=None)
If copy=False, every effort is made not to copy the data:
@@ -527,9 +527,9 @@ class MaskedArray (object):
The fill_value is not used for computation within this module.
"""
__array_priority__ = 10.1
- def __init__(self, data, dtype=None, copy=True, fortran=False,
+ def __init__(self, data, dtype=None, copy=True, order=False,
mask=nomask, fill_value=None):
- """array(data, dtype=None, copy=True, fortran=False, mask=nomask, fill_value=None)
+ """array(data, dtype=None, copy=True, order=False, mask=nomask, fill_value=None)
If data already a numeric array, its dtype becomes the default value of dtype.
"""
if dtype is None:
@@ -556,12 +556,12 @@ class MaskedArray (object):
need_data_copied = True
else:
need_data_copied = False #because I'll do it now
- c = numeric.array(data, dtype=tc, copy=True, fortran=fortran)
+ c = numeric.array(data, dtype=tc, copy=True, order=order)
tc = c.dtype
if need_data_copied:
if tc == c.dtype:
- self._data = numeric.array(c, dtype=tc, copy=True, fortran=fortran)
+ self._data = numeric.array(c, dtype=tc, copy=True, order=order)
else:
self._data = c.astype(tc)
else:
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py
index 72596ff5e..84d64afbe 100644
--- a/numpy/core/memmap.py
+++ b/numpy/core/memmap.py
@@ -18,7 +18,7 @@ mode_equivalents = {
class memmap(ndarray):
__array_priority__ = -100.0
def __new__(subtype, name, dtype=uint8, mode='r+', offset=0,
- shape=None, fortran=0):
+ shape=None, order=0):
global _globalvar
try:
@@ -70,7 +70,7 @@ class memmap(ndarray):
mm = mmap.mmap(fid.fileno(), bytes, access=acc)
self = ndarray.__new__(subtype, shape, dtype=descr, buffer=mm,
- offset=offset, fortran=fortran)
+ offset=offset, order=order)
self._mmap = mm
self._offset = offset
self._mode = mode
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 630f9ff66..e5ae12c0d 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -108,23 +108,23 @@ can_cast = multiarray.can_cast
lexsort = multiarray.lexsort
-def asarray(a, dtype=None, fortran=None):
+def asarray(a, dtype=None, order=None):
"""returns a as an array. Unlike array(),
no copy is performed if a is already an array. Subclasses are converted
to base class ndarray.
"""
- return array(a, dtype, copy=False, fortran=fortran)
+ return array(a, dtype, copy=False, order=order)
-def asanyarray(a, dtype=None, copy=False, fortran=None):
+def asanyarray(a, dtype=None, copy=False, order=None):
"""will pass subclasses through...
"""
- return array(a, dtype, copy=copy, fortran=fortran, subok=1)
+ return array(a, dtype, copy=copy, order=order, subok=1)
def ascontiguous(a, dtype=None, copy=False):
- return array(a, dtype, copy=copy, fortran=False, ndmin=1)
+ return array(a, dtype, copy=copy, order=False, ndmin=1)
def asfortran(a, dtype=None, copy=False):
- return array(a, dtype, copy=copy, fortran=True, ndmin=1)
+ return array(a, dtype, copy=copy, order=True, ndmin=1)
def isfortran(a):
return a.flags.fnc
@@ -362,14 +362,14 @@ def load(file):
# These are all essentially abbreviations
# These might wind up in a special abbreviations module
-def ones(shape, dtype=int_, fortran=False):
+def ones(shape, dtype=int_, order='C'):
"""ones(shape, dtype=int_) returns an array of the given
dimensions which is initialized to all ones.
"""
- a = empty(shape, dtype, fortran)
+ a = empty(shape, dtype, order)
a.fill(1)
# Above is faster now after addition of fast loops.
- #a = zeros(shape, dtype, fortran)
+ #a = zeros(shape, dtype, order)
#a+=1
return a
diff --git a/numpy/core/oldnumeric.py b/numpy/core/oldnumeric.py
index 378b7d018..26058f0c9 100644
--- a/numpy/core/oldnumeric.py
+++ b/numpy/core/oldnumeric.py
@@ -177,14 +177,14 @@ def take(a, indices, axis=0):
return _wrapit(a, 'take', indices, axis)
return take(indices, axis)
-def reshape(a, newshape, fortran=False):
+def reshape(a, newshape, order=False):
"""Change the shape of a to newshape. Return a new view object.
"""
try:
reshape = a.reshape
except AttributeError:
- return _wrapit(a, 'reshape', newshape, fortran=fortran)
- return reshape(newshape, fortran=fortran)
+ return _wrapit(a, 'reshape', newshape, order=order)
+ return reshape(newshape, order=order)
def choose(a, choices):
try:
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c
index 9c1715678..2d4c82054 100644
--- a/numpy/core/src/arraymethods.c
+++ b/numpy/core/src/arraymethods.c
@@ -68,7 +68,7 @@ array_putmask(PyArrayObject *self, PyObject *args, PyObject *kwds)
}
static char doc_reshape[] = \
- "self.reshape(d1, d2, ..., dn, fortran=False) \n" \
+ "self.reshape(d1, d2, ..., dn, order='C') \n" \
"Return a new array from this one. \n" \
"\n The new array must have the same number of elements as self. " \
"Also\n a copy of the data only occurs if necessary.";
@@ -78,14 +78,14 @@ array_reshape(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
PyArray_Dims newshape;
PyObject *ret;
- PyArray_CONDITION fortran=PyArray_FALSE;
+ PyArray_ORDER order=PyArray_CORDER;
int n;
if (kwds != NULL) {
PyObject *ref;
- ref = PyDict_GetItemString(kwds, "fortran");
- if (ref == NULL || \
- (PyArray_ConditionConverter(ref, &fortran) == PY_FAIL))
+ ref = PyDict_GetItemString(kwds, "order");
+ if (ref == NULL || \
+ (PyArray_OrderConverter(ref, &order) == PY_FAIL))
return NULL;
}
@@ -109,7 +109,7 @@ array_reshape(PyArrayObject *self, PyObject *args, PyObject *kwds)
return PyArray_Ravel(self, 0);
}
- ret = PyArray_Newshape(self, &newshape, fortran);
+ ret = PyArray_Newshape(self, &newshape, order);
PyDimMem_FREE(newshape.ptr);
return ret;
@@ -623,8 +623,8 @@ static char doc_copy[] = "m.copy(|fortran). Return a copy of the array.\n"\
static PyObject *
array_copy(PyArrayObject *self, PyObject *args)
{
- PyArray_CONDITION fortran=PyArray_FALSE;
- if (!PyArg_ParseTuple(args, "|O&", PyArray_ConditionConverter,
+ PyArray_ORDER fortran=PyArray_CORDER;
+ if (!PyArg_ParseTuple(args, "|O&", PyArray_OrderConverter,
&fortran)) return NULL;
return PyArray_NewCopy(self, fortran);
@@ -642,7 +642,7 @@ array_resize(PyArrayObject *self, PyObject *args, PyObject *kwds)
PyObject *ret;
int n;
int refcheck = 1;
- PyArray_CONDITION fortran=PyArray_DONTCARE;
+ PyArray_ORDER fortran=PyArray_ANYORDER;
if (kwds != NULL) {
PyObject *ref;
@@ -655,7 +655,7 @@ array_resize(PyArrayObject *self, PyObject *args, PyObject *kwds)
}
ref = PyDict_GetItemString(kwds, "fortran");
if (ref != NULL ||
- (PyArray_ConditionConverter(ref, &fortran) == PY_FAIL))
+ (PyArray_OrderConverter(ref, &fortran) == PY_FAIL))
return NULL;
}
n = PyTuple_Size(args);
@@ -1443,9 +1443,9 @@ static char doc_flatten[] = "a.flatten([fortran]) return a 1-d array (always cop
static PyObject *
array_flatten(PyArrayObject *self, PyObject *args)
{
- PyArray_CONDITION fortran=PyArray_FALSE;
+ PyArray_ORDER fortran=PyArray_CORDER;
- if (!PyArg_ParseTuple(args, "|O&", PyArray_ConditionConverter,
+ if (!PyArg_ParseTuple(args, "|O&", PyArray_OrderConverter,
&fortran)) return NULL;
return PyArray_Flatten(self, fortran);
@@ -1456,9 +1456,9 @@ static char doc_ravel[] = "a.ravel([fortran]) return a 1-d array (copy only if n
static PyObject *
array_ravel(PyArrayObject *self, PyObject *args)
{
- PyArray_CONDITION fortran=PyArray_FALSE;
+ PyArray_ORDER fortran=PyArray_CORDER;
- if (!PyArg_ParseTuple(args, "|O&", PyArray_ConditionConverter,
+ if (!PyArg_ParseTuple(args, "|O&", PyArray_OrderConverter,
&fortran)) return NULL;
return PyArray_Ravel(self, fortran);
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index bbfb94e27..084eaaf7a 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -801,12 +801,12 @@ PyArray_FromDims(int nd, int *d, int type)
Copy an array.
*/
static PyObject *
-PyArray_NewCopy(PyArrayObject *m1, PyArray_CONDITION fortran)
+PyArray_NewCopy(PyArrayObject *m1, PyArray_ORDER fortran)
{
PyArrayObject *ret;
- if (fortran == PyArray_DONTCARE)
+ if (fortran == PyArray_ANYORDER)
fortran = PyArray_ISFORTRAN(m1);
-
+
Py_INCREF(m1->descr);
ret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type,
m1->descr,
@@ -4103,7 +4103,7 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd,
*/
static PyObject *
PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
- PyArray_CONDITION fortran)
+ PyArray_ORDER fortran)
{
intp oldsize, newsize;
int new_nd=newshape->len, k, n, elsize;
@@ -4120,9 +4120,9 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
return NULL;
}
- if (fortran == PyArray_DONTCARE)
- fortran = PyArray_FALSE;
-
+ if (fortran == PyArray_ANYORDER)
+ fortran = PyArray_CORDER;
+
newsize = PyArray_MultiplyList(new_dimensions, new_nd);
oldsize = PyArray_SIZE(self);
@@ -4289,7 +4289,7 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"shape", "dtype", "buffer", /* XXX ? */
"offset", "strides",
- "fortran", NULL};
+ "order", NULL};
PyArray_Descr *descr=NULL;
int type_num;
int itemsize;
@@ -4297,6 +4297,7 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
PyArray_Dims strides = {NULL, 0};
PyArray_Chunk buffer;
longlong offset=0;
+ PyArray_ORDER order=PyArray_CORDER;
int fortran = 0;
PyArrayObject *ret;
@@ -4309,7 +4310,7 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
array of a specific type and shape.
*/
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&O&LO&i",
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&O&LO&O&",
kwlist, PyArray_IntpConverter,
&dims,
PyArray_DescrConverter,
@@ -4319,9 +4320,11 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
&offset,
&PyArray_IntpConverter,
&strides,
- &fortran))
+ &PyArray_OrderConverter,
+ &order))
goto fail;
+ if (order == PyArray_FORTRANORDER) fortran = 1;
if (descr == NULL)
descr = PyArray_DescrFromType(PyArray_LONG);
diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c
index 101af121d..72f29b5c0 100644
--- a/numpy/core/src/multiarraymodule.c
+++ b/numpy/core/src/multiarraymodule.c
@@ -175,12 +175,12 @@ PyArray_View(PyArrayObject *self, PyArray_Descr *type, PyTypeObject *pytype)
Ravel
*/
static PyObject *
-PyArray_Ravel(PyArrayObject *a, PyArray_CONDITION fortran)
+PyArray_Ravel(PyArrayObject *a, PyArray_ORDER fortran)
{
PyArray_Dims newdim = {NULL,1};
intp val[1] = {-1};
- if (fortran == PyArray_DONTCARE)
+ if (fortran == PyArray_ANYORDER)
fortran = PyArray_ISFORTRAN(a);
newdim.ptr = val;
@@ -189,7 +189,7 @@ PyArray_Ravel(PyArrayObject *a, PyArray_CONDITION fortran)
Py_INCREF(a);
return (PyObject *)a;
}
- return PyArray_Newshape(a, &newdim, PyArray_FALSE);
+ return PyArray_Newshape(a, &newdim, PyArray_CORDER);
}
else
return PyArray_Flatten(a, fortran);
@@ -313,12 +313,12 @@ PyArray_Round(PyArrayObject *a, int decimals)
Flatten
*/
static PyObject *
-PyArray_Flatten(PyArrayObject *a, PyArray_CONDITION fortran)
+PyArray_Flatten(PyArrayObject *a, PyArray_ORDER fortran)
{
PyObject *ret, *new;
intp size;
- if (fortran == PyArray_DONTCARE)
+ if (fortran == PyArray_ANYORDER)
fortran = PyArray_ISFORTRAN(a);
size = PyArray_SIZE(a);
@@ -366,7 +366,7 @@ PyArray_Reshape(PyArrayObject *self, PyObject *shape)
PyArray_Dims newdims;
if (!PyArray_IntpConverter(shape, &newdims)) return NULL;
- ret = PyArray_Newshape(self, &newdims, PyArray_FALSE);
+ ret = PyArray_Newshape(self, &newdims, PyArray_CORDER);
PyDimMem_FREE(newdims.ptr);
return ret;
}
@@ -453,7 +453,7 @@ _fix_unknown_dimension(PyArray_Dims *newshape, intp s_original)
*/
static PyObject *
PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
- PyArray_CONDITION fortran)
+ PyArray_ORDER fortran)
{
intp i;
intp *dimensions = newdims->ptr;
@@ -463,7 +463,7 @@ PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
intp *strides = NULL;
intp newstrides[MAX_DIMS];
- if (fortran == PyArray_DONTCARE)
+ if (fortran == PyArray_ANYORDER)
fortran = PyArray_ISFORTRAN(self);
/* Quick check to make sure anything actually needs to be done */
@@ -487,8 +487,8 @@ PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
if (strides==NULL) {
if ((n == 0) ||
- (PyArray_ISCONTIGUOUS(self) && (fortran != PyArray_TRUE)) ||
- (PyArray_ISFORTRAN(self) && (fortran != PyArray_FALSE))) {
+ (PyArray_ISCONTIGUOUS(self) && (fortran != PyArray_FORTRANORDER)) ||
+ (PyArray_ISFORTRAN(self) && (fortran != PyArray_CORDER))) {
incref = TRUE;
}
else {
@@ -507,7 +507,7 @@ PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
/* replace any 0-valued strides with
appropriate value to preserve contiguousness
*/
- if (fortran == PyArray_TRUE) {
+ if (fortran == PyArray_FORTRANORDER) {
if (strides[0] == 0)
strides[0] = self->descr->elsize;
for (i=1; i<n; i++) {
@@ -3306,24 +3306,40 @@ PyArray_BoolConverter(PyObject *object, Bool *val)
}
/*MULTIARRAY_API
- Convert an object to true / false
+ Convert an object to FORTRAN / C / ANY
*/
static int
-PyArray_ConditionConverter(PyObject *object, PyArray_CONDITION *val)
-{
-
- if (object == Py_None)
- *val = PyArray_DONTCARE;
- else if (PyObject_IsTrue(object))
- *val=PyArray_TRUE;
- else *val=PyArray_FALSE;
- if (PyErr_Occurred())
- return PY_FAIL;
- return PY_SUCCEED;
+PyArray_OrderConverter(PyObject *object, PyArray_ORDER *val)
+{
+ char *str;
+ if (object == Py_None) {
+ *val = PyArray_ANYORDER;
+ }
+ else if (!PyString_Check(object) || PyString_GET_SIZE(object) < 1) {
+ if (PyObject_IsTrue(object))
+ *val = PyArray_FORTRANORDER;
+ else
+ *val = PyArray_CORDER;
+ if (PyErr_Occurred())
+ return PY_FAIL;
+ return PY_SUCCEED;
+ }
+ else {
+ str = PyString_AS_STRING(object);
+ if (str[0] == 'C' || str[0] == 'c') {
+ *val = PyArray_CORDER;
+ }
+ if (str[0] == 'F' || str[0] == 'f') {
+ *val = PyArray_FORTRANORDER;
+ }
+ if (str[0] == 'A' || str[0] == 'a') {
+ *val = PyArray_ANYORDER;
+ }
+ }
+ return PY_SUCCEED;
}
-
/*MULTIARRAY_API
Typestr converter
*/
@@ -4433,24 +4449,24 @@ static char doc_fromobject[] = "array(object, dtype=None, copy=1, "\
"then a C-style contiguous array will be returned. If fotran is True\n"\
"then a Fortran-style contiguous array will be returned.";
-#define STRIDING_OK(op, fortran) ((fortran) == PyArray_DONTCARE || \
- ((fortran) == PyArray_FALSE && \
- PyArray_ISCONTIGUOUS(op)) || \
- ((fortran) == PyArray_TRUE && \
- PyArray_ISFORTRAN(op)))
+#define STRIDING_OK(op, order) ((order) == PyArray_ANYORDER || \
+ ((order) == PyArray_CORDER && \
+ PyArray_ISCONTIGUOUS(op)) || \
+ ((order) == PyArray_FORTRANORDER && \
+ PyArray_ISFORTRAN(op)))
static PyObject *
_array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)
{
PyObject *op, *ret=NULL;
- static char *kwd[]= {"object", "dtype", "copy", "fortran", "subok",
+ static char *kwd[]= {"object", "dtype", "copy", "order", "subok",
"ndmin", NULL};
Bool subok=FALSE;
Bool copy=TRUE;
int ndmin=0, nd;
PyArray_Descr *type=NULL;
PyArray_Descr *oldtype=NULL;
- PyArray_CONDITION fortran=PyArray_DONTCARE;
+ PyArray_ORDER order=PyArray_ANYORDER;
int flags=0;
if (PyTuple_GET_SIZE(args) > 2) {
@@ -4463,7 +4479,7 @@ _array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)
PyArray_DescrConverter2,
&type,
PyArray_BoolConverter, &copy,
- PyArray_ConditionConverter, &fortran,
+ PyArray_OrderConverter, &order,
PyArray_BoolConverter, &subok,
&ndmin))
return NULL;
@@ -4471,28 +4487,28 @@ _array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)
/* fast exit if simple call */
if (PyArray_CheckExact(op)) {
if (type==NULL) {
- if (!copy && STRIDING_OK(op, fortran)) {
+ if (!copy && STRIDING_OK(op, order)) {
Py_INCREF(op);
ret = op;
goto finish;
}
else {
ret = PyArray_NewCopy((PyArrayObject*)op,
- fortran);
+ order);
goto finish;
}
}
/* One more chance */
oldtype = PyArray_DESCR(op);
if (PyArray_EquivTypes(oldtype, type)) {
- if (!copy && STRIDING_OK(op, fortran)) {
+ if (!copy && STRIDING_OK(op, order)) {
Py_INCREF(op);
ret = op;
goto finish;
}
else {
ret = PyArray_NewCopy((PyArrayObject*)op,
- fortran);
+ order);
if (oldtype == type) return ret;
Py_INCREF(oldtype);
Py_DECREF(PyArray_DESCR(ret));
@@ -4505,10 +4521,11 @@ _array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)
if (copy) {
flags = ENSURECOPY;
}
- if (fortran == PyArray_FALSE) {
+ if (order == PyArray_CORDER) {
flags |= CONTIGUOUS;
}
- else if ((fortran == PyArray_TRUE) ||
+ else if ((order == PyArray_FORTRANORDER) ||
+ /* order == PyArray_ANYORDER && */
(PyArray_Check(op) && PyArray_ISFORTRAN(op))) {
flags |= FORTRAN;
}
@@ -4551,16 +4568,17 @@ PyArray_Empty(int nd, intp *dims, PyArray_Descr *type, int fortran)
}
-static char doc_empty[] = "empty((d1,...,dn),dtype=int,fortran=0) will return a new array\n of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros.";
+static char doc_empty[] = "empty((d1,...,dn),dtype=int,order='C') will return a new array\n of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros.";
static PyObject *
array_empty(PyObject *ignored, PyObject *args, PyObject *kwds)
{
- static char *kwlist[] = {"shape","dtype","fortran",NULL};
+ static char *kwlist[] = {"shape","dtype","order",NULL};
PyArray_Descr *typecode=NULL;
PyArray_Dims shape = {NULL, 0};
- Bool fortran = FALSE;
+ PyArray_ORDER order = PyArray_CORDER;
+ Bool fortran;
PyObject *ret=NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&O&",
@@ -4568,9 +4586,12 @@ array_empty(PyObject *ignored, PyObject *args, PyObject *kwds)
&shape,
PyArray_DescrConverter,
&typecode,
- PyArray_BoolConverter, &fortran))
+ PyArray_OrderConverter, &order))
goto fail;
+ if (order == PyArray_FORTRANORDER) fortran = TRUE;
+ else fortran = FALSE;
+
ret = PyArray_Empty(shape.len, shape.ptr, typecode, fortran);
PyDimMem_FREE(shape.ptr);
return ret;
@@ -4676,7 +4697,7 @@ PyArray_Zeros(int nd, intp *dims, PyArray_Descr *type, int fortran)
}
-static char doc_zeros[] = "zeros((d1,...,dn),dtype=int,fortran=0) will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.";
+static char doc_zeros[] = "zeros((d1,...,dn),dtype=int,order='C') will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.";
static PyObject *
@@ -4685,6 +4706,7 @@ array_zeros(PyObject *ignored, PyObject *args, PyObject *kwds)
static char *kwlist[] = {"shape","dtype","fortran",NULL}; /* XXX ? */
PyArray_Descr *typecode=NULL;
PyArray_Dims shape = {NULL, 0};
+ PyArray_ORDER order = PyArray_CORDER;
Bool fortran = FALSE;
PyObject *ret=NULL;
@@ -4693,10 +4715,12 @@ array_zeros(PyObject *ignored, PyObject *args, PyObject *kwds)
&shape,
PyArray_DescrConverter,
&typecode,
- PyArray_BoolConverter,
+ PyArray_OrderConverter,
&fortran))
goto fail;
+ if (order == PyArray_FORTRANORDER) fortran = TRUE;
+ else fortran = FALSE;
ret = PyArray_Zeros(shape.len, shape.ptr, typecode, (int) fortran);
PyDimMem_FREE(shape.ptr);
return ret;