diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2012-11-01 18:24:50 +0100 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-04-12 16:44:59 +0200 |
| commit | 22fae03ce4d9f3855bd24e03ecdeb215eb1299e4 (patch) | |
| tree | 0215ed16db03a0ccbb77078d0b998ad71da42254 /numpy | |
| parent | 4bc65576d00984642572e043a6736ae2dbf7a458 (diff) | |
| download | numpy-22fae03ce4d9f3855bd24e03ecdeb215eb1299e4.tar.gz | |
MNT: Tiny cleanup for mapping.c and comments
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/include/numpy/ndarraytypes.h | 7 | ||||
| -rw-r--r-- | numpy/core/src/multiarray/mapping.c | 14 |
2 files changed, 12 insertions, 9 deletions
diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h index 72e598762..bb3f1065c 100644 --- a/numpy/core/include/numpy/ndarraytypes.h +++ b/numpy/core/include/numpy/ndarraytypes.h @@ -1275,8 +1275,11 @@ typedef struct { npy_intp bscoord[NPY_MAXDIMS]; PyObject *indexobj; /* creating obj */ - int consec; /* axes to swap if index - * arrays are consecutive */ + /* + * consec is first used to indicate wether fancy indices are + * consecutive and then denotes at which axis they are inserted + */ + int consec; char *dataptr; } PyArrayMapIterObject; diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index 984ce489c..17089761d 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/numpy/core/src/multiarray/mapping.c @@ -226,8 +226,7 @@ PyArray_MapIterSwapAxes(PyArrayMapIterObject *mit, PyArrayObject **ret, int getm * (n2,...,n1+n2-1,0,...,n2-1,n1+n2,...n3-1) */ n1 = mit->iters[0]->nd_m1 + 1; - /* We have to normalize for newaxes */ - n2 = mit->consec; + n2 = mit->consec; /* axes to insert at */ n3 = mit->nd; /* use n1 as the boundary if getting but n2 if setting */ @@ -1899,7 +1898,9 @@ PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr) j = 0; /* Only expand the first ellipsis */ noellip = 1; - memset(mit->bscoord, 0, sizeof(npy_intp)*(PyArray_NDIM(arr))); + /* count newaxes before iter axes */ + newaxes = 0; + memset(mit->bscoord, 0, sizeof(npy_intp)*PyArray_NDIM(arr)); for (i = 0; i < n; i++) { /* * We need to fill in the starting coordinates for @@ -1914,8 +1915,8 @@ PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr) noellip = 0; } else if (obj == Py_None) { - if (j == 0 && mit->consec) { - mit->consec += 1; /* count newaxes before iter axes */ + if (j == 0) { + newaxes += 1; } } else { @@ -1943,8 +1944,7 @@ PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr) } } if (mit->consec) { - /* if set, it was 1 + newaxes before first iter axis */ - mit->consec += mit->iteraxes[0] - 1; + mit->consec = mit->iteraxes[0] + newaxes; } finish: |
