summaryrefslogtreecommitdiff
path: root/numpy/core/src/arraymethods.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-07-18 16:32:12 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-07-18 16:32:12 +0000
commit565f8c335c12a9365d6c9163889b8db1ac44690e (patch)
tree11304d6452207b1666d406ba4441a1a4120ee3d2 /numpy/core/src/arraymethods.c
parentb1015e1386bbe3d0d2868ebf0745332bb8346d97 (diff)
downloadnumpy-565f8c335c12a9365d6c9163889b8db1ac44690e.tar.gz
Added PyArray_ToString to C-API and made default .tostring() method return C-order.
Diffstat (limited to 'numpy/core/src/arraymethods.c')
-rw-r--r--numpy/core/src/arraymethods.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c
index 93a133c40..757df2ef5 100644
--- a/numpy/core/src/arraymethods.c
+++ b/numpy/core/src/arraymethods.c
@@ -415,14 +415,19 @@ array_tolist(PyArrayObject *self, PyObject *args)
return PyArray_ToList(self);
}
-static char doc_tostring[] = "m.tostring() Construct a Python string "\
+static char doc_tostring[] = "m.tostring(order='C') Construct a Python string "\
"containing the raw bytes in the array";
static PyObject *
-array_tostring(PyArrayObject *self, PyObject *args)
+array_tostring(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- if (!PyArg_ParseTuple(args, "")) return NULL;
- return PyArray_ToString(self);
+ NPY_ORDER order=NPY_CORDER;
+ static char *kwlist[] = {"order", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kwlist,
+ PyArray_OrderConverter,
+ &order)) return NULL;
+ return PyArray_ToString(self, order);
}
static char doc_tofile[] = "m.tofile(fid, sep="") write the data to a file.";
@@ -920,7 +925,7 @@ array_reduce(PyArrayObject *self, PyObject *args)
thestr = _getlist_pkl(self);
}
else {
- thestr = PyArray_ToString(self);
+ thestr = PyArray_ToString(self, NPY_ANYORDER);
}
if (thestr == NULL) {
Py_DECREF(ret);
@@ -1647,7 +1652,8 @@ static PyMethodDef array_methods[] = {
{"item", (PyCFunction)array_toscalar, METH_VARARGS, doc_toscalar},
{"tofile", (PyCFunction)array_tofile,
METH_VARARGS | METH_KEYWORDS, doc_tofile},
- {"tostring", (PyCFunction)array_tostring, METH_VARARGS, doc_tostring},
+ {"tostring", (PyCFunction)array_tostring,
+ METH_VARARGS | METH_KEYWORDS, doc_tostring},
{"byteswap", (PyCFunction)array_byteswap, 1, doc_byteswap},
{"astype", (PyCFunction)array_cast, 1, doc_cast},
{"getfield", (PyCFunction)array_getfield,