summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-06-01 21:11:10 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-06-01 21:11:10 +0000
commit9f88ecbc10e7a1f56e2eb1b8445184263111a1cf (patch)
treef832339e857c4629da3161919f2844d1f65eddac /numpy
parent5a85dd3d9557c5aa4119ced4ebd47e0e8e3f1142 (diff)
downloadnumpy-9f88ecbc10e7a1f56e2eb1b8445184263111a1cf.tar.gz
Comment changes and change var and std to divide by N instead of N-1
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarraymodule.c4
-rw-r--r--numpy/lib/index_tricks.py5
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