[Numpy-svn] r3550 - in trunk/numpy: core lib

numpy-svn@scip... numpy-svn@scip...
Sun Feb 18 16:44:01 CST 2007


Author: stefan
Date: 2007-02-18 16:43:40 -0600 (Sun, 18 Feb 2007)
New Revision: 3550

Modified:
   trunk/numpy/core/arrayprint.py
   trunk/numpy/core/fromnumeric.py
   trunk/numpy/core/numeric.py
   trunk/numpy/lib/function_base.py
   trunk/numpy/lib/index_tricks.py
   trunk/numpy/lib/polynomial.py
   trunk/numpy/lib/shape_base.py
   trunk/numpy/lib/utils.py
Log:
Fix doctests.


Modified: trunk/numpy/core/arrayprint.py
===================================================================
--- trunk/numpy/core/arrayprint.py	2007-02-18 21:02:46 UTC (rev 3549)
+++ trunk/numpy/core/arrayprint.py	2007-02-18 22:43:40 UTC (rev 3550)
@@ -245,7 +245,7 @@
     Examples
     --------
 
-    >>> x = array([1e-16,1,2,3])
+    >>> x = N.array([1e-16,1,2,3])
     >>> print array2string(x,precision=2,separator=',',suppress_small=True)
     [ 0., 1., 2., 3.]
 

Modified: trunk/numpy/core/fromnumeric.py
===================================================================
--- trunk/numpy/core/fromnumeric.py	2007-02-18 21:02:46 UTC (rev 3549)
+++ trunk/numpy/core/fromnumeric.py	2007-02-18 22:43:40 UTC (rev 3550)
@@ -142,6 +142,7 @@
       array([20, 31, 12,  3])
       >>> choose([2, 4, 1, 0], choices, mode='wrap')
       array([20,  1, 12,  3])
+      
     """
     try:
         choose = a.choose
@@ -173,6 +174,7 @@
       array([0, 0, 1, 1, 2, 2])
       >>> repeat([0, 1, 2], [2, 3, 4])
       array([0, 0, 1, 1, 1, 2, 2, 2, 2])
+      
     """
     try:
         repeat = a.repeat
@@ -487,16 +489,16 @@
 
         x.dtype                         default sum() dtype
         ---------------------------------------------------
-        bool, Int8, Int16, Int32        Int32
+        bool, int8, int16, int32        int32
 
     Examples:
-    >>> sum([0.5, 1.5])
+    >>> N.sum([0.5, 1.5])
     2.0
-    >>> sum([0.5, 1.5], dtype=Int32)
+    >>> N.sum([0.5, 1.5], dtype=N.int32)
     1
-    >>> sum([[0, 1], [0, 5]])
-    array([0, 6])
-    >>> sum([[0, 1], [0, 5]], axis=1)
+    >>> N.sum([[0, 1], [0, 5]])
+    6
+    >>> N.sum([[0, 1], [0, 5]], axis=1)
     array([1, 5])
     """
     if isinstance(x, _gentype):

Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py	2007-02-18 21:02:46 UTC (rev 3549)
+++ trunk/numpy/core/numeric.py	2007-02-18 22:43:40 UTC (rev 3550)
@@ -691,15 +691,17 @@
 
     Example:
 
-    >>> seterr(over='raise')
+    >>> seterr(over='raise') # doctest: +SKIP
     {'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}
-    >>> seterr(all='warn', over='raise')
+    
+    >>> seterr(all='warn', over='raise') # doctest: +SKIP
     {'over': 'raise', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}
-    >>> int16(32000) * int16(3)
+    
+    >>> int16(32000) * int16(3) # doctest: +SKIP
     Traceback (most recent call last):
           File "<stdin>", line 1, in ?
     FloatingPointError: overflow encountered in short_scalars
-    >>> seterr(all='ignore')
+    >>> seterr(all='ignore') # doctest: +SKIP
     {'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}
 
     """

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2007-02-18 21:02:46 UTC (rev 3549)
+++ trunk/numpy/lib/function_base.py	2007-02-18 22:43:40 UTC (rev 3550)
@@ -665,7 +665,7 @@
 
     Example:
     >>> unique([5,2,4,0,4,4,2,2,1])
