diff options
author | Alan McIntyre <alan.mcintyre@local> | 2008-07-03 02:23:34 +0000 |
---|---|---|
committer | Alan McIntyre <alan.mcintyre@local> | 2008-07-03 02:23:34 +0000 |
commit | a1be9e66bbbbb28a42cd51b8f2f0301dc25e1080 (patch) | |
tree | 2b9e40a3204e22c6a57dd46926ed4e6211d412d0 | |
parent | 6a4e465bce127b61948301c9de835e7de99b4c29 (diff) | |
download | numpy-a1be9e66bbbbb28a42cd51b8f2f0301dc25e1080.tar.gz |
Update doctests to assume only an "import numpy as np" has been executed prior to the
example code.
Updated numeric.py doctests to skip with-statements, and updated expected outputs to
match current NumPy behavior.
-rw-r--r-- | numpy/core/fromnumeric.py | 24 | ||||
-rw-r--r-- | numpy/core/numeric.py | 21 |
2 files changed, 23 insertions, 22 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index c8521b735..d3d94b891 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -155,11 +155,11 @@ def choose(a, choices, out=None, mode='raise'): >>> choices = [[0, 1, 2, 3], [10, 11, 12, 13], ... [20, 21, 22, 23], [30, 31, 32, 33]] - >>> choose([2, 3, 1, 0], choices) + >>> np.choose([2, 3, 1, 0], choices) array([20, 31, 12, 3]) - >>> choose([2, 4, 1, 0], choices, mode='clip') + >>> np.choose([2, 4, 1, 0], choices, mode='clip') array([20, 31, 12, 3]) - >>> choose([2, 4, 1, 0], choices, mode='wrap') + >>> np.choose([2, 4, 1, 0], choices, mode='wrap') array([20, 1, 12, 3]) """ @@ -197,13 +197,13 @@ def repeat(a, repeats, axis=None): Examples -------- - >>> x = array([[1,2],[3,4]]) - >>> repeat(x, 2) + >>> x = np.array([[1,2],[3,4]]) + >>> np.repeat(x, 2) array([1, 1, 2, 2, 3, 3, 4, 4]) - >>> repeat(x, 3, axis=1) + >>> np.repeat(x, 3, axis=1) array([[1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4]]) - >>> repeat(x, [1, 2], axis=0) + >>> np.repeat(x, [1, 2], axis=0) array([[1, 2], [3, 4], [3, 4]]) @@ -560,7 +560,7 @@ def searchsorted(a, v, side='left'): Examples -------- - >>> searchsorted([1,2,3,4,5],[6,4,0]) + >>> np.searchsorted([1,2,3,4,5],[6,4,0]) array([5, 3, 0]) """ @@ -624,10 +624,10 @@ def squeeze(a): Examples -------- - >>> x = array([[[1,1,1],[2,2,2],[3,3,3]]]) + >>> x = np.array([[[1,1,1],[2,2,2],[3,3,3]]]) >>> x.shape (1, 3, 3) - >>> squeeze(x).shape + >>> np.squeeze(x).shape (3, 3) """ @@ -782,7 +782,7 @@ def ravel(a, order='C'): >>> x array([[1, 2, 3], [4, 5, 6]]) - >>> ravel(x) + >>> np.ravel(x) array([1, 2, 3, 4, 5, 6]) """ @@ -1536,7 +1536,7 @@ def ndim(a): -------- >>> np.ndim([[1,2,3],[4,5,6]]) 2 - >>> np.ndim(array([[1,2,3],[4,5,6]])) + >>> np.ndim(np.array([[1,2,3],[4,5,6]])) 2 >>> np.ndim(1) 0 diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 3e4b6cb1f..2945a892b 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -881,22 +881,23 @@ class errstate(object): """with errstate(**state): --> operations in following block use given state. # Set error handling to known state. - >>> _ = seterr(invalid='raise', divide='raise', over='raise', under='ignore') + >>> _ = np.seterr(invalid='raise', divide='raise', over='raise', + ... under='ignore') - |>> a = -arange(3) - |>> with errstate(invalid='ignore'): - ... print sqrt(a) + >>> a = -np.arange(3) + >>> with np.errstate(invalid='ignore'): # doctest: +SKIP + ... print np.sqrt(a) # with statement requires Python 2.5 [ 0. -1.#IND -1.#IND] - |>> print sqrt(a.astype(complex)) - [ 0. +0.00000000e+00j 0. +1.00000000e+00j 0. +1.41421356e+00j] - |>> print sqrt(a) + >>> print np.sqrt(a.astype(complex)) + [ 0.+0.j 0.+1.j 0.+1.41421356j] + >>> print np.sqrt(a) Traceback (most recent call last): ... - FloatingPointError: invalid encountered in sqrt - |>> with errstate(divide='ignore'): + FloatingPointError: invalid value encountered in sqrt + >>> with np.errstate(divide='ignore'): # doctest: +SKIP ... print a/0 [0 0 0] - |>> print a/0 + >>> print a/0 Traceback (most recent call last): ... FloatingPointError: divide by zero encountered in divide |