summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scipy/base/numeric.py4
-rw-r--r--scipy/base/src/arrayobject.c6
-rw-r--r--scipy/base/src/multiarraymodule.c8
-rw-r--r--scipy/base/src/ufuncobject.c6
4 files changed, 15 insertions, 9 deletions
diff --git a/scipy/base/numeric.py b/scipy/base/numeric.py
index 9fb40065a..28e351d66 100644
--- a/scipy/base/numeric.py
+++ b/scipy/base/numeric.py
@@ -1,5 +1,5 @@
__all__ = ['newaxis', 'ndarray', 'bigndarray', 'flatiter', 'ufunc',
- 'arange', 'array', 'zeros', 'empty', 'broadcast',
+ 'arange', 'array', 'zeros', 'empty', 'broadcast', 'datadescr',
'fromstring', 'fromfile', 'frombuffer','newbuffer','getbuffer',
'where', 'concatenate', 'fastCopyAndTranspose',
'register_dtype', 'set_numeric_ops', 'can_cast',
@@ -48,6 +48,7 @@ ndarray = multiarray.ndarray
bigndarray = multiarray.bigndarray
flatiter = multiarray.flatiter
broadcast = multiarray.broadcast
+datadescr=multiarray.datadescr
ufunc = type(sin)
arange = multiarray.arange
@@ -67,6 +68,7 @@ set_numeric_ops = multiarray.set_numeric_ops
can_cast = multiarray.can_cast
+
def asarray(a, dtype=None, fortran=False):
"""returns a as an array. Unlike array(),
no copy is performed if a is already an array. Subclasses are converted
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];