[Spambayes-checkins] spambayes HistToGNU.py,1.3,1.4
Sjoerd Mullender
sjoerd@users.sourceforge.net
Thu, 26 Sep 2002 01:46:13 -0700
Update of /cvsroot/spambayes/spambayes
In directory usw-pr-cvs1:/tmp/cvs-serv18312
Modified Files:
HistToGNU.py
Log Message:
Converted \r\n line endings to \n.
Index: HistToGNU.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/HistToGNU.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** HistToGNU.py 24 Sep 2002 14:38:10 -0000 1.3
--- HistToGNU.py 26 Sep 2002 08:46:11 -0000 1.4
***************
*** 1,30 ****
! #! /usr/bin/env python
!
! """HistToGNU.py
!
! Convert saved binary pickle of histograms to gnu plot output
!
! Usage: %(program)s [options] [histogrampicklefile ...]
!
! reads pickle filename from options if not specified
!
! writes to stdout
- """
-
- globalOptions = """
- set grid
- set xtics 5
- set xrange [0.0:100.0]
- """
-
- dataSetOptions="smooth unique"
-
from Options import options
! from TestDriver import Hist
!
! import sys
import cPickle as pickle
!
program = sys.argv[0]
--- 1,30 ----
! #! /usr/bin/env python
!
! """HistToGNU.py
!
! Convert saved binary pickle of histograms to gnu plot output
!
! Usage: %(program)s [options] [histogrampicklefile ...]
!
! reads pickle filename from options if not specified
!
! writes to stdout
!
! """
!
! globalOptions = """
! set grid
! set xtics 5
! set xrange [0.0:100.0]
! """
!
! dataSetOptions="smooth unique"
from Options import options
! from TestDriver import Hist
!
! import sys
import cPickle as pickle
!
program = sys.argv[0]
***************
*** 36,67 ****
print >> sys.stderr, __doc__ % globals()
sys.exit(code)
!
! def loadHist(path):
! """Load the histogram pickle object"""
! return pickle.load(file(path))
!
! def outputHist(hist,f=sys.stdout):
! """Output the Hist object to file f"""
! for i in range(len(hist.buckets)):
! n = hist.buckets[i]
! if n:
! f.write("%.3f %d\n" % ( (100.0 * i) / hist.nbuckets, n))
!
! def plot(files):
! """given a list of files, create gnu-plot file"""
! import cStringIO, os
! cmd = cStringIO.StringIO()
! cmd.write(globalOptions)
! args = []
! for file in files:
! args.append("""'-' %s title "%s" """ % (dataSetOptions, file))
! cmd.write('plot %s\n' % ",".join(args))
! for file in files:
! outputHist(loadHist(file), cmd)
! cmd.write('e\n')
!
! cmd.write('pause 100\n')
! print cmd.getvalue()
!
def main():
import getopt
--- 36,67 ----
print >> sys.stderr, __doc__ % globals()
sys.exit(code)
!
! def loadHist(path):
! """Load the histogram pickle object"""
! return pickle.load(file(path))
!
! def outputHist(hist,f=sys.stdout):
! """Output the Hist object to file f"""
! for i in range(len(hist.buckets)):
! n = hist.buckets[i]
! if n:
! f.write("%.3f %d\n" % ( (100.0 * i) / hist.nbuckets, n))
!
! def plot(files):
! """given a list of files, create gnu-plot file"""
! import cStringIO, os
! cmd = cStringIO.StringIO()
! cmd.write(globalOptions)
! args = []
! for file in files:
! args.append("""'-' %s title "%s" """ % (dataSetOptions, file))
! cmd.write('plot %s\n' % ",".join(args))
! for file in files:
! outputHist(loadHist(file), cmd)
! cmd.write('e\n')
!
! cmd.write('pause 100\n')
! print cmd.getvalue()
!
def main():
import getopt
***************
*** 72,87 ****
except getopt.error, msg:
usage(1, msg)
!
! if not args and options.save_histogram_pickles:
! args = []
! for f in ('ham', 'spam'):
! fname = "%s_%shist.pik" % (options.pickle_basename, f)
! args.append(fname)
!
! if args:
! plot(args)
! else:
! print "could not locate any files to plot"
!
! if __name__ == "__main__":
! main()
--- 72,87 ----
except getopt.error, msg:
usage(1, msg)
!
! if not args and options.save_histogram_pickles:
! args = []
! for f in ('ham', 'spam'):
! fname = "%s_%shist.pik" % (options.pickle_basename, f)
! args.append(fname)
!
! if args:
! plot(args)
! else:
! print "could not locate any files to plot"
!
! if __name__ == "__main__":
! main()