-    array([0,1,2,4,5])
+    array([0, 1, 2, 4, 5])
     
     """
     try:
@@ -806,13 +806,13 @@
 
   Example:
 
-    def myfunc(a, b):
-        if a > b:
-            return a-b
-        else
-            return a+b
+    >>> def myfunc(a, b):
+    ...    if a > b:
+    ...        return a-b
+    ...    else:
+    ...        return a+b
 
-    vfunc = vectorize(myfunc)
+    >>> vfunc = vectorize(myfunc)
 
     >>> vfunc([1, 2, 3, 4], 2)
     array([3, 4, 1, 2])
@@ -1197,16 +1197,16 @@
 
     Example:
     >>> arr = [[3,4,5],
-              [1,2,3],
-              [6,7,8]]
+    ...       [1,2,3],
+    ...       [6,7,8]]
 
     >>> delete(arr, 1, 1)
-    array([[3,5],
-           [1,3],
-           [6,8])
+    array([[3, 5],
+           [1, 3],
+           [6, 8]])
     >>> delete(arr, 1, 0)
-    array([[3,4,5],
-           [6,7,8]])
+    array([[3, 4, 5],
+           [6, 7, 8]])
     """
     wrap = None
     if type(arr) is not ndarray:
@@ -1300,15 +1300,15 @@
 
     Example:
     >>> a = array([[1,2,3],
-                   [4,5,6],
-                   [7,8,9]])
+    ...            [4,5,6],
+    ...            [7,8,9]])
 
     >>> insert(a, [1,2], [[4],[5]], axis=0)
