diff options
author | Travis Oliphant <oliphant@enthought.com> | 2008-03-04 20:06:39 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2008-03-04 20:06:39 +0000 |
commit | 91ee5fea809df423e1b60a17ec8109d036a27289 (patch) | |
tree | d9eb7aaead4968df6a94019f1d9477e3e27394fd /numpy/core/src/arrayobject.c | |
parent | 52c2183be0f41507cd93822adf55ba2f46860a92 (diff) | |
download | numpy-91ee5fea809df423e1b60a17ec8109d036a27289.tar.gz |
Add _default_copyswapn for extended data-types. Fix recent format error.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index d6059719c..f429a69aa 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -1530,6 +1530,24 @@ _default_nonzero(void *ip, void *arr) return FALSE; } +static void +_default_copyswapn(void *dst, npy_intp dstride, void *src, + npy_intp sstride, npy_intp n, int swap, void *arr) +{ + npy_intp i; + PyArray_CopySwapFunc *copyswap; + char *dstptr = dst; + char *srcptr = src; + + copyswap = PyArray_DESCR(arr)->f->copyswap; + + for (i=0; i<n; i++) { + copyswap(dstptr, srcptr, swap, arr); + dstptr += dstride; + srcptr += sstride; + } +} + /* Given a string return the type-number for the data-type with that string as the type-object name. @@ -1588,9 +1606,12 @@ PyArray_RegisterDataType(PyArray_Descr *descr) if (f->nonzero == NULL) { f->nonzero = _default_nonzero; } + if (f->copyswapn == NULL) { + f->copyswapn = _default_copyswapn; + } if (f->copyswap == NULL || f->getitem == NULL || - f->copyswapn == NULL || f->setitem == NULL) { - PyErr_SetString(PyExc_ValueError, "a required array function" \ + f->setitem == NULL) { + PyErr_SetString(PyExc_ValueError, "a required array function" \ " is missing."); return -1; } @@ -11004,7 +11025,7 @@ arraydescr_names_set(PyArray_Descr *self, PyObject *val) N = PyTuple_GET_SIZE(self->names); if (!PySequence_Check(val) || PyObject_Size((PyObject *)val) != N) { PyErr_Format(PyExc_ValueError, "must replace all names at once" \ - " with a sequence of length %d", N, N); + " with a sequence of length %d", N); return -1; } /* Make sure all entries are strings */ |