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

numpy-svn@scip... numpy-svn@scip...
Tue Jul 1 20:15:14 CDT 2008


Author: alan.mcintyre
Date: 2008-07-01 20:15:06 -0500 (Tue, 01 Jul 2008)
New Revision: 5330

Modified:
   trunk/numpy/core/arrayprint.py
   trunk/numpy/core/defmatrix.py
   trunk/numpy/core/memmap.py
   trunk/numpy/core/numeric.py
   trunk/numpy/core/records.py
Log:
Update doctests to use the implicit "import numpy as np" made available 
to all doctests.


Modified: trunk/numpy/core/arrayprint.py
===================================================================
--- trunk/numpy/core/arrayprint.py	2008-07-01 22:01:09 UTC (rev 5329)
+++ trunk/numpy/core/arrayprint.py	2008-07-02 01:15:06 UTC (rev 5330)
@@ -218,9 +218,8 @@
     Examples
     --------
 
-    >>> import numpy as N
-    >>> x = N.array([1e-16,1,2,3])
-    >>> print array2string(x,precision=2,separator=',',suppress_small=True)
+    >>> x = np.array([1e-16,1,2,3])
+    >>> print np.core.array2string(x,precision=2,separator=',',suppress_small=True)
     [ 0., 1., 2., 3.]
 
     """

Modified: trunk/numpy/core/defmatrix.py
===================================================================
--- trunk/numpy/core/defmatrix.py	2008-07-01 22:01:09 UTC (rev 5329)
+++ trunk/numpy/core/defmatrix.py	2008-07-02 01:15:06 UTC (rev 5330)
@@ -84,8 +84,7 @@
 
     Examples
     --------
-    >>> from numpy import array
-    >>> matrix_power(array([[0,1],[-1,0]]),10)
+    >>> np.linalg.matrix_power(np.array([[0,1],[-1,0]]),10)
     array([[-1,  0],
            [ 0, -1]])
     """
@@ -149,7 +148,6 @@
 
     Examples
     --------
-    >>> import numpy as np
     >>> a = np.matrix('1 2; 3 4')
     >>> print a
     [[1 2]

Modified: trunk/numpy/core/memmap.py
===================================================================
--- trunk/numpy/core/memmap.py	2008-07-01 22:01:09 UTC (rev 5329)
+++ trunk/numpy/core/memmap.py	2008-07-02 01:15:06 UTC (rev 5330)
@@ -67,7 +67,6 @@
 
     Examples
     --------
-    >>> import numpy as np
     >>> data = np.arange(12, dtype='float32')
     >>> data.resize((3,4))
 

Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py	2008-07-01 22:01:09 UTC (rev 5329)
+++ trunk/numpy/core/numeric.py	2008-07-02 01:15:06 UTC (rev 5330)
@@ -214,8 +214,7 @@
     is a sequence of indices into a.  This sequence must be
     converted to a tuple in order to be used to index into a.
 
-    >>> from numpy import ones, argwhere
-    >>> argwhere(ones((2, 2)))
+    >>> np.argwhere(np.ones((2, 2)))
     array([[0, 0],
            [0, 1],
            [1, 0],
@@ -228,10 +227,9 @@
 
     Equivalent to a.ravel().nonzero()[0]
 
-    >>> from numpy import arange, flatnonzero
-    >>> arange(-2, 3)
+    >>> np.arange(-2, 3)
     array([-2, -1,  0,  1,  2])
-    >>> flatnonzero(arange(-2, 3))
+    >>> np.flatnonzero(np.arange(-2, 3))
     array([0, 1, 3, 4])
     """
     return a.ravel().nonzero()[0]
@@ -385,10 +383,9 @@
     """Roll the elements in the array by 'shift' positions along
     the given axis.
 
-    >>> from numpy import roll
-    >>> arange(10)
+    >>> np.arange(10)
     array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
-    >>> roll(arange(10), 2)
+    >>> np.roll(np.arange(10), 2)
     array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7])
     """
     a = asanyarray(a)
@@ -409,13 +406,12 @@
 def rollaxis(a, axis, start=0):
     """Return transposed array so that axis is rolled before start.
 
-    >>> from numpy import ones, rollaxis
-    >>> a = ones((3,4,5,6))
-    >>> rollaxis(a, 3, 1).shape
+    >>> a = np.ones((3,4,5,6))
+    >>> np.rollaxis(a, 3, 1).shape
     (3, 6, 4, 5)
-    >>> rollaxis(a, 2, 0).shape
+    >>> np.rollaxis(a, 2, 0).shape
     (5, 3, 4, 6)
-    >>> rollaxis(a, 1, 4).shape
+    >>> np.rollaxis(a, 1, 4).shape
     (3, 5, 6, 4)
     """
     n = a.ndim

Modified: trunk/numpy/core/records.py
===================================================================
--- trunk/numpy/core/records.py	2008-07-01 22:01:09 UTC (rev 5329)
+++ trunk/numpy/core/records.py	2008-07-02 01:15:06 UTC (rev 5330)
@@ -347,11 +347,10 @@
                names=None, titles=None, aligned=False, byteorder=None):
     """ create a record array from a (flat) list of arrays
 
-    >>> import numpy as N
-    >>> x1=N.array([1,2,3,4])
-    >>> x2=N.array(['a','dd','xyz','12'])
-    >>> x3=N.array([1.1,2,3,4])
-    >>> r = fromarrays([x1,x2,x3],names='a,b,c')
+    >>> x1=np.array([1,2,3,4])
+    >>> x2=np.array(['a','dd','xyz','12'])
+    >>> x3=np.array([1.1,2,3,4])
+    >>> r = np.core.records.fromarrays([x1,x2,x3],names='a,b,c')
     >>> print r[1]
     (2, 'dd', 2.0)
     >>> x1[1]=34
@@ -515,8 +514,7 @@
     to be a file object.
 
     >>> from tempfile import TemporaryFile
-    >>> import numpy as N
-    >>> a = N.empty(10,dtype='f8,i4,a5')
+    >>> a = np.empty(10,dtype='f8,i4,a5')
     >>> a[5] = (0.5,10,'abcde')
     >>>
     >>> fd=TemporaryFile()
@@ -524,7 +522,7 @@
     >>> a.tofile(fd)
     >>>
     >>> fd.seek(0)
-    >>> r=fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<')
+    >>> r=np.fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<')
     >>> print r[5]
     (0.5, 10, 'abcde')
     >>> r.shape



More information about the Numpy-svn mailing list