From: <jd...@us...> - 2008-06-02 14:55:00
|
Revision: 5359 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5359&view=rev Author: jdh2358 Date: 2008-06-02 07:54:41 -0700 (Mon, 02 Jun 2008) Log Message: ----------- added dtype patch from sf 1980695 for mlab.load Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mlab.py Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2008-06-02 14:53:20 UTC (rev 5358) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-06-02 14:54:41 UTC (rev 5359) @@ -1200,7 +1200,7 @@ def load(fname,comments='#',delimiter=None, converters=None,skiprows=0, - usecols=None, unpack=False): + usecols=None, unpack=False, dtype=np.float_): """ Load ASCII data from fname into an array and return the array. @@ -1230,8 +1230,9 @@ a separator. converters, if not None, is a dictionary mapping column number to - a function that will convert that column to a float. Eg, if - column 0 is a date string: converters={0:datestr2num} + a function that will convert that column to a float (or the optional + dtype if specified). Eg, if column 0 is a date string: + converters={0:datestr2num} skiprows is the number of rows from the top to skip @@ -1245,6 +1246,8 @@ t,y = load('test.dat', unpack=True) # for two column data x,y,z = load('somefile.dat', usecols=(3,5,7), unpack=True) + dtype, the array will have this dtype. default: numpy.float_ + See examples/load_demo.py which exeercises many of these options. """ @@ -1270,7 +1273,7 @@ converterseq = [converters.get(j,float) for j,val in enumerate(splitfunc(line))] if usecols is not None: - vals = line.split(delimiter) + vals = splitfunc(line) row = [converterseq[j](vals[j]) for j in usecols] else: row = [converterseq[j](val) @@ -1278,7 +1281,7 @@ thisLen = len(row) X.append(row) - X = np.array(X, np.float_) + X = np.array(X, dtype) r,c = X.shape if r==1 or c==1: X.shape = max(r,c), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |