[Numpy-svn] r5351 - in trunk/numpy: . lib linalg ma testing

numpy-svn@scip... numpy-svn@scip...
Sat Jul 5 09:26:32 CDT 2008


Author: alan.mcintyre
Date: 2008-07-05 09:26:16 -0500 (Sat, 05 Jul 2008)
New Revision: 5351

Modified:
   trunk/numpy/add_newdocs.py
   trunk/numpy/lib/financial.py
   trunk/numpy/lib/function_base.py
   trunk/numpy/lib/io.py
   trunk/numpy/lib/polynomial.py
   trunk/numpy/lib/scimath.py
   trunk/numpy/lib/shape_base.py
   trunk/numpy/lib/twodim_base.py
   trunk/numpy/linalg/linalg.py
   trunk/numpy/ma/core.py
   trunk/numpy/ma/extras.py
   trunk/numpy/testing/decorators.py
Log:
Use the implicit "import numpy as np" made available to all doctests instead 
of explicit imports or dependency on the local scope where the doctest is 
defined..


Modified: trunk/numpy/add_newdocs.py
===================================================================
--- trunk/numpy/add_newdocs.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/add_newdocs.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -19,46 +19,46 @@
 --------
 
 Using array-scalar type:
->>> dtype(int16)
+>>> np.dtype(np.int16)
 dtype('int16')
 
 Record, one field name 'f1', containing int16:
->>> dtype([('f1', int16)])
+>>> np.dtype([('f1', np.int16)])
 dtype([('f1', '<i2')])
 
 Record, one field named 'f1', in itself containing a record with one field:
->>> dtype([('f1', [('f1', int16)])])
+>>> np.dtype([('f1', [('f1', np.int16)])])
 dtype([('f1', [('f1', '<i2')])])
 
 Record, two fields: the first field contains an unsigned int, the
 second an int32:
->>> dtype([('f1', uint), ('f2', int32)])
+>>> np.dtype([('f1', np.uint), ('f2', np.int32)])
 dtype([('f1', '<u4'), ('f2', '<i4')])
 
 Using array-protocol type strings:
->>> dtype([('a','f8'),('b','S10')])
+>>> np.dtype([('a','f8'),('b','S10')])
 dtype([('a', '<f8'), ('b', '|S10')])
 
 Using comma-separated field formats.  The shape is (2,3):
->>> dtype("i4, (2,3)f8")
+>>> np.dtype("i4, (2,3)f8")
 dtype([('f0', '<i4'), ('f1', '<f8', (2, 3))])
 
 Using tuples.  ``int`` is a fixed type, 3 the field's shape.  ``void``
 is a flexible type, here of size 10:
->>> dtype([('hello',(int,3)),('world',void,10)])
+>>> np.dtype([('hello',(np.int,3)),('world',np.void,10)])
 dtype([('hello', '<i4', 3), ('world', '|V10')])
 
 Subdivide ``int16`` into 2 ``int8``'s, called x and y.  0 and 1 are
 the offsets in bytes:
->>> dtype((int16, {'x':(int8,0), 'y':(int8,1)}))
+>>> np.dtype((np.int16, {'x':(np.int8,0), 'y':(np.int8,1)}))
 dtype(('<i2', [('x', '|i1'), ('y', '|i1')]))
 
 Using dictionaries.  Two fields named 'gender' and 'age':
->>> dtype({'names':['gender','age'], 'formats':['S1',uint8]})
+>>> np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]})
 dtype([('gender', '|S1'), ('age', '|u1')])
 
 Offsets in bytes, here 0 and 25:
->>> dtype({'surname':('S25',0),'age':(uint8,25)})
+>>> np.dtype({'surname':('S25',0),'age':(np.uint8,25)})
 dtype([('surname', '|S25'), ('age', '|u1')])
 
 """)
@@ -386,7 +386,7 @@
 
     Examples
     --------
-    >>> concatenate( ([0,1,2], [5,6,7]) )
+    >>> np.concatenate( ([0,1,2], [5,6,7]) )
     array([0, 1, 2, 5, 6, 7])
 
     """)
@@ -480,7 +480,7 @@
 
     Examples
     --------
-    >>> where([True,False,True],[1,2,3],[4,5,6])
+    >>> np.where([True,False,True],[1,2,3],[4,5,6])
     array([1, 5, 3])
 
     """)
@@ -520,12 +520,12 @@
     --------
     >>> a = [1,5,1,4,3,6,7]
     >>> b = [9,4,0,4,0,4,3]
-    >>> ind = lexsort((b,a))
+    >>> ind = np.lexsort((b,a))
     >>> print ind
     [2 0 4 3 1 5 6]
-    >>> print take(a,ind)
+    >>> print np.take(a,ind)
     [1 1 3 4 5 6 7]
-    >>> print take(b,ind)
+    >>> print np.take(b,ind)
     [0 9 0 4 4 4 3]
 
     """)
@@ -858,7 +858,7 @@
 
     Examples
     --------
-    >>> a = arange(6).reshape(2,3)
+    >>> a = np.arange(6).reshape(2,3)
     >>> a.argmax()
     5
     >>> a.argmax(0)
@@ -889,7 +889,7 @@
 
     Examples
     --------
-    >>> a = arange(6).reshape(2,3)
+    >>> a = np.arange(6).reshape(2,3)
     >>> a.argmin()
     0
     >>> a.argmin(0)
@@ -1008,10 +1008,10 @@
     --------
     >>> choices = [[0, 1, 2, 3], [10, 11, 12, 13],
     ...   [20, 21, 22, 23], [30, 31, 32, 33]]
-    >>> a = array([2, 3, 1, 0], dtype=int)
+    >>> a = np.array([2, 3, 1, 0], dtype=int)
     >>> a.choose(choices)
     array([20, 31, 12,  3])
-    >>> a = array([2, 4, 1, 0], dtype=int)
+    >>> a = np.array([2, 4, 1, 0], dtype=int)
     >>> a.choose(choices, mode='clip')
     array([20, 31, 12,  3])
     >>> a.choose(choices, mode='wrap')
@@ -1226,7 +1226,7 @@
 
     Examples
     --------
-    >>> a = arange(4).reshape(2,2)
+    >>> a = np.arange(4).reshape(2,2)
     >>> a
     array([[0, 1],
            [2, 3]])
@@ -1235,7 +1235,7 @@
     >>> a.diagonal(1)
     array([1])
 
-    >>> a = arange(8).reshape(2,2,2)
+    >>> a = np.arange(8).reshape(2,2,2)
     >>> a
     array([[[0, 1],
             [2, 3]],
@@ -1462,13 +1462,13 @@
 
     Examples
     --------
-    >>> prod([1.,2.])
+    >>> np.prod([1.,2.])
     2.0
-    >>> prod([1.,2.], dtype=int32)
+    >>> np.prod([1.,2.], dtype=np.int32)
     2
-    >>> prod([[1.,2.],[3.,4.]])
+    >>> np.prod([[1.,2.],[3.,4.]])
     24.0
-    >>> prod([[1.,2.],[3.,4.]], axis=1)
+    >>> np.prod([[1.,2.],[3.,4.]], axis=1)
     array([  2.,  12.])
 
     Notes
@@ -1599,7 +1599,7 @@
 
     Examples
     --------
-    >>> x = array([[1,2,3],[4,5,6]])
+    >>> x = np.array([[1,2,3],[4,5,6]])
     >>> x
     array([[1, 2, 3],
           [4, 5, 6]])
@@ -1637,7 +1637,7 @@
 
     Examples
     --------
-    >>> x = array([[1,2],[3,4]])
+    >>> x = np.array([[1,2],[3,4]])
     >>> x.repeat(2)
     array([1, 1, 2, 2, 3, 3, 4, 4])
     >>> x.repeat(3, axis=1)
@@ -1725,10 +1725,10 @@
 
     Examples
     --------
-    >>> x = array([.5, 1.5, 2.5, 3.5, 4.5])
+    >>> x = np.array([.5, 1.5, 2.5, 3.5, 4.5])
     >>> x.round()
     array([ 0.,  2.,  2.,  4.,  4.])
-    >>> x = array([1,2,3,11])
+    >>> x = np.array([1,2,3,11])
     >>> x.round(decimals=1)
     array([ 1,  2,  3, 11])
     >>> x.round(decimals=-1)
@@ -1840,7 +1840,7 @@
 
     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)
     >>> x.squeeze().shape
@@ -1929,15 +1929,15 @@
 
     Examples
     --------
-    >>> array([0.5, 1.5]).sum()
+    >>> np.array([0.5, 1.5]).sum()
     2.0
-    >>> array([0.5, 1.5]).sum(dtype=int32)
+    >>> np.array([0.5, 1.5]).sum(dtype=np.int32)
     1
-    >>> array([[0, 1], [0, 5]]).sum(axis=0)
+    >>> np.array([[0, 1], [0, 5]]).sum(axis=0)
     array([0, 6])
-    >>> array([[0, 1], [0, 5]]).sum(axis=1)
+    >>> np.array([[0, 1], [0, 5]]).sum(axis=1)
     array([1, 5])
-    >>> ones(128, dtype=int8).sum(dtype=int8) # overflow!
+    >>> np.ones(128, dtype=np.int8).sum(dtype=np.int8) # overflow!
     -128
 
     Notes
@@ -2120,9 +2120,9 @@
 
     Examples
     --------
-    >>> eye(3).trace()
+    >>> np.eye(3).trace()
     3.0
-    >>> a = arange(8).reshape((2,2,2))
+    >>> a = np.arange(8).reshape((2,2,2))
     >>> a.trace()
     array([6, 8])
 
@@ -2139,7 +2139,7 @@
 
     Examples
     --------
-    >>> a = array([[1,2],[3,4]])
+    >>> a = np.array([[1,2],[3,4]])
     >>> a
     array([[1, 2],
            [3, 4]])

Modified: trunk/numpy/lib/financial.py
===================================================================
--- trunk/numpy/lib/financial.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/lib/financial.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -69,7 +69,7 @@
   an additional monthly savings of $100.  Assume the interest rate is
   5% (annually) compounded monthly?
 
->>> fv(0.05/12, 10*12, -100, -100)
+>>> np.fv(0.05/12, 10*12, -100, -100)
 15692.928894335748
 
 By convention, the negative sign represents cash flow out (i.e. money not
@@ -94,7 +94,7 @@
 What would the monthly payment need to be to pay off a $200,000 loan in 15
   years at an annual interest rate of 7.5%?
 
->>> pmt(0.075/12, 12*15, 200000)
+>>> np.pmt(0.075/12, 12*15, 200000)
 -1854.0247200054619
 
 In order to pay-off (i.e. have a future-value of 0) the $200,000 obtained
@@ -122,7 +122,7 @@
 If you only had $150 to spend as payment, how long would it take to pay-off
   a loan of $8,000 at 7% annual interest?
 
->>> nper(0.07/12, -150, 8000)
+>>> np.nper(0.07/12, -150, 8000)
 64.073348770661852
 
 So, over 64 months would be required to pay off the loan.
@@ -130,7 +130,7 @@
 The same analysis could be done with several different interest rates and/or
     payments and/or total amounts to produce an entire table.
 
->>> nper(*(ogrid[0.06/12:0.071/12:0.01/12, -200:-99:100, 6000:7001:1000]))
+>>> np.nper(*(np.ogrid[0.06/12:0.071/12:0.01/12, -200:-99:100, 6000:7001:1000]))
 array([[[ 32.58497782,  38.57048452],
         [ 71.51317802,  86.37179563]],
 

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/lib/function_base.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -471,7 +471,7 @@
 
     Examples
     --------
-      >>> average(range(1,11), weights=range(10,0,-1))
+      >>> np.average(range(1,11), weights=range(10,0,-1))
       4.0
 
     Raises
@@ -893,7 +893,7 @@
 
     Examples
     --------
-    >>> a = array((0, 0, 0, 1, 2, 3, 2, 1, 0))
+    >>> a = np.array((0, 0, 0, 1, 2, 3, 2, 1, 0))
     >>> np.trim_zeros(a)
     array([1, 2, 3, 2, 1])
 
@@ -1069,7 +1069,7 @@
     ...    else:
     ...        return a+b
 
-    >>> vfunc = vectorize(myfunc)
+    >>> vfunc = np.vectorize(myfunc)
 
     >>> vfunc([1, 2, 3, 4], 2)
     array([3, 4, 1, 2])
@@ -1486,29 +1486,28 @@
 
     Examples
     --------
-    >>> from numpy import median
     >>> a = np.array([[10, 7, 4], [3, 2, 1]])
     >>> a
     array([[10,  7,  4],
            [ 3,  2,  1]])
-    >>> median(a)
+    >>> np.median(a)
     array([ 6.5,  4.5,  2.5])
-    >>> median(a, axis=None)
+    >>> np.median(a, axis=None)
     3.5
-    >>> median(a, axis=1)
+    >>> np.median(a, axis=1)
     array([ 7.,  2.])
-    >>> m = median(a)
+    >>> m = np.median(a)
     >>> out = np.zeros_like(m)
-    >>> median(a, out=m)
+    >>> np.median(a, out=m)
     array([ 6.5,  4.5,  2.5])
     >>> m
     array([ 6.5,  4.5,  2.5])
     >>> b = a.copy()
-    >>> median(b, axis=1, overwrite_input=True)
+    >>> np.median(b, axis=1, overwrite_input=True)
     array([ 7.,  2.])
     >>> assert not np.all(a==b)
     >>> b = a.copy()
-    >>> median(b, axis=None, overwrite_input=True)
+    >>> np.median(b, axis=None, overwrite_input=True)
     3.5
     >>> assert not np.all(a==b)
     """
@@ -1632,11 +1631,11 @@
     ...       [1,2,3],
     ...       [6,7,8]]
 
-    >>> delete(arr, 1, 1)
+    >>> np.delete(arr, 1, 1)
     array([[3, 5],
            [1, 3],
            [6, 8]])
-    >>> delete(arr, 1, 0)
+    >>> np.delete(arr, 1, 0)
     array([[3, 4, 5],
            [6, 7, 8]])
     """
@@ -1732,11 +1731,11 @@
 
     Examples
     --------
-    >>> a = array([[1,2,3],
-    ...            [4,5,6],
-    ...            [7,8,9]])
+    >>> a = np.array([[1,2,3],
+    ...               [4,5,6],
+    ...               [7,8,9]])
 
-    >>> insert(a, [1,2], [[4],[5]], axis=0)
+    >>> np.insert(a, [1,2], [[4],[5]], axis=0)
     array([[1, 2, 3],
            [4, 4, 4],
            [4, 5, 6],

Modified: trunk/numpy/lib/io.py
===================================================================
--- trunk/numpy/lib/io.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/lib/io.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -344,9 +344,9 @@
 
     Examples
     --------
-    >>> savetxt('test.out', x, delimiter=',') # X is an array
-    >>> savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays
-    >>> savetxt('test.out', x, fmt='%1.4e') # use exponential notation
+    >>> np.savetxt('test.out', x, delimiter=',') # X is an array
+    >>> np.savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays
+    >>> np.savetxt('test.out', x, fmt='%1.4e') # use exponential notation
 
     Notes on fmt
     ------------

Modified: trunk/numpy/lib/polynomial.py
===================================================================
--- trunk/numpy/lib/polynomial.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/lib/polynomial.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -52,8 +52,8 @@
 
     Example:
 
-        >>> b = roots([1,3,1,5,6])
-        >>> poly(b)
+        >>> b = np.roots([1,3,1,5,6])
+        >>> np.poly(b)
         array([ 1.,  3.,  1.,  5.,  6.])
 
     """

Modified: trunk/numpy/lib/scimath.py
===================================================================
--- trunk/numpy/lib/scimath.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/lib/scimath.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -50,8 +50,8 @@
 
     >>> a = np.array([1,2,3],np.short)
 
-    >>> ac = _tocomplex(a); ac
-    array([ 1.+0.j,  2.+0.j,  3.+0.j], dtype=complex64)
+    >>> ac = np.lib.scimath._tocomplex(a); ac
+    array([ 1.+0.j,  2.+0.j,  3.+0.j], dtype=np.complex64)
 
     >>> ac.dtype
     dtype('complex64')
@@ -61,7 +61,7 @@
 
     >>> b = np.array([1,2,3],np.double)
 
-    >>> bc = _tocomplex(b); bc
+    >>> bc = np.lib.scimath._tocomplex(b); bc
     array([ 1.+0.j,  2.+0.j,  3.+0.j])
 
     >>> bc.dtype
@@ -72,7 +72,7 @@
 
     >>> c = np.array([1,2,3],np.csingle)
 
-    >>> cc = _tocomplex(c); cc
+    >>> cc = np.lib.scimath._tocomplex(c); cc
     array([ 1.+0.j,  2.+0.j,  3.+0.j], dtype=complex64)
 
     >>> c *= 2; c
@@ -102,10 +102,10 @@
 
     Examples
     --------
-    >>> _fix_real_lt_zero([1,2])
+    >>> np.lib.scimath._fix_real_lt_zero([1,2])
     array([1, 2])
 
-    >>> _fix_real_lt_zero([-1,2])
+    >>> np.lib.scimath._fix_real_lt_zero([-1,2])
     array([-1.+0.j,  2.+0.j])
     """
     x = asarray(x)
@@ -128,10 +128,10 @@
 
     Examples
     --------
-    >>> _fix_int_lt_zero([1,2])
+    >>> np.lib.scimath._fix_int_lt_zero([1,2])
     array([1, 2])
 
-    >>> _fix_int_lt_zero([-1,2])
+    >>> np.lib.scimath._fix_int_lt_zero([-1,2])
     array([-1.,  2.])
     """
     x = asarray(x)
@@ -154,10 +154,10 @@
 
     Examples
     --------
-    >>> _fix_real_abs_gt_1([0,1])
+    >>> np.lib.scimath._fix_real_abs_gt_1([0,1])
     array([0, 1])
 
-    >>> _fix_real_abs_gt_1([0,2])
+    >>> np.lib.scimath._fix_real_abs_gt_1([0,2])
     array([ 0.+0.j,  2.+0.j])
     """
     x = asarray(x)
@@ -180,17 +180,17 @@
     --------
 
     For real, non-negative inputs this works just like numpy.sqrt():
-    >>> sqrt(1)
+    >>> np.lib.scimath.sqrt(1)
     1.0
 
-    >>> sqrt([1,4])
+    >>> np.lib.scimath.sqrt([1,4])
     array([ 1.,  2.])
 
     But it automatically handles negative inputs:
-    >>> sqrt(-1)
+    >>> np.lib.scimath.sqrt(-1)
     (0.0+1.0j)
 
-    >>> sqrt([-1,4])
+    >>> np.lib.scimath.sqrt([-1,4])
     array([ 0.+1.j,  2.+0.j])
     """
     x = _fix_real_lt_zero(x)
@@ -213,14 +213,13 @@
     Examples
     --------
     >>> import math
-
-    >>> log(math.exp(1))
+    >>> np.lib.scimath.log(math.exp(1))
     1.0
 
     Negative arguments are correctly handled (recall that for negative
     arguments, the identity exp(log(z))==z does not hold anymore):
 
-    >>> log(-math.exp(1)) == (1+1j*math.pi)
+    >>> np.lib.scimath.log(-math.exp(1)) == (1+1j*math.pi)
     True
     """
     x = _fix_real_lt_zero(x)
@@ -246,11 +245,11 @@
     (We set the printing precision so the example can be auto-tested)
     >>> np.set_printoptions(precision=4)
 
-    >>> log10([10**1,10**2])
+    >>> np.lib.scimath.log10([10**1,10**2])
     array([ 1.,  2.])
 
 
-    >>> log10([-10**1,-10**2,10**2])
+    >>> np.lib.scimath.log10([-10**1,-10**2,10**2])
     array([ 1.+1.3644j,  2.+1.3644j,  2.+0.j    ])
     """
     x = _fix_real_lt_zero(x)
@@ -276,10 +275,10 @@
     (We set the printing precision so the example can be auto-tested)
     >>> np.set_printoptions(precision=4)
 
-    >>> logn(2,[4,8])
+    >>> np.lib.scimath.logn(2,[4,8])
     array([ 2.,  3.])
 
-    >>> logn(2,[-4,-8,8])
+    >>> np.lib.scimath.logn(2,[-4,-8,8])
     array([ 2.+4.5324j,  3.+4.5324j,  3.+0.j    ])
     """
     x = _fix_real_lt_zero(x)
@@ -306,10 +305,10 @@
     (We set the printing precision so the example can be auto-tested)
     >>> np.set_printoptions(precision=4)
 
-    >>> log2([4,8])
+    >>> np.lib.scimath.log2([4,8])
     array([ 2.,  3.])
 
-    >>> log2([-4,-8,8])
+    >>> np.lib.scimath.log2([-4,-8,8])
     array([ 2.+4.5324j,  3.+4.5324j,  3.+0.j    ])
     """
     x = _fix_real_lt_zero(x)
@@ -336,13 +335,13 @@
     (We set the printing precision so the example can be auto-tested)
     >>> np.set_printoptions(precision=4)
 
-    >>> power([2,4],2)
+    >>> np.lib.scimath.power([2,4],2)
     array([ 4, 16])
 
-    >>> power([2,4],-2)
+    >>> np.lib.scimath.power([2,4],-2)
     array([ 0.25  ,  0.0625])
 
-    >>> power([-2,4],2)
+    >>> np.lib.scimath.power([-2,4],2)
     array([  4.+0.j,  16.+0.j])
     """
     x = _fix_real_lt_zero(x)
@@ -368,10 +367,10 @@
     --------
     >>> np.set_printoptions(precision=4)
 
-    >>> arccos(1)
+    >>> np.lib.scimath.arccos(1)
     0.0
 
-    >>> arccos([1,2])
+    >>> np.lib.scimath.arccos([1,2])
     array([ 0.-0.j   ,  0.+1.317j])
     """
     x = _fix_real_abs_gt_1(x)
@@ -397,10 +396,10 @@
     (We set the printing precision so the example can be auto-tested)
     >>> np.set_printoptions(precision=4)
 
-    >>> arcsin(0)
+    >>> np.lib.scimath.arcsin(0)
     0.0
 
-    >>> arcsin([0,1])
+    >>> np.lib.scimath.arcsin([0,1])
     array([ 0.    ,  1.5708])
     """
     x = _fix_real_abs_gt_1(x)
@@ -426,10 +425,10 @@
     (We set the printing precision so the example can be auto-tested)
     >>> np.set_printoptions(precision=4)
 
-    >>> arctanh(0)
+    >>> np.lib.scimath.arctanh(0)
     0.0
 
-    >>> arctanh([0,2])
+    >>> np.lib.scimath.arctanh([0,2])
     array([ 0.0000+0.j    ,  0.5493-1.5708j])
     """
     x = _fix_real_abs_gt_1(x)

Modified: trunk/numpy/lib/shape_base.py
===================================================================
--- trunk/numpy/lib/shape_base.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/lib/shape_base.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -192,13 +192,13 @@
             tup -- sequence of arrays.  All arrays must have the same
                    shape.
         Examples:
-            >>> a = array((1,2,3))
-            >>> b = array((2,3,4))
+            >>> a = np.array((1,2,3))
+            >>> b = np.array((2,3,4))
             >>> np.vstack((a,b))
             array([[1, 2, 3],
                    [2, 3, 4]])
-            >>> a = array([[1],[2],[3]])
-            >>> b = array([[2],[3],[4]])
+            >>> a = np.array([[1],[2],[3]])
+            >>> b = np.array([[2],[3],[4]])
             >>> np.vstack((a,b))
             array([[1],
                    [2],
@@ -222,14 +222,13 @@
             tup -- sequence of arrays.  All arrays must have the same
                    shape.
         Examples:
-            >>> import numpy
-            >>> a = array((1,2,3))
-            >>> b = array((2,3,4))
-            >>> numpy.hstack((a,b))
+            >>> a = np.array((1,2,3))
+            >>> b = np.array((2,3,4))
+            >>> np.hstack((a,b))
             array([1, 2, 3, 2, 3, 4])
-            >>> a = array([[1],[2],[3]])
-            >>> b = array([[2],[3],[4]])
-            >>> numpy.hstack((a,b))
+            >>> a = np.array([[1],[2],[3]])
+            >>> b = np.array([[2],[3],[4]])
+            >>> np.hstack((a,b))
             array([[1, 2],
                    [2, 3],
                    [3, 4]])
@@ -253,10 +252,9 @@
             tup -- sequence of 1D or 2D arrays.  All arrays must have the same
                    first dimension.
         Examples:
-            >>> import numpy
-            >>> a = array((1,2,3))
-            >>> b = array((2,3,4))
-            >>> numpy.column_stack((a,b))
+            >>> a = np.array((1,2,3))
+            >>> b = np.array((2,3,4))
+            >>> np.column_stack((a,b))
             array([[1, 2],
                    [2, 3],
                    [3, 4]])
@@ -283,16 +281,15 @@
         tup -- sequence of arrays.  All arrays must have the same
                shape.
     Examples:
-        >>> import numpy
-        >>> a = array((1,2,3))
-        >>> b = array((2,3,4))
-        >>> numpy.dstack((a,b))
+        >>> a = np.array((1,2,3))
+        >>> b = np.array((2,3,4))
+        >>> np.dstack((a,b))
         array([[[1, 2],
                 [2, 3],
                 [3, 4]]])
-        >>> a = array([[1],[2],[3]])
-        >>> b = array([[2],[3],[4]])
-        >>> numpy.dstack((a,b))
+        >>> a = np.array([[1],[2],[3]])
+        >>> b = np.array([[2],[3],[4]])
+        >>> np.dstack((a,b))
         array([[[1, 2]],
         <BLANKLINE>
                [[2, 3]],
@@ -432,12 +429,11 @@
         Related:
             hstack, split, array_split, vsplit, dsplit.
         Examples:
-            >>> import numpy
-            >>> a= array((1,2,3,4))
-            >>> numpy.hsplit(a,2)
+            >>> a= np.array((1,2,3,4))
+            >>> np.hsplit(a,2)
             [array([1, 2]), array([3, 4])]
-            >>> a = array([[1,2,3,4],[1,2,3,4]])
-            >>> hsplit(a,2)
+            >>> a = np.array([[1,2,3,4],[1,2,3,4]])
+            >>> np.hsplit(a,2)
             [array([[1, 2],
                    [1, 2]]), array([[3, 4],
                    [3, 4]])]
@@ -482,9 +478,9 @@
             vstack, split, array_split, hsplit, dsplit.
         Examples:
             import numpy
-            >>> a = array([[1,2,3,4],
-            ...            [1,2,3,4]])
-            >>> numpy.vsplit(a,2)
+            >>> a = np.array([[1,2,3,4],
+            ...              [1,2,3,4]])
+            >>> np.vsplit(a,2)
             [array([[1, 2, 3, 4]]), array([[1, 2, 3, 4]])]
 
     """
@@ -519,8 +515,8 @@
         Related:
             dstack, split, array_split, hsplit, vsplit.
         Examples:
-            >>> a = array([[[1,2,3,4],[1,2,3,4]]])
-            >>> dsplit(a,2)
+            >>> a = np.array([[[1,2,3,4],[1,2,3,4]]])
+            >>> np.dsplit(a,2)
             [array([[[1, 2],
                     [1, 2]]]), array([[[3, 4],
                     [3, 4]]])]
@@ -596,15 +592,15 @@
 
 
     Examples:
-    >>> a = array([0,1,2])
-    >>> tile(a,2)
+    >>> a = np.array([0,1,2])
+    >>> np.tile(a,2)
     array([0, 1, 2, 0, 1, 2])
-    >>> tile(a,(1,2))
+    >>> np.tile(a,(1,2))
     array([[0, 1, 2, 0, 1, 2]])
-    >>> tile(a,(2,2))
+    >>> np.tile(a,(2,2))
     array([[0, 1, 2, 0, 1, 2],
            [0, 1, 2, 0, 1, 2]])
-    >>> tile(a,(2,1,2))
+    >>> np.tile(a,(2,1,2))
     array([[[0, 1, 2, 0, 1, 2]],
     <BLANKLINE>
            [[0, 1, 2, 0, 1, 2]]])

Modified: trunk/numpy/lib/twodim_base.py
===================================================================
--- trunk/numpy/lib/twodim_base.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/lib/twodim_base.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -88,13 +88,13 @@
 
     Examples
     --------
-      >>> diagflat([[1,2],[3,4]]])
+      >>> np.diagflat([[1,2],[3,4]])
       array([[1, 0, 0, 0],
              [0, 2, 0, 0],
              [0, 0, 3, 0],
              [0, 0, 0, 4]])
 
-      >>> diagflat([1,2], 1)
+      >>> np.diagflat([1,2], 1)
       array([[0, 1, 0],
              [0, 0, 2],
              [0, 0, 0]])
@@ -180,8 +180,8 @@
       - `xedges, yedges` : Arrays defining the bin edges.
 
     Example:
-      >>> x = random.randn(100,2)
-      >>> hist2d, xedges, yedges = histogram2d(x, bins = (6, 7))
+      >>> x = np.random.randn(100,2)
+      >>> hist2d, xedges, yedges = np.lib.histogram2d(x, bins = (6, 7))
 
     :SeeAlso: histogramdd
     """

Modified: trunk/numpy/linalg/linalg.py
===================================================================
--- trunk/numpy/linalg/linalg.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/linalg/linalg.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -163,18 +163,17 @@
 
     Examples
     --------
-    >>> from numpy import *
-    >>> a = eye(2*3*4)
+    >>> a = np.eye(2*3*4)
     >>> a.shape = (2*3,4,  2,3,4)
-    >>> b = random.randn(2*3,4)
-    >>> x = linalg.tensorsolve(a, b)
+    >>> b = np.random.randn(2*3,4)
+    >>> x = np.linalg.tensorsolve(a, b)
     >>> x.shape
     (2, 3, 4)
-    >>> allclose(tensordot(a, x, axes=3), b)
+    >>> np.allclose(np.tensordot(a, x, axes=3), b)
     True
 
     """
-    a = asarray(a)
+    a,wrap = _makearray(a)
     b = asarray(b)
     an = a.ndim
 
@@ -266,23 +265,22 @@
 
     Examples
     --------
-    >>> from numpy import *
-    >>> a = eye(4*6)
+    >>> a = np.eye(4*6)
     >>> a.shape = (4,6,8,3)
-    >>> ainv = linalg.tensorinv(a, ind=2)
+    >>> ainv = np.linalg.tensorinv(a, ind=2)
     >>> ainv.shape
     (8, 3, 4, 6)
-    >>> b = random.randn(4,6)
-    >>> allclose(tensordot(ainv, b), linalg.tensorsolve(a, b))
+    >>> b = np.random.randn(4,6)
+    >>> np.allclose(np.tensordot(ainv, b), np.linalg.tensorsolve(a, b))
     True
 
-    >>> a = eye(4*6)
+    >>> a = np.eye(4*6)
     >>> a.shape = (24,8,3)
-    >>> ainv = linalg.tensorinv(a, ind=1)
+    >>> ainv = np.linalg.tensorinv(a, ind=1)
     >>> ainv.shape
     (8, 3, 24)
-    >>> b = random.randn(24)
-    >>> allclose(tensordot(ainv, b, 1), linalg.tensorsolve(a, b))
+    >>> b = np.random.randn(24)
+    >>> np.allclose(np.tensordot(ainv, b, 1), np.linalg.tensorsolve(a, b))
     True
     """
     a = asarray(a)
@@ -318,12 +316,11 @@
 
     Examples
     --------
-    >>> from numpy import array, inv, dot
-    >>> a = array([[1., 2.], [3., 4.]])
-    >>> inv(a)
+    >>> a = np.array([[1., 2.], [3., 4.]])
+    >>> np.linalg.inv(a)
     array([[-2. ,  1. ],
            [ 1.5, -0.5]])
-    >>> dot(a, inv(a))
+    >>> np.dot(a, np.linalg.inv(a))
     array([[ 1.,  0.],
            [ 0.,  1.]])
 
@@ -360,7 +357,7 @@
     >>> L
     array([[ 1.+0.j,  0.+0.j],
            [ 0.+2.j,  1.+0.j]])
-    >>> dot(L, L.T.conj())
+    >>> np.dot(L, L.T.conj())
     array([[ 1.+0.j,  0.-2.j],
            [ 0.+2.j,  5.+0.j]])
 
@@ -427,16 +424,15 @@
 
     Examples
     --------
-    >>> from numpy import *
-    >>> a = random.randn(9, 6)
-    >>> q, r = linalg.qr(a)
-    >>> allclose(a, dot(q, r))
+    >>> a = np.random.randn(9, 6)
+    >>> q, r = np.linalg.qr(a)
+    >>> np.allclose(a, np.dot(q, r))
     True
-    >>> r2 = linalg.qr(a, mode='r')
-    >>> r3 = linalg.qr(a, mode='economic')
-    >>> allclose(r, r2)
+    >>> r2 = np.linalg.qr(a, mode='r')
+    >>> r3 = np.linalg.qr(a, mode='economic')
+    >>> np.allclose(r, r2)
     True
-    >>> allclose(r, triu(r3[:6,:6], k=0))
+    >>> np.allclose(r, np.triu(r3[:6,:6], k=0))
     True
 
     """
@@ -909,20 +905,20 @@
 
     Examples
     --------
-    >>> a = random.randn(9, 6) + 1j*random.randn(9, 6)
-    >>> U, s, Vh = linalg.svd(a)
+    >>> a = np.random.randn(9, 6) + 1j*np.random.randn(9, 6)
+    >>> U, s, Vh = np.linalg.svd(a)
     >>> U.shape, Vh.shape, s.shape
     ((9, 9), (6, 6), (6,))
 
-    >>> U, s, Vh = linalg.svd(a, full_matrices=False)
+    >>> U, s, Vh = np.linalg.svd(a, full_matrices=False)
     >>> U.shape, Vh.shape, s.shape
     ((9, 6), (6, 6), (6,))
-    >>> S = diag(s)
-    >>> allclose(a, dot(U, dot(S, Vh)))
+    >>> S = np.diag(s)
+    >>> np.allclose(a, np.dot(U, np.dot(S, Vh)))
     True
 
-    >>> s2 = linalg.svd(a, compute_uv=False)
-    >>> allclose(s, s2)
+    >>> s2 = np.linalg.svd(a, compute_uv=False)
+    >>> np.allclose(s, s2)
     True
     """
     a, wrap = _makearray(a)
@@ -1048,12 +1044,11 @@
 
     Examples
     --------
-    >>> from numpy import *
-    >>> a = random.randn(9, 6)
-    >>> B = linalg.pinv(a)
-    >>> allclose(a, dot(a, dot(B, a)))
+    >>> a = np.random.randn(9, 6)
+    >>> B = np.linalg.pinv(a)
+    >>> np.allclose(a, np.dot(a, np.dot(B, a)))
     True
-    >>> allclose(B, dot(B, dot(a, B)))
+    >>> np.allclose(B, np.dot(B, np.dot(a, B)))
     True
 
     """

Modified: trunk/numpy/ma/core.py
===================================================================
--- trunk/numpy/ma/core.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/ma/core.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -1694,7 +1694,7 @@
 
         Examples
         --------
-        >>> x = array([1,2,3,4,5], mask=[0,0,1,0,1], fill_value=-999)
+        >>> x = np.ma.array([1,2,3,4,5], mask=[0,0,1,0,1], fill_value=-999)
         >>> x.filled()
         array([1,2,-999,4,-999])
         >>> type(x.filled())
@@ -2116,10 +2116,10 @@
     
     Example
     -------
-    >>> array([1,2,3]).all()
+    >>> np.ma.array([1,2,3]).all()
     True
-    >>> a = array([1,2,3], mask=True)
-    >>> (a.all() is masked)
+    >>> a = np.ma.array([1,2,3], mask=True)
+    >>> (a.all() is np.ma.masked)
     True
 
         """
@@ -2293,7 +2293,7 @@
 
     Example
     -------
-    >>> print array(arange(10),mask=[0,0,0,1,1,1,0,0,0,0]).cumsum()
+    >>> print np.ma.array(np.arange(10), mask=[0,0,0,1,1,1,0,0,0,0]).cumsum()
     [0 1 3 -- -- -- 9 16 24 33]
 
 
@@ -2348,13 +2348,13 @@
 
     Examples
     --------
-    >>> prod([1.,2.])
+    >>> np.prod([1.,2.])
     2.0
-    >>> prod([1.,2.], dtype=int32)
+    >>> np.prod([1.,2.], dtype=np.int32)
     2
-    >>> prod([[1.,2.],[3.,4.]])
+    >>> np.prod([[1.,2.],[3.,4.]])
     24.0
-    >>> prod([[1.,2.],[3.,4.]], axis=1)
+    >>> np.prod([[1.,2.],[3.,4.]], axis=1)
     array([  2.,  12.])
 
     Notes
@@ -2755,7 +2755,7 @@
 
     Examples
     --------
-    >>> a = arange(6).reshape(2,3)
+    >>> a = np.arange(6).reshape(2,3)
     >>> a.argmax()
     5
     >>> a.argmax(0)

Modified: trunk/numpy/ma/extras.py
===================================================================
--- trunk/numpy/ma/extras.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/ma/extras.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -716,7 +716,7 @@
     """Translate slice objects to concatenation along the first axis.
 
     For example:
-        >>> mr_[array([1,2,3]), 0, 0, array([4,5,6])]
+        >>> np.ma.mr_[np.ma.array([1,2,3]), 0, 0, np.ma.array([4,5,6])]
         array([1, 2, 3, 0, 0, 4, 5, 6])
 
     """

Modified: trunk/numpy/testing/decorators.py
===================================================================
--- trunk/numpy/testing/decorators.py	2008-07-05 01:17:03 UTC (rev 5350)
+++ trunk/numpy/testing/decorators.py	2008-07-05 14:26:16 UTC (rev 5351)
@@ -30,6 +30,7 @@
         If True specifies this is a test, not a test otherwise
 
     e.g
+    >>> from numpy.testing.decorators import setastest
     >>> @setastest(False)
     ... def func_with_test_in_name(arg1, arg2): pass
     ...



More information about the Numpy-svn mailing list