-    array([[1,2,3],
-           [4,4,4],
-           [4,5,6],
-           [5,5,5],
-           [7,8,9])
+    array([[1, 2, 3],
+           [4, 4, 4],
+           [4, 5, 6],
+           [5, 5, 5],
+           [7, 8, 9]])
     """
     wrap = None
     if type(arr) is not ndarray:

Modified: trunk/numpy/lib/index_tricks.py
===================================================================
--- trunk/numpy/lib/index_tricks.py	2007-02-18 21:02:46 UTC (rev 3549)
+++ trunk/numpy/lib/index_tricks.py	2007-02-18 22:43:40 UTC (rev 3550)
@@ -108,6 +108,7 @@
                    [2, 2, 2, 2, 2],
                    [3, 3, 3, 3, 3],
                    [4, 4, 4, 4, 4]],
+           <BLANKLINE>
                   [[0, 1, 2, 3, 4],
                    [0, 1, 2, 3, 4],
                    [0, 1, 2, 3, 4],
@@ -118,7 +119,11 @@
 
            >>> ogrid = nd_grid(sparse=True)
            >>> ogrid[0:5,0:5]
-           [array([[0],[1],[2],[3],[4]]), array([[0, 1, 2, 3, 4]])]
+           [array([[0],
+                  [1],
+                  [2],
+                  [3],
+                  [4]]), array([[0, 1, 2, 3, 4]])]
            
     """
     def __init__(self, sparse=False):
@@ -359,15 +364,15 @@
     will then return an N-dimensional counter.
 
     Example:
-    >>> for index in ndindex(4,3,2):
-            print index
-    (0,0,0)
-    (0,0,1)
-    (0,1,0)
-    ...
-    (3,1,1)
-    (3,2,0)
-    (3,2,1)
+    >>> for index in ndindex(3,2,1):
+    ...     print index
+    (0, 0, 0)
+    (0, 1, 0)
+    (1, 0, 0)
+    (1, 1, 0)
+    (2, 0, 0)
+    (2, 1, 0)
+
     """
 
     def __init__(self, *args):

Modified: trunk/numpy/lib/polynomial.py
===================================================================
--- trunk/numpy/lib/polynomial.py	2007-02-18 21:02:46 UTC (rev 3549)
+++ trunk/numpy/lib/polynomial.py	2007-02-18 22:43:40 UTC (rev 3550)
@@ -56,7 +56,7 @@
         
         >>> b = roots([1,3,1,5,6])
         >>> poly(b)
-        array([1., 3., 1., 5., 6.])
+        array([ 1.,  3.,  1.,  5.,  6.])
         
     """
     seq_of_zeros = atleast_1d(seq_of_zeros)

Modified: trunk/numpy/lib/shape_base.py
===================================================================
--- trunk/numpy/lib/shape_base.py	2007-02-18 21:02:46 UTC (rev 3549)
+++ trunk/numpy/lib/shape_base.py	2007-02-18 22:43:40 UTC (rev 3550)
@@ -288,15 +288,17 @@
         >>> a = array((1,2,3))
         >>> b = array((2,3,4))
         >>> numpy.dstack((a,b))
-        array([       [[1, 2],
-                       [2, 3],
-                       [3, 4]]])
+        array([[[1, 2],
+                [2, 3],
+                [3, 4]]])
         >>> a = array([[1],[2],[3]])
         >>> b = array([[2],[3],[4]])
         >>> numpy.dstack((a,b))
-        array([[        [1, 2]],
-        [        [2, 3]],
-        [        [3, 4]]])
+        array([[[1, 2]],
+        <BLANKLINE>
+               [[2, 3]],
+        <BLANKLINE>
+               [[3, 4]]])
         
     """
     return _nx.concatenate(map(atleast_3d,tup),2)
@@ -436,6 +438,7 @@
             >>> numpy.hsplit(a,2)
             [array([1, 2]), array([3, 4])]
             >>> a = array([[1,2,3,4],[1,2,3,4]])
+            >>> hsplit(a,2)
             [array([[1, 2],
                    [1, 2]]), array([[3, 4],
                    [3, 4]])]
@@ -482,8 +485,8 @@
             import numpy
             >>> a = array([[1,2,3,4],
             ...            [1,2,3,4]])
-            >>> numpy.vsplit(a)
-            [array([       [1, 2, 3, 4]]), array([       [1, 2, 3, 4]])]
+            >>> numpy.vsplit(a,2)
+            [array([[1, 2, 3, 4]]), array([[1, 2, 3, 4]])]
 
     """
     if len(_nx.shape(ary)) < 2:
@@ -518,8 +521,9 @@
             dstack, split, array_split, hsplit, vsplit.
         Examples:
             >>> a = array([[[1,2,3,4],[1,2,3,4]]])
-            [array([       [[1, 2],
-                    [1, 2]]]), array([       [[3, 4],
+            >>> dsplit(a,2)
+            [array([[[1, 2],
+                    [1, 2]]]), array([[[3, 4],
                     [3, 4]]])]
 
     """
@@ -603,7 +607,7 @@
            [0, 1, 2, 0, 1, 2]])
     >>> tile(a,(2,1,2))
     array([[[0, 1, 2, 0, 1, 2]],
-
+    <BLANKLINE>
            [[0, 1, 2, 0, 1, 2]]])
 
     See Also:

Modified: trunk/numpy/lib/utils.py
===================================================================
--- trunk/numpy/lib/utils.py	2007-02-18 21:02:46 UTC (rev 3549)
+++ trunk/numpy/lib/utils.py	2007-02-18 22:43:40 UTC (rev 3550)
@@ -269,7 +269,8 @@
 
        Example:
           >>> from numpy import *
-          >>> info(polyval)
+          >>> info(polyval) # doctest: +SKIP
+          
           polyval(p, x)
 
             Evaluate the polymnomial p at x.



More information about the Numpy-svn mailing list