summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorAlan McIntyre <alan.mcintyre@local>2008-07-03 02:23:34 +0000
committerAlan McIntyre <alan.mcintyre@local>2008-07-03 02:23:34 +0000
commita1be9e66bbbbb28a42cd51b8f2f0301dc25e1080 (patch)
tree2b9e40a3204e22c6a57dd46926ed4e6211d412d0 /numpy/core/numeric.py
parent6a4e465bce127b61948301c9de835e7de99b4c29 (diff)
downloadnumpy-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.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py21
1 files changed, 11 insertions, 10 deletions
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