[Numpy-svn] r5333 - trunk/numpy/core

numpy-svn@scip... numpy-svn@scip...
Wed Jul 2 21:23:37 CDT 2008


Author: alan.mcintyre
Date: 2008-07-02 21:23:34 -0500 (Wed, 02 Jul 2008)
New Revision: 5333

Modified:
   trunk/numpy/core/fromnumeric.py
   trunk/numpy/core/numeric.py
Log:
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.


Modified: trunk/numpy/core/fromnumeric.py
===================================================================
--- trunk/numpy/core/fromnumeric.py	2008-07-02 21:46:01 UTC (rev 5332)
+++ trunk/numpy/core/fromnumeric.py	2008-07-03 02:23:34 UTC (rev 5333)
@@ -155,11 +155,11 @@
 
     >>> 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 @@
 
     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 @@
 
     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 @@
 
     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 @@
     >>> x
     array([[1, 2, 3],
            [4, 5, 6]])
-    >>> ravel(x)
+    >>> np.ravel(x)
     array([1, 2, 3, 4, 5, 6])
 
     """
@@ -1536,7 +1536,7 @@
     --------
     >>> 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

Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py	2008-07-02 21:46:01 UTC (rev 5332)
+++ trunk/numpy/core/numeric.py	2008-07-03 02:23:34 UTC (rev 5333)
@@ -881,22 +881,23 @@
     """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



More information about the Numpy-svn mailing list