"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "numpy/core/src/multiarray/iterators.c" between
numpy-1.21.0.tar.gz and numpy-1.21.1.tar.gz

About: NumPy is the fundamental package for scientific computing with Python.

iterators.c  (numpy-1.21.0):iterators.c  (numpy-1.21.1)
skipping to change at line 18 skipping to change at line 18
#include "numpy/arrayscalars.h" #include "numpy/arrayscalars.h"
#include "npy_config.h" #include "npy_config.h"
#include "npy_pycompat.h" #include "npy_pycompat.h"
#include "arrayobject.h" #include "arrayobject.h"
#include "iterators.h" #include "iterators.h"
#include "ctors.h" #include "ctors.h"
#include "common.h" #include "common.h"
#include "conversion_utils.h"
#include "array_coercion.h" #include "array_coercion.h"
#define NEWAXIS_INDEX -1 #define NEWAXIS_INDEX -1
#define ELLIPSIS_INDEX -2 #define ELLIPSIS_INDEX -2
#define SINGLE_INDEX -3 #define SINGLE_INDEX -3
/* /*
* Tries to convert 'o' into an npy_intp interpreted as an * Tries to convert 'o' into an npy_intp interpreted as an
* index. Returns 1 if it was successful, 0 otherwise. Does * index. Returns 1 if it was successful, 0 otherwise. Does
* not set an exception. * not set an exception.
skipping to change at line 1052 skipping to change at line 1053
PyArray_ResolveWritebackIfCopy(new); PyArray_ResolveWritebackIfCopy(new);
Py_DECREF(new); Py_DECREF(new);
return ret; return ret;
} }
static PyMemberDef iter_members[] = { static PyMemberDef iter_members[] = {
{"base", {"base",
T_OBJECT, T_OBJECT,
offsetof(PyArrayIterObject, ao), offsetof(PyArrayIterObject, ao),
READONLY, NULL}, READONLY, NULL},
{"index",
T_INT,
offsetof(PyArrayIterObject, index),
READONLY, NULL},
{NULL, 0, 0, 0, NULL}, {NULL, 0, 0, 0, NULL},
}; };
static PyObject * static PyObject *
iter_index_get(PyArrayIterObject *self)
{
return PyArray_PyIntFromIntp(self->index);
}
static PyObject *
iter_coords_get(PyArrayIterObject *self) iter_coords_get(PyArrayIterObject *self)
{ {
int nd; int nd;
nd = PyArray_NDIM(self->ao); nd = PyArray_NDIM(self->ao);
if (self->contiguous) { if (self->contiguous) {
/* /*
* coordinates not kept track of --- * coordinates not kept track of ---
* need to generate from index * need to generate from index
*/ */
npy_intp val; npy_intp val;
skipping to change at line 1085 skipping to change at line 1088
val = val % self->factors[i]; val = val % self->factors[i];
} else { } else {
self->coordinates[i] = 0; self->coordinates[i] = 0;
} }
} }
} }
return PyArray_IntTupleFromIntp(nd, self->coordinates); return PyArray_IntTupleFromIntp(nd, self->coordinates);
} }
static PyGetSetDef iter_getsets[] = { static PyGetSetDef iter_getsets[] = {
{"index",
(getter)iter_index_get,
NULL, NULL, NULL},
{"coords", {"coords",
(getter)iter_coords_get, (getter)iter_coords_get,
NULL, NULL, NULL, NULL},
NULL, NULL},
{NULL, NULL, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL},
}; };
NPY_NO_EXPORT PyTypeObject PyArrayIter_Type = { NPY_NO_EXPORT PyTypeObject PyArrayIter_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "numpy.flatiter", .tp_name = "numpy.flatiter",
.tp_basicsize = sizeof(PyArrayIterObject), .tp_basicsize = sizeof(PyArrayIterObject),
.tp_dealloc = (destructor)arrayiter_dealloc, .tp_dealloc = (destructor)arrayiter_dealloc,
.tp_as_mapping = &iter_as_mapping, .tp_as_mapping = &iter_as_mapping,
.tp_flags = Py_TPFLAGS_DEFAULT, .tp_flags = Py_TPFLAGS_DEFAULT,
skipping to change at line 1400 skipping to change at line 1405
for (i = 0; i < multi->numiter; i++) { for (i = 0; i < multi->numiter; i++) {
Py_XDECREF(multi->iters[i]); Py_XDECREF(multi->iters[i]);
} }
Py_TYPE(multi)->tp_free((PyObject *)multi); Py_TYPE(multi)->tp_free((PyObject *)multi);
} }
static PyObject * static PyObject *
arraymultiter_size_get(PyArrayMultiIterObject *self) arraymultiter_size_get(PyArrayMultiIterObject *self)
{ {
#if NPY_SIZEOF_INTP <= NPY_SIZEOF_LONG return PyArray_PyIntFromIntp(self->size);
return PyLong_FromLong((long) self->size);
#else
if (self->size < NPY_MAX_LONG) {
return PyLong_FromLong((long) self->size);
}
else {
return PyLong_FromLongLong((npy_longlong) self->size);
}
#endif
} }
static PyObject * static PyObject *
arraymultiter_index_get(PyArrayMultiIterObject *self) arraymultiter_index_get(PyArrayMultiIterObject *self)
{ {
#if NPY_SIZEOF_INTP <= NPY_SIZEOF_LONG return PyArray_PyIntFromIntp(self->index);
return PyLong_FromLong((long) self->index);
#else
if (self->size < NPY_MAX_LONG) {
return PyLong_FromLong((long) self->index);
}
else {
return PyLong_FromLongLong((npy_longlong) self->index);
}
#endif
} }
static PyObject * static PyObject *
arraymultiter_shape_get(PyArrayMultiIterObject *self) arraymultiter_shape_get(PyArrayMultiIterObject *self)
{ {
return PyArray_IntTupleFromIntp(self->nd, self->dimensions); return PyArray_IntTupleFromIntp(self->nd, self->dimensions);
} }
static PyObject * static PyObject *
arraymultiter_iters_get(PyArrayMultiIterObject *self) arraymultiter_iters_get(PyArrayMultiIterObject *self)
 End of changes. 7 change blocks. 
26 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)