[Numpy-svn] r3155 - trunk/numpy/core/src
numpy-svn at scipy.org
numpy-svn at scipy.org
Thu Sep 14 14:55:25 EDT 2006
Author: oliphant
Date: 2006-09-14 13:55:14 -0500 (Thu, 14 Sep 2006)
New Revision: 3155
Modified:
trunk/numpy/core/src/arrayobject.c
Log:
Fix a.flat = []
Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c 2006-09-14 09:00:57 UTC (rev 3154)
+++ trunk/numpy/core/src/arrayobject.c 2006-09-14 18:55:14 UTC (rev 3155)
@@ -5305,15 +5305,6 @@
/* It is bad to have unitialized OBJECT pointers */
/* which could also be sub-fields of a VOID array */
if (descr->hasobject) {
- /*
- if (descr != &OBJECT_Descr) {
- PyErr_SetString(PyExc_TypeError,
- "fields with object members " \
- "not yet supported.");
- goto fail;
- }
- */
-
memset(data, 0, sd);
}
}
@@ -5345,7 +5336,7 @@
/* update flags before finalize function */
PyArray_UpdateFlags(self, UPDATE_ALL);
}
- if PyCObject_Check(func) {
+ if PyCObject_Check(func) { /* A C-function is stored here */
PyArray_FinalizeFunc *cfunc;
cfunc = PyCObject_AsVoidPtr(func);
Py_DECREF(func);
@@ -6473,6 +6464,11 @@
selfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);
if (selfit == NULL) goto exit;
+ if (arrit->size == 0 || selfit->size == 0) {
+ PyErr_SetString(PyExc_ValueError, "trying to set with 0-sized array");
+ goto exit;
+ }
+
swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);
copyswap = self->descr->f->copyswap;
if (self->descr->hasobject) {
@@ -6480,8 +6476,9 @@
PyArray_Item_XDECREF(selfit->dataptr, self->descr);
PyArray_Item_INCREF(arrit->dataptr, PyArray_DESCR(arr));
memmove(selfit->dataptr, arrit->dataptr,
- sizeof(PyObject *));
- copyswap(selfit->dataptr, NULL, swap, self);
+ sizeof(PyObject **));
+ if (swap)
+ copyswap(selfit->dataptr, NULL, swap, self);
PyArray_ITER_NEXT(selfit);
PyArray_ITER_NEXT(arrit);
if (arrit->index == arrit->size)
@@ -6493,7 +6490,8 @@
while(selfit->index < selfit->size) {
memmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);
- copyswap(selfit->dataptr, NULL, swap, self);
+ if (swap)
+ copyswap(selfit->dataptr, NULL, swap, self);
PyArray_ITER_NEXT(selfit);
PyArray_ITER_NEXT(arrit);
if (arrit->index == arrit->size)
@@ -9219,6 +9217,11 @@
if (arrval==NULL) return -1;
val_it = (PyArrayIterObject *)PyArray_IterNew(arrval);
if (val_it==NULL) goto finish;
+ if (val_it->size == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "trying to set with zero-sized array");
+ goto finish;
+ }
/* Check for Boolean -- this is first becasue
Bool is a subclass of Int */
@@ -9655,7 +9658,7 @@
/* Sub-space iteration */
if (mit->subspace != NULL) {
PyArray_ITER_NEXT(mit->subspace);
- if (mit->subspace->index == mit->subspace->size) {
+ if (mit->subspace->index >= mit->subspace->size) {
/* reset coord to coordinates of
beginning of the subspace */
memcpy(coord, mit->bscoord,
More information about the Numpy-svn
mailing list