summaryrefslogtreecommitdiff
path: root/scipy/base/src
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2005-12-05 21:56:27 +0000
committerTravis Oliphant <oliphant@enthought.com>2005-12-05 21:56:27 +0000
commit73eff17e359d08053183fc0aa4280261ca580dbd (patch)
tree71406dab94d9edd803cef57eaad8c805d4818db1 /scipy/base/src
parent9db8e4f9cb95484af086951c0e22d7d6947b744b (diff)
downloadnumpy-73eff17e359d08053183fc0aa4280261ca580dbd.tar.gz
Fixed up tuple as data descriptor and added datadescr for descriptor constructor
Diffstat (limited to 'scipy/base/src')
-rw-r--r--scipy/base/src/arrayobject.c6
-rw-r--r--scipy/base/src/multiarraymodule.c8
-rw-r--r--scipy/base/src/ufuncobject.c6
3 files changed, 12 insertions, 8 deletions
diff --git a/scipy/base/src/arrayobject.c b/scipy/base/src/arrayobject.c
index 1628c7da0..b9a5bbc08 100644
--- a/scipy/base/src/arrayobject.c
+++ b/scipy/base/src/arrayobject.c
@@ -3290,10 +3290,10 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd,
PyObject *ret;
intp newdims[2*MAX_DIMS];
intp *newstrides=NULL;
- memcpy(newdims, dims, nd);
+ memcpy(newdims, dims, nd*sizeof(intp));
if (strides) {
newstrides = newdims + MAX_DIMS;
- memcpy(newstrides, strides, nd);
+ memcpy(newstrides, strides, nd*sizeof(intp));
}
nd =_update_descr_and_dimensions(&descr, newdims,
newstrides, nd);
@@ -7818,7 +7818,7 @@ arraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
static PyTypeObject PyArrayDescr_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
- "scipy.descr", /* tp_name */
+ "scipy.datadescr", /* tp_name */
sizeof(PyArray_Descr), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
diff --git a/scipy/base/src/multiarraymodule.c b/scipy/base/src/multiarraymodule.c
index 0961c54ff..b08ed80cb 100644
--- a/scipy/base/src/multiarraymodule.c
+++ b/scipy/base/src/multiarraymodule.c
@@ -2702,13 +2702,14 @@ _convert_from_tuple(PyObject *obj)
{
PyArray_Descr *type;
- if (PyTuple_GET_SIZE(obj) != 2) return NULL;
+ if (PyTuple_GET_SIZE(obj) < 2) return NULL;
if (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj,0), &type))
return NULL;
if (type->elsize == 0) { /* interpret next item as a typesize */
int itemsize;
itemsize = PyArray_PyIntAsInt(PyTuple_GET_ITEM(obj,1));
if (error_converting(itemsize)) goto fail;
+ PyArray_DESCR_REPLACE(type);
type->elsize = itemsize;
}
else { /* interpret next item as shape
@@ -2869,15 +2870,18 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
else if (PyTuple_Check(obj)) {
*at = _convert_from_tuple(obj);
if (*at == NULL) goto fail;
+ return PY_SUCCEED;
}
/* or a dictionary */
else if (PyDict_Check(obj)) {
*at = _convert_from_dict(obj);
if (*at == NULL) goto fail;
+ return PY_SUCCEED;
}
else {
*at = _convert_from_obj(obj);
if (*at == NULL) goto fail;
+ return PY_SUCCEED;
}
if (PyErr_Occurred()) goto fail;
@@ -4283,7 +4287,7 @@ DL_EXPORT(void) initmultiarray(void) {
PyDict_SetItemString(d, "broadcast",
(PyObject *)&PyArrayMultiIter_Type);
Py_INCREF(&PyArrayDescr_Type);
- PyDict_SetItemString(d, "descr", (PyObject *)&PyArrayDescr_Type);
+ PyDict_SetItemString(d, "datadescr", (PyObject *)&PyArrayDescr_Type);
/* Doesn't need to be exposed to Python
Py_INCREF(&PyArrayMapIter_Type);
diff --git a/scipy/base/src/ufuncobject.c b/scipy/base/src/ufuncobject.c
index 5c6f7eeab..296d96a03 100644
--- a/scipy/base/src/ufuncobject.c
+++ b/scipy/base/src/ufuncobject.c
@@ -1807,7 +1807,7 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)
/* fprintf(stderr, "ZERO..%d\n", loop->size); */
for(i=0; i<loop->size; i++) {
if (loop->obj) Py_INCREF(*((PyObject **)loop->idptr));
- memcpy(loop->bufptr[1], loop->idptr, loop->outsize);
+ memmove(loop->bufptr[1], loop->idptr, loop->outsize);
loop->bufptr[1] += loop->outsize;
}
break;
@@ -1815,7 +1815,7 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)
/*fprintf(stderr, "ONEDIM..%d\n", loop->size); */
while(loop->index < loop->size) {
if (loop->obj) Py_INCREF(*((PyObject **)loop->it->dataptr));
- memcpy(loop->bufptr[1], loop->it->dataptr,
+ memmove(loop->bufptr[1], loop->it->dataptr,
loop->outsize);
PyArray_ITER_NEXT(loop->it);
loop->bufptr[1] += loop->outsize;
@@ -1828,7 +1828,7 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)
/* Copy first element to output */
if (loop->obj)
Py_INCREF(*((PyObject **)loop->it->dataptr));
- memcpy(loop->bufptr[1], loop->it->dataptr,
+ memmove(loop->bufptr[1], loop->it->dataptr,
loop->outsize);
/* Adjust input pointer */
loop->bufptr[0] = loop->it->dataptr+loop->steps[0];