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

numpy-svn@scip... numpy-svn@scip...
Sun Feb 18 14:34:38 CST 2007


Author: stefan
Date: 2007-02-18 14:34:30 -0600 (Sun, 18 Feb 2007)
New Revision: 3548

Modified:
   trunk/numpy/core/records.py
Log:
Fix numpy.core.records doctests.


Modified: trunk/numpy/core/records.py
===================================================================
--- trunk/numpy/core/records.py	2007-02-17 18:36:16 UTC (rev 3547)
+++ trunk/numpy/core/records.py	2007-02-18 20:34:30 UTC (rev 3548)
@@ -274,10 +274,10 @@
                names=None, titles=None, aligned=False, byteorder=None):
     """ create a record array from a (flat) list of arrays
 
-    >>> x1=array([1,2,3,4])
-    >>> x2=array(['a','dd','xyz','12'])
-    >>> x3=array([1.1,2,3,4])
-    >>> r=fromarrays([x1,x2,x3],names='a,b,c')
+    >>> 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')
     >>> print r[1]
     (2, 'dd', 2.0)
     >>> x1[1]=34
@@ -361,13 +361,11 @@
     >>> r.col1
     array([456,   2])
     >>> r.col2
-    chararray(['dbe', 'de'])
+    chararray(['dbe', 'de'], 
+          dtype='|S3')
     >>> import cPickle
     >>> print cPickle.loads(cPickle.dumps(r))
-    recarray[
-    (456, 'dbe', 1.2),
-    (2, 'de', 1.3)
-    ]
+    [(456, 'dbe', 1.2) (2, 'de', 1.3)]
     """
 
     nfields = len(recList[0])
@@ -442,17 +440,22 @@
     If file is a string then that file is opened, else it is assumed
     to be a file object.
 
-    >>> import testdata, sys
-    >>> fd=open(testdata.filename)
-    >>> fd.seek(2880*2)
-    >>> r=fromfile(fd, formats='f8,i4,a5', shape=3, byteorder='big')
-    >>> print r[0]
-    (5.1000000000000005, 61, 'abcde')
-    >>> r._shape
-    (3,)
+    >>> from tempfile import TemporaryFile
+    >>> a = N.empty(10,dtype='f8,i4,a5')
+    >>> a[5] = (0.5,10,'abcde')
+    >>>
+    >>> fd=TemporaryFile()
+    >>> a = a.newbyteorder('<')
+    >>> a.tofile(fd)
+    >>>
+    >>> fd.seek(0)
+    >>> r=fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<')
+    >>> print r[5]
+    (0.5, 10, 'abcde')
+    >>> r.shape
+    (10,)
     """
 
-
     if (shape is None or shape == 0):
         shape = (-1,)
     elif isinstance(shape, (int, long)):



More information about the Numpy-svn mailing list