diff options
author | Travis Oliphant <oliphant@enthought.com> | 2005-10-07 18:28:56 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2005-10-07 18:28:56 +0000 |
commit | 3f0cd73d77fafad5a41748b288863ab0b37628d8 (patch) | |
tree | da853fd7c68e3c11578dc3fe6a145e3fcdfc6064 | |
parent | dfdb8689aaaed931bc8d9d42deec96d0c43a6a79 (diff) | |
download | numpy-3f0cd73d77fafad5a41748b288863ab0b37628d8.tar.gz |
Added some simple CAPI documentation.
-rw-r--r-- | COMPATIBILITY | 4 | ||||
-rw-r--r-- | doc/CAPI.txt | 187 | ||||
-rw-r--r-- | doc/README.txt | 15 | ||||
-rw-r--r-- | scipy/base/code_generators/generate_array_api.py | 2 | ||||
-rw-r--r-- | scipy/base/include/scipy/arrayobject.h | 4 | ||||
-rw-r--r-- | scipy/base/src/arraymethods.c | 2 | ||||
-rw-r--r-- | scipy/base/src/arrayobject.c | 54 | ||||
-rw-r--r-- | scipy/base/src/multiarraymodule.c | 38 |
8 files changed, 263 insertions, 43 deletions
diff --git a/COMPATIBILITY b/COMPATIBILITY index 042f6768d..fb5144e76 100644 --- a/COMPATIBILITY +++ b/COMPATIBILITY @@ -46,11 +46,11 @@ use PyArray_XXXLTR where XXX is the name of the type. If you used function pointers directly (why did you do that?), -the arguments have changed. +the arguments have changed. Everything that was an int is now an intp. Also, +arrayobjects should be passed in at the end. a->descr->cast[i](fromdata, fromstep, todata, tostep, n) a->descr->cast[i](fromdata, todata, n, PyArrayObject *in, PyArrayObject *out) anything but single-stepping is not supported by this function use the PyArray_CastXXXX functions. - diff --git a/doc/CAPI.txt b/doc/CAPI.txt new file mode 100644 index 000000000..be6c50d94 --- /dev/null +++ b/doc/CAPI.txt @@ -0,0 +1,187 @@ + +The CAPI of SciPy is (mostly) backward compatible with Numeric. + +There are a few non-standard API Numeric usages that will need to be changed: + + * If you used any of the function pointers in the PyArray_Descr + structure you will have to modify your usage of those. The casting functions + have eliminated the strides argument (use PyArray_CastTo if you need strided casting). + All functions have one or two PyArrayObject * arguments at the end. This allows + the flexible arrays and mis-behaved arrays to be handled. + + * The descr->zero and descr->one constants have been replaced with + function calls, PyArray_Zero, and PyArray_One. + + * You should use PyArray_ITEMSIZE(obj) instead of descr->elsize to get the itemsize of an + object (for flexible arrays descr->elsize is 0). + + +The header files arrayobject.h and ufuncobject.h contain many defines +that you may find useful. The files __ufunc_api.h and +__multiarray_api.h contain the available C-API function calls with their function signatures. + +All of these headers are installed to + +<YOUR_PYTHON_LOCATION>/site-packages/scipy/base/include + + +Getting arrays in C-code +========================= + +All new arrays can be created using PyArray_New. + +This is a very flexible function. + +PyObject * PyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type, + intp *strides, char *data, int itemsize, int flags, + PyObject *obj); + + +subtype : The subtype that should be created (either pass in + &PyArray_Type, &PyBigArray_Type, or obj->ob_type, + where obj is a subtype (or subclass) of PyBigArray_Type). + +nd : The number of dimensions (<MAX_DIMS) +*dims : A pointer to the size in each dimension. Information will be copied from here. +type : An integer specifying the type of the array. +*strides : The strides this array should have. For new arrays created by this routine, this + should be NULL. If you pass in memory for this array to use, then you should pass + in the strides information as well. I +*data : NULL for creating brand-new memory. If you want this array to wrap another memory + area, then pass the pointer here. You are responsible for deleting the memory in that + case, but do not do so until the new array object has been deleted. The best way to + handle that is to get the memory from another Python object, + INCREF that Python object after passing it's data pointer to this routine, and + set the ->base member of the returned array to the Python object. You are + responsible for setting the base object. Failure to do so will create a memory leak. + + If you pass in a data buffer, the flags argument will be the flags of the new array. + If you create a new array, a non-zero flags argument indicates that you want the + array to be in FORTRAN order. + +itemsize : Indicates the itemsize for the new array. This can be 0 if it is a fixed-size array type. + It is only used for flexible array types and must be set in that case. + +flags : Either the flags showing how to interpret the data buffer passed in. Or if a new array + is created, nonzero to indicate a FORTRAN order array. + +obj : If subtypes is &PyArray_Type or &PyBigArray_Type, this argument is ignored. Otherwise, + the __array_finalize__ method of the subtype is called (if present) and passed this + object. This is usually an array of the type to be created (so the __array_finalize__ + method must handle an array argument. But, it can be anything...) + +Note: The returned array object will be unitialized unless the type is PyArray_OBJECT. + + +The PyArray_FromDims and family of functions are still available and are loose wrappers around +this function. + + +Getting an arrayobject from an arbitrary Python object: PyArray_FromAny + +This function replaces PyArray_ContiguousFromObject and friends (those +function calls still remain but they are loose wrappers around the +PyArray_FromAny call). + +static PyObject * +PyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, + int max_depth, int requires) + + +op : The Python object to "convert" to an array object +typecode : A typecode structure filled with the data type and itemsize of the desired data type. + This can be NULL, if the type should be determined from the object. + Unless FORCECAST is present in flags, this call will generate an error + if the data type cannot be safely obtained from the object. +min_depth : The minimum depth of array needed or 0 if doesn't matter +max_depth : The maximum depth of array allowed or 0 if doesn't matter +requires : A flag indicating the "requirements" of the returned array. + + +From the code comments, the requires flag is explained. + +requires can be any of + + CONTIGUOUS, + FORTRAN, (or set typecode->fortran=1) + ALIGNED, + NOTSWAPPED, + WRITEABLE, + ENSURECOPY, + UPDATEIFCOPY, + FORCECAST, + + or'd (|) together + + Any of these flags present means that the returned array should + guarantee that aspect of the array. Otherwise the returned array + won't guarantee it -- it will depend on the object as to whether or + not it has such features. + + Note that ENSURECOPY is enough to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, + and WRITEABLE and therefore it is redundant to include those as well. + + BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE + BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED + CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS + FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS + + By default, if the object is an array and requires is 0, + the array will just be INCREF'd and returned. + + typecode->fortran can be set to request a + fortran-contiguous array (or just | FORTRAN to the requires flags). + Fortran arrays are always behaved (aligned, + notswapped, and writeable) and not (C) CONTIGUOUS. Note that either + FORTRAN in the flag or typecode->fortran = 1 is enough to request + a FORTRAN-style array. + + UPDATEIFCOPY flag sets this flag in the returned array if a copy is + made and the base argument points to the (possibly) misbehaved array. + When the new array is deallocated, the original array held in base + is updated with the contents of the new array. This is useful, + if you don't want to deal with a possibly mis-behaved array, but want + to update it easily using a local contiguous copy. + + FORCECAST will cause a cast to occur regardless of whether or not + it is safe. + + +PyArray_Typecode structure +{ + int type_num; + int itemsize; + int fortran --- used to indicate a fortran array is desired. +} + + +Passing Data Type information to C-code +============================================ + +To get a Typecode structure from Python use the +PyArray_TypecodeConverter function. This will return a typecode +structure filled appropriately based on a wide variety of user inputs. + +See the arraymethods.c and multiarraymodule.c files for many examples of usage. + + +Getting at the structure of the array. + +You should use the #defines provided to access array structure portions: + +PyArray_DATA(obj) +PyArray_ITEMSIZE(obj) +PyArray_NDIM(obj) +PyArray_DIMS(obj) +PyArray_DIM(obj, n) +PyArray_STRIDES(obj) +PyArray_STRIDE(obj,n) + + +see more in arrayobject.h + + +There are more C-API enhancements which you can discover in the code, + or buy the book (http://www.trelgol.com) + + diff --git a/doc/README.txt b/doc/README.txt new file mode 100644 index 000000000..f63508669 --- /dev/null +++ b/doc/README.txt @@ -0,0 +1,15 @@ +Very complete documentation is available from the primary developer of +SciPy Core for a small fee. After a brief period, that documentation +will become freely available. See http://www.trelgol.com for +details. The fee and restriction period is intended to allow people +and to encourage companies to easily contribute to the development of +SciPy. + +This directory will contain all public documentation that becomes available. + +Very good documentation is also available using Python's (and +especially IPython's) own help system. Most of the functions have +docstrings that provide usage assistance. + + + diff --git a/scipy/base/code_generators/generate_array_api.py b/scipy/base/code_generators/generate_array_api.py index 6844f3cf6..10da74ded 100644 --- a/scipy/base/code_generators/generate_array_api.py +++ b/scipy/base/code_generators/generate_array_api.py @@ -200,7 +200,7 @@ objectapi_list = [ (r"""Generic new array creation routine. """, - 'New','PyTypeObject *, int nd, intp *dims, int type, intp *strides, char *data, int itemsize, int fortran, PyArrayObject *arr', 'PyObject *'), + 'New','PyTypeObject *, int nd, intp *dims, int type, intp *strides, char *data, int itemsize, int fortran, PyObject *obj', 'PyObject *'), (r"""Get Priority from object """, diff --git a/scipy/base/include/scipy/arrayobject.h b/scipy/base/include/scipy/arrayobject.h index b0c856ad9..adcaf7360 100644 --- a/scipy/base/include/scipy/arrayobject.h +++ b/scipy/base/include/scipy/arrayobject.h @@ -641,6 +641,8 @@ enum PyArray_TYPECHAR { PyArray_BOOLLTR = '?', typedef Py_intptr_t intp; typedef Py_uintptr_t uintp; +#define INTP_STRFORMAT "%d" + #if SIZEOF_PY_INTPTR_T == SIZEOF_INT #define PyArray_INTP PyArray_INT #define PyArray_UINTP PyArray_UINT @@ -665,6 +667,8 @@ typedef Py_uintptr_t uintp; #define MAX_INTP MAX_LONGLONG #define MIN_INTP MIN_LONGLONG #define MAX_UINTP MAX_ULONGLONG + #undef INTP_STRFORMAT + #define INTP_STRFORMAT "%Ld" #endif #define ERR(str) fprintf(stderr, #str); fflush(stderr); diff --git a/scipy/base/src/arraymethods.c b/scipy/base/src/arraymethods.c index aee19fd37..288d3a6d8 100644 --- a/scipy/base/src/arraymethods.c +++ b/scipy/base/src/arraymethods.c @@ -242,7 +242,7 @@ PyArray_GetField(PyArrayObject *self, PyArray_Typecode *type, ret = PyArray_New(self->ob_type, self->nd, self->dimensions, type->type_num, self->strides, self->data + offset, - type->itemsize, self->flags, self); + type->itemsize, self->flags, (PyObject *)self); if (ret == NULL) return NULL; Py_INCREF(self); ((PyArrayObject *)ret)->base = (PyObject *)self; diff --git a/scipy/base/src/arrayobject.c b/scipy/base/src/arrayobject.c index 41414801a..47d9c5010 100644 --- a/scipy/base/src/arrayobject.c +++ b/scipy/base/src/arrayobject.c @@ -175,8 +175,10 @@ PyArray_GetPriority(PyObject *obj, double default_) PyObject *ret; double priority=PyArray_PRIORITY; - if (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) + if (PyArray_CheckExact(obj)) return priority; + if (PyBigArray_CheckExact(obj)) + return PyArray_BIG_PRIORITY; ret = PyObject_GetAttrString(obj, "__array_priority__"); if (ret != NULL) priority = PyFloat_AsDouble(ret); @@ -437,7 +439,7 @@ contiguous_data(PyArrayObject *src) static PyObject *PyArray_New(PyTypeObject *, int nd, intp *, - int, intp *, char *, int, int, PyArrayObject *); + int, intp *, char *, int, int, PyObject *); /* C-API functions */ @@ -748,7 +750,8 @@ PyArray_FromDimsAndData(int nd, int *d, int type, char *data) type, NULL, data, 0, CARRAY_FLAGS, NULL); #endif - if (type != PyArray_OBJECT) + if (type != PyArray_OBJECT && type != PyArray_OBJECTLTR) + /* already done*/ memset(PyArray_DATA(ret), 0, PyArray_SIZE(ret)); return ret; } @@ -769,7 +772,7 @@ PyArray_FromDims(int nd, int *d, int type) ret = PyArray_New(&PyArray_Type, nd, (intp *)d, type, NULL, NULL, 0, CARRAY_FLAGS, NULL); #endif - if (type != PyArray_OBJECT) + if (type != PyArray_OBJECT && type != PyArray_OBJECTLTR) memset(PyArray_DATA(ret), 0, PyArray_SIZE(ret)); return ret; } @@ -785,7 +788,7 @@ PyArray_Copy(PyArrayObject *m1) m1->dimensions, m1->descr->type_num, NULL, NULL, m1->itemsize, - 0, m1); + 0, (PyObject *)m1); if (PyArray_CopyInto(ret, m1) == -1) return NULL; @@ -921,6 +924,10 @@ PyArray_RegisterDataType(PyTypeObject *type) descr->typeobj = type; userdescrs = realloc(userdescrs, (PyArray_NUMUSERTYPES+1)*sizeof(void *)); + if (userdescrs == NULL) { + PyErr_SetString(PyExc_MemoryError, "RegisterDataType"); + return -1; + } userdescrs[PyArray_NUMUSERTYPES++] = descr; return typenum; } @@ -1221,7 +1228,7 @@ array_item(PyArrayObject *self, int i) self->descr->type_num, self->strides+1, item, self->itemsize, self->flags, - self); + (PyObject *)self); if (r == NULL) return NULL; Py_INCREF(self); r->base = (PyObject *)self; @@ -1550,7 +1557,7 @@ PyArray_GetMap(PyArrayMapIterObject *mit) temp->descr->type_num, NULL, NULL, temp->itemsize, PyArray_ISFORTRAN(temp), - temp); + (PyObject *)temp); if (ret == NULL) return NULL; /* Now just iterate through the new array filling it in @@ -1726,7 +1733,7 @@ array_subscript(PyArrayObject *self, PyObject *op) PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num, strides, self->data+offset, self->itemsize, self->flags, - self)) == NULL) + (PyObject *)self)) == NULL) return NULL; @@ -2571,7 +2578,7 @@ array_slice(PyArrayObject *self, int ilow, int ihigh) r = (PyArrayObject *)\ PyArray_New(self->ob_type, self->nd, self->dimensions, self->descr->type_num, self->strides, data, - self->itemsize, self->flags, self); + self->itemsize, self->flags, (PyObject *)self); self->dimensions[0] = l; r->base = (PyObject *)self; @@ -3130,7 +3137,7 @@ _array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, static PyObject * PyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num, intp *strides, char *data, int itemsize, int flags, - PyArrayObject *obj) + PyObject *obj) { PyArrayObject *self; PyArray_Descr *descr; @@ -3266,7 +3273,7 @@ PyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num, PyObject *res; res = PyObject_CallMethod((PyObject *)self, "__array_finalize__", - "O", (PyObject *)obj); + "O", obj); if (res == NULL) PyErr_Clear(); else Py_DECREF(res); } @@ -3980,7 +3987,7 @@ array_real_get(PyArrayObject *self) self->strides, self->data, 0, - self->flags, self); + self->flags, (PyObject *)self); if (ret == NULL) return NULL; ret->flags &= ~CONTIGUOUS; ret->flags &= ~FORTRAN; @@ -4014,7 +4021,7 @@ array_real_set(PyArrayObject *self, PyObject *val) self->strides, self->data, 0, - self->flags, self); + self->flags, (PyObject *)self); if (ret == NULL) return -1; ret->flags &= ~CONTIGUOUS; ret->flags &= ~FORTRAN; @@ -4050,7 +4057,7 @@ array_imag_get(PyArrayObject *self) self->strides, self->data + itemsize, 0, - self->flags, self); + self->flags, (PyObject *)self); if (ret == NULL) return NULL; ret->flags &= ~CONTIGUOUS; ret->flags &= ~FORTRAN; @@ -4085,7 +4092,7 @@ array_imag_set(PyArrayObject *self, PyObject *val) (self->itemsize >> 1) , self->data, 0, - self->flags, self); + self->flags, (PyObject *)self); if (ret == NULL) { Py_DECREF(new); return -1; @@ -4856,7 +4863,7 @@ PyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) mp->dimensions, at->type_num, NULL, NULL, at->itemsize, - at->fortran, mp); + at->fortran, (PyObject *)mp); if (out == NULL) return NULL; ret = PyArray_CastTo((PyArrayObject *)out, mp); if (ret != -1) return out; @@ -4963,7 +4970,7 @@ array_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) NULL, NULL, itemsize, flags & FORTRAN, - arr); + (PyObject *)arr); if (PyArray_CopyInto(ret, arr) == -1) return NULL; if (flags & UPDATEIFCOPY) { ret->flags |= UPDATEIFCOPY; @@ -5682,7 +5689,7 @@ iter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind) itemsize = self->ao->itemsize; r = PyArray_New(self->ao->ob_type, 1, &count, self->ao->descr->type_num, NULL, NULL, - itemsize, 0, self->ao); + itemsize, 0, (PyObject *)self->ao); if (r==NULL) return NULL; /* Set up loop */ @@ -5729,7 +5736,7 @@ iter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind) r = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions, self->ao->descr->type_num, NULL, NULL, self->ao->itemsize, - 0, self->ao); + 0, (PyObject *)self->ao); if (r==NULL) return NULL; optr = PyArray_DATA(r); @@ -5800,7 +5807,7 @@ iter_subscript(PyArrayIterObject *self, PyObject *ind) r = PyArray_New(self->ao->ob_type, 1, &ii, self->ao->descr->type_num, NULL, NULL, self->ao->itemsize, 0, - self->ao); + (PyObject *)self->ao); return r; } } @@ -5827,7 +5834,7 @@ iter_subscript(PyArrayIterObject *self, PyObject *ind) size = self->ao->itemsize; r = PyArray_New(self->ao->ob_type, 1, &n_steps, self->ao->descr->type_num, NULL, NULL, - size, 0, self->ao); + size, 0, (PyObject *)self->ao); if (r==NULL) goto fail; dptr = PyArray_DATA(r); swap = !PyArray_ISNOTSWAPPED(self->ao); @@ -6122,13 +6129,14 @@ iter_array(PyArrayIterObject *it, PyObject *op) it->ao->descr->type_num, NULL, it->ao->data, it->ao->itemsize, it->ao->flags, - it->ao); + (PyObject *)it->ao); if (r==NULL) return NULL; } else { r = PyArray_New(it->ao->ob_type, 1, &size, it->ao->descr->type_num, - NULL, NULL, it->ao->itemsize, 0, it->ao); + NULL, NULL, it->ao->itemsize, 0, + (PyObject *)it->ao); if (r==NULL) return NULL; if (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) { Py_DECREF(r); diff --git a/scipy/base/src/multiarraymodule.c b/scipy/base/src/multiarraymodule.c index 04b0ff6c6..752ccdd29 100644 --- a/scipy/base/src/multiarraymodule.c +++ b/scipy/base/src/multiarraymodule.c @@ -99,7 +99,7 @@ PyArray_View(PyArrayObject *self, PyArray_Typecode *type) self->strides, self->data, self->itemsize, - self->flags, self); + self->flags, (PyObject *)self); if (new==NULL) return NULL; @@ -163,7 +163,7 @@ PyArray_Flatten(PyArrayObject *a, int fortran) NULL, NULL, a->itemsize, - 0, a); + 0, (PyObject *)a); if (ret== NULL) return NULL; if (fortran) { @@ -275,7 +275,7 @@ PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims) NULL, self->data, self->itemsize, - self->flags, self); + self->flags, (PyObject *)self); if (ret== NULL) goto fail; @@ -322,7 +322,7 @@ PyArray_Squeeze(PyArrayObject *self) ret = PyArray_New(self->ob_type, newnd, dimensions, self->descr->type_num, strides, self->data, self->itemsize, self->flags, - self); + (PyObject *)self); self->flags &= ~OWN_DATA; self->base = (PyObject *)self; Py_INCREF(self); @@ -539,7 +539,7 @@ PyArray_Nonzero(PyArrayObject *self) PyArray_ITER_RESET(it); if (n==1) { ret = PyArray_New(self->ob_type, 1, &count, PyArray_INTP, - NULL, NULL, 0, 0, self); + NULL, NULL, 0, 0, (PyObject *)self); if (ret == NULL) goto fail; dptr[0] = (intp *)PyArray_DATA(ret); @@ -554,7 +554,7 @@ PyArray_Nonzero(PyArrayObject *self) for (j=0; j<n; j++) { item = PyArray_New(self->ob_type, 1, &count, PyArray_INTP, NULL, NULL, 0, 0, - self); + (PyObject *)self); PyTuple_SET_ITEM(ret, j, item); if (item == NULL) goto fail; dptr[j] = (intp *)PyArray_DATA(item); @@ -1046,7 +1046,8 @@ PyArray_Concatenate(PyObject *op, int axis) mps[0]->dimensions[0] = new_dim; ret = (PyArrayObject *)PyArray_New(subtype, nd, mps[0]->dimensions, - type_num, NULL, NULL, 0, 0, ret); + type_num, NULL, NULL, 0, 0, + (PyObject *)ret); mps[0]->dimensions[0] = tmp; if (ret == NULL) goto fail; @@ -1149,7 +1150,7 @@ PyArray_Transpose(PyArrayObject *ap, PyObject *op) { ret = (PyArrayObject *)PyArray_New(ap->ob_type, n, permutation, ap->descr->type_num, NULL, ap->data, ap->itemsize, ap->flags, - ap); + (PyObject *)ap); if (ret == NULL) goto fail; /* point at true owner of memory: */ @@ -1231,7 +1232,7 @@ PyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis) { aop->dimensions, aop->descr->type_num, NULL, NULL, aop->itemsize, 0, - aop); + (PyObject *)aop); aop->dimensions[axis] = n; if (ret == NULL) goto fail; @@ -1348,7 +1349,7 @@ PyArray_Choose(PyArrayObject *ip, PyObject *op) { */ ret = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd, ap->dimensions, type_num, - NULL, NULL, 0, 0, ap); + NULL, NULL, 0, 0, (PyObject *)ap); if (ret == NULL) goto fail; elsize = ret->itemsize; @@ -1504,7 +1505,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis) ret = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd, ap->dimensions, PyArray_INTP, - NULL, NULL, 0, 0, ap); + NULL, NULL, 0, 0, (PyObject *)ap); if (ret == NULL) goto fail; if (ap->descr->compare == NULL) { @@ -1608,7 +1609,7 @@ PyArray_SearchSorted(PyArrayObject *op1, PyObject *op2) ret = (PyArrayObject *)PyArray_New(ap2->ob_type, ap2->nd, ap2->dimensions, PyArray_INTP, - NULL, NULL, 0, 0, ap2); + NULL, NULL, 0, 0, (PyObject *)ap2); if (ret == NULL) goto fail; if (ap2->descr->compare == NULL) { @@ -1700,6 +1701,7 @@ PyArray_InnerProduct(PyObject *op1, PyObject *op2) ret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, typenum, NULL, NULL, 0, 0, + (PyObject *) (prior2 > prior1 ? ap2 : ap1)); if (ret == NULL) goto fail; @@ -1822,6 +1824,7 @@ PyArray_MatrixProduct(PyObject *op1, PyObject *op2) ret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, typenum, NULL, NULL, 0, 0, + (PyObject *) (prior2 > prior1 ? ap2 : ap1)); if (ret == NULL) goto fail; @@ -1898,7 +1901,7 @@ PyArray_CopyAndTranspose(PyObject *op) elsize = PyArray_ITEMSIZE(arr); ret = PyArray_New(arr->ob_type, 2, dims, PyArray_TYPE(arr), - NULL, NULL, elsize, 0, (PyArrayObject *)arr); + NULL, NULL, elsize, 0, arr); if (ret == NULL) { Py_DECREF(arr); @@ -1973,7 +1976,8 @@ PyArray_Correlate(PyObject *op1, PyObject *op2, int mode) ret = (PyArrayObject *)PyArray_New(ap1->ob_type, 1, &length, typenum, - NULL, NULL, 0, 0, ap1); + NULL, NULL, 0, 0, + (PyObject *)ap1); if (ret == NULL) goto fail; @@ -2130,7 +2134,8 @@ PyArray_ArgMax(PyArrayObject *op, int axis) rp = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd-1, ap->dimensions, PyArray_INTP, - NULL, NULL, 0, 0, ap); + NULL, NULL, 0, 0, + (PyObject *)ap); if (rp == NULL) goto fail; @@ -2195,7 +2200,8 @@ PyArray_Take(PyArrayObject *self0, PyObject *indices0, int axis) { } ret = (PyArrayObject *)PyArray_New(self->ob_type, nd, shape, self->descr->type_num, - NULL, NULL, 0, 0, self); + NULL, NULL, 0, 0, + (PyObject *)self); if (ret == NULL) goto fail; |