@@ -442,8 +442,9 @@ def corrcoef(*args):
442442 kw = dict (rowvar = False )
443443 return npy .corrcoef (* args , ** kw )
444444
445- def polyfit (x , y , N ):
445+ def polyfit (* args , ** kwargs ):
446446 """
447+ def polyfit(x,y,N)
447448
448449 Do a best fit polynomial of order N of y to x. Return value is a
449450 vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2
@@ -480,21 +481,13 @@ def polyfit(x,y,N):
480481 See also polyval
481482
482483 """
483- x = npy .asarray (x , dtype = npy .float_ )
484- #y = npy.asarray(y, dtype=npy.float_)
485- #y.shape = (len(y),1)
486- #X = npy.matrix(npy.vander(x, N+1))
487- #Xt = npy.matrix(X.transpose())
488- #c = npy.array(npy.linalg.inv(Xt*X)*Xt*y) # convert back to array
489- #c.shape = (N+1,)
490- #return c
491- X = npy .vander (x , N + 1 )
492- return npy .linalg .lstsq (X , y )[0 ]
484+ warnings .warn ("use numpy.poyfit" , DeprecationWarning )
485+ return npy .polyfit (* args , ** kw )
493486
494487
495488
496489
497- def polyval (p , x ):
490+ def polyval (* args , ** kwargs ):
498491 """
499492 y = polyval(p,x)
500493
@@ -510,14 +503,11 @@ def polyval(p,x):
510503 See also polyfit
511504
512505 """
513- x = npy .asarray (x , dtype = npy .float_ )
514- p = npy .asarray (p , dtype = npy .float_ ).reshape ((len (p ),1 ))
515- X = npy .vander (x ,len (p ))
516- y = npy .dot (X ,p )
517- return y .reshape (x .shape )
506+ warnings .warn ("use numpy.polyval" , DeprecationWarning )
507+ return npy .polyval (* args , ** kw )
518508
519509
520- def vander (x , N = None ):
510+ def vander (* args , ** kwargs ):
521511 """
522512 X = vander(x,N=None)
523513
@@ -527,7 +517,7 @@ def vander(x,N=None):
527517
528518 """
529519 warnings .warn ("Use numpy.vander()" , DeprecationWarning )
530- return npy .vander (x , N )
520+ return npy .vander (* args , ** kwargs )
531521
532522
533523def donothing_callback (* args ):
@@ -1262,20 +1252,31 @@ def load(fname,comments='#',delimiter=None, converters=None,skiprows=0,
12621252 fh = cbook .to_filehandle (fname )
12631253 X = []
12641254
1255+ if delimiter == ' ' :
1256+ # space splitting is a special case since x.split() is what
1257+ # you want, not x.split(' ')
1258+ def splitfunc (x ):
1259+ return x .split ()
1260+ else :
1261+ def splitfunc (x ):
1262+ return x .split (delimiter )
1263+
1264+
1265+
12651266 converterseq = None
12661267 for i ,line in enumerate (fh ):
12671268 if i < skiprows : continue
12681269 line = line .split (comments , 1 )[0 ].strip ()
12691270 if not len (line ): continue
12701271 if converterseq is None :
12711272 converterseq = [converters .get (j ,float )
1272- for j ,val in enumerate (line . split ( delimiter ))]
1273+ for j ,val in enumerate (splitfunc ( line ))]
12731274 if usecols is not None :
12741275 vals = line .split (delimiter )
12751276 row = [converterseq [j ](vals [j ]) for j in usecols ]
12761277 else :
12771278 row = [converterseq [j ](val )
1278- for j ,val in enumerate (line . split ( delimiter ))]
1279+ for j ,val in enumerate (splitfunc ( line ))]
12791280 thisLen = len (row )
12801281 X .append (row )
12811282
@@ -2281,7 +2282,7 @@ def __init__(self, precision=4):
22812282 FormatFloat .__init__ (self , precision , scale = 1e-6 )
22822283
22832284
2284- class FormatDate (FormatString ):
2285+ class FormatDate (FormatObj ):
22852286 def __init__ (self , fmt ):
22862287 self .fmt = fmt
22872288
@@ -2301,7 +2302,7 @@ def __init__(self, fmt='%Y-%m-%d %H:%M:%S'):
23012302 npy .float32 : FormatFloat (),
23022303 npy .float64 : FormatFloat (),
23032304 npy .object_ : FormatObj (),
2304- npy .string_ : FormatString (),
2305+ npy .string_ : FormatObj (),
23052306 }
23062307
23072308def get_formatd (r , formatd = None ):
@@ -2658,15 +2659,21 @@ def foreach(model, path, iter, selected):
26582659
26592660
26602661
2661- def rec2gtk (r , formatd = None , rownum = 0 ):
2662+ def rec2gtk (r , formatd = None , rownum = 0 , autowin = True ):
26622663 """
26632664 save record array r to excel pyExcelerator worksheet ws
26642665 starting at rownum. if ws is string like, assume it is a
26652666 filename and save to it
26662667
26672668 formatd is a dictionary mapping dtype name -> FormatXL instances
26682669
2669- The next rownum after writing is returned
2670+ This function creates a SortedStringsScrolledWindow (derived
2671+ from gtk.ScrolledWindow) and returns it. if autowin is True,
2672+ a gtk.Window is created, attached to the
2673+ SortedStringsScrolledWindow instance, shown and returned. If
2674+ autowin=False, the caller is responsible for adding the
2675+ SortedStringsScrolledWindow instance to a gtk widget and
2676+ showing it.
26702677 """
26712678
26722679
@@ -2692,6 +2699,14 @@ def rec2gtk(r, formatd=None, rownum=0):
26922699 for row in r :
26932700 scroll .add_row (row )
26942701
2702+
2703+ if autowin :
2704+ win = gtk .Window ()
2705+ win .set_default_size (800 ,600 )
2706+ win .add (scroll )
2707+ win .show_all ()
2708+ scroll .win = win
2709+
26952710 return scroll
26962711
26972712
0 commit comments