diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarraymodule.c | 4 | ||||
-rw-r--r-- | numpy/lib/index_tricks.py | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c index d543def01..004354e33 100644 --- a/numpy/core/src/multiarraymodule.c +++ b/numpy/core/src/multiarraymodule.c @@ -674,9 +674,9 @@ PyArray_Std(PyArrayObject *self, int axis, int rtype, int variance) Py_DECREF(obj2); if (obj1 == NULL) {Py_DECREF(new); return NULL;} - n = PyArray_DIM(new,axis)-1; + n = PyArray_DIM(new,axis); Py_DECREF(new); - if (n<=0) n=1; + if (n==0) n=1; obj2 = PyFloat_FromDouble(1.0/((double )n)); if (obj2 == NULL) {Py_DECREF(obj1); return NULL;} ret = PyNumber_Multiply(obj1, obj2); diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 6f9d14e3e..c1516a976 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -18,9 +18,9 @@ makemat = matrix.matrix # contributed by Stefan van der Walt def unravel_index(x,dims): - """Convert a flat index into an index tuple for a matrix of given shape. + """Convert a flat index into an index tuple for an array of given shape. - e.g. for a 2x2 matrix, unravel_index(2,(2,2)) returns (1,0). + e.g. for a 2x2 array, unravel_index(2,(2,2)) returns (1,0). Example usage: p = x.argmax() @@ -314,6 +314,7 @@ class ndenumerate(object): def __iter__(self): return self + class ndindex(object): """Pass in a sequence of integers corresponding to the number of dimensions in the counter. This iterator |