diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-01-16 01:48:42 -0800 |
---|---|---|
committer | Mark Wiebe <mwwiebe@gmail.com> | 2011-01-16 01:48:42 -0800 |
commit | 165d98d9a574aaba367f20b4fcd8dec7fda0bafb (patch) | |
tree | e95edbebc6ba31a11481974c5d50ade444338a9d /numpy/add_newdocs.py | |
parent | 1604e898911755ee29f829ee2ae1ffcc80c3dade (diff) | |
download | numpy-165d98d9a574aaba367f20b4fcd8dec7fda0bafb.tar.gz |
ENH: core: Switch nonzero to use the iterator as an example, add count_nonzero function
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r-- | numpy/add_newdocs.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index baf5285f0..2faf3ba16 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -481,6 +481,35 @@ add_newdoc('numpy.core.multiarray', 'zeros', """) +add_newdoc('numpy.core.multiarray', 'count_nonzero', + """ + count_nonzero(a) + + Counts the number of non-zero values in the array ``a``. + + Parameters + ---------- + a : array_like + The array for which to count non-zeros. + + Returns + ------- + count : int + Number of non-zero values in the array. + + See Also + -------- + nonzero : Return the coordinates of all the non-zero values. + + Examples + -------- + >>> np.count_nonzero(np.eye(4)) + 4 + + >>> np.count_nonzero([[0,1,7,0,0],[3,0,0,2,19]]) + 5 + """) + add_newdoc('numpy.core.multiarray','set_typeDict', """set_typeDict(dict) |