summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/arrayterator.py29
-rw-r--r--numpy/lib/function_base.py2
-rw-r--r--numpy/lib/polynomial.py22
3 files changed, 40 insertions, 13 deletions
diff --git a/numpy/lib/arrayterator.py b/numpy/lib/arrayterator.py
index 3f07cd263..2df05e514 100644
--- a/numpy/lib/arrayterator.py
+++ b/numpy/lib/arrayterator.py
@@ -141,12 +141,41 @@ class Arrayterator(object):
@property
def flat(self):
+ """
+ A 1-D flat iterator for Arrayterator objects.
+
+ This iterator returns elements of the array to be iterated over in
+ `Arrayterator` one by one. It is similar to `flatiter`.
+
+ See Also
+ --------
+ `Arrayterator`
+ flatiter
+
+ Examples
+ --------
+ >>> a = np.arange(3 * 4 * 5 * 6).reshape(3, 4, 5, 6)
+ >>> a_itor = np.lib.arrayterator.Arrayterator(a, 2)
+
+ >>> for subarr in a_itor.flat:
+ ... if not subarr:
+ ... print subarr, type(subarr)
+ ...
+ 0 <type 'numpy.int32'>
+
+ """
for block in self:
for value in block.flat:
yield value
@property
def shape(self):
+ """
+ The shape of the array to be iterated over.
+
+ For an example, see `Arrayterator`.
+
+ """
return tuple(((stop-start-1)//step+1) for start, stop, step in
zip(self.start, self.stop, self.step))
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 292dbe41d..033e18f8e 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -99,7 +99,7 @@ def histogram(a, bins=10, range=None, normed=False, weights=None):
See Also
--------
- histogramdd, bincount, searchsorted
+ histogramdd, bincount, searchsorted, digitize
Notes
-----
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index 603655ec2..f3146d691 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -151,13 +151,14 @@ def roots(p):
Return the roots of a polynomial with coefficients given in p.
The values in the rank-1 array `p` are coefficients of a polynomial.
- If the length of `p` is n+1 then the polynomial is described by
- p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
+ If the length of `p` is n+1 then the polynomial is described by::
+
+ p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
Parameters
----------
- p : array_like of shape(M,)
- Rank-1 array of polynomial co-efficients.
+ p : array_like
+ Rank-1 array of polynomial coefficients.
Returns
-------
@@ -166,32 +167,29 @@ def roots(p):
Raises
------
- ValueError:
+ ValueError :
When `p` cannot be converted to a rank-1 array.
See also
--------
-
- poly : Find the coefficients of a polynomial with
- a given sequence of roots.
+ poly : Find the coefficients of a polynomial with a given sequence
+ of roots.
polyval : Evaluate a polynomial at a point.
polyfit : Least squares polynomial fit.
poly1d : A one-dimensional polynomial class.
Notes
-----
-
The algorithm relies on computing the eigenvalues of the
companion matrix [1]_.
References
----------
- .. [1] Wikipedia, "Companion matrix",
- http://en.wikipedia.org/wiki/Companion_matrix
+ .. [1] R. A. Horn & C. R. Johnson, *Matrix Analysis*. Cambridge, UK:
+ Cambridge University Press, 1999, pp. 146-7.
Examples
--------
-
>>> coeff = [3.2, 2, 1]
>>> np.roots(coeff)
array([-0.3125+0.46351241j, -0.3125-0.46351241j])