summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/add_newdocs.py14
-rw-r--r--numpy/lib/arrayterator.py29
-rw-r--r--numpy/lib/function_base.py2
-rw-r--r--numpy/lib/polynomial.py22
-rw-r--r--numpy/ma/core.py12
5 files changed, 61 insertions, 18 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index 5b65d9ce1..62e656346 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -2605,9 +2605,15 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('astype',
Parameters
----------
- t : string or dtype
+ t : str or dtype
Typecode or data-type to which the array is cast.
+ Raises
+ ------
+ ComplexWarning :
+ When casting from complex to float or int. To avoid this,
+ one should use ``a.real.astype(t)``.
+
Examples
--------
>>> x = np.array([1, 2, 2.5])
@@ -4297,8 +4303,9 @@ add_newdoc('numpy.lib._compiled_base', 'bincount',
Input array.
weights : array_like, optional
Weights, array of the same shape as `x`.
- minlength : integer, optional
+ minlength : int, optional
.. versionadded:: 1.6.0
+
A minimum number of bins for the output array.
Returns
@@ -4330,6 +4337,9 @@ add_newdoc('numpy.lib._compiled_base', 'bincount',
>>> np.bincount(x).size == np.amax(x)+1
True
+ The input array needs to be of integer dtype, otherwise a
+ TypeError is raised:
+
>>> np.bincount(np.arange(5, dtype=np.float))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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])
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 673cfb1ab..48ed424ff 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -2580,9 +2580,9 @@ class MaskedArray(ndarray):
Construction::
- x = MaskedArray(data, mask=nomask, dtype=None, copy=True,
- fill_value=None, keep_mask=True, hard_mask=False,
- shrink=True)
+ x = MaskedArray(data, mask=nomask, dtype=None,
+ copy=False, subok=True, ndmin=0, fill_value=None,
+ keep_mask=True, hard_mask=None, flag=None, shrink=True)
Parameters
----------
@@ -3373,6 +3373,12 @@ class MaskedArray(ndarray):
The value to use for invalid entries (None by default).
If None, the `fill_value` attribute of the array is used instead.
+ Returns
+ -------
+ filled_array : ndarray
+ A copy of ``self`` with invalid entries replaced by *fill_value*
+ (be it the function argument or the attribute of ``self``.
+
Notes
-----
The result is **not** a MaskedArray!