def MakePlot(details, final, counts, pickVects, nModels, nTrueActs=-1): if not hasattr(details, 'plotFile') or not details.plotFile: return dataFileName = '%s.dat' % (details.plotFile) outF = open(dataFileName, 'w+') i = 0 while i < len(final) and counts[i] != 0: if nModels > 1: _, sd = Stats.MeanAndDev(pickVects[i]) confInterval = Stats.GetConfidenceInterval(sd, len(pickVects[i]), level=90) outF.write('%d %f %f %d %f\n' % (i + 1, final[i][0] / counts[i], final[i][1] / counts[i], counts[i], confInterval)) else: outF.write('%d %f %f %d\n' % (i + 1, final[i][0] / counts[i], final[i][1] / counts[i], counts[i])) i += 1 outF.close() plotFileName = '%s.gnu' % (details.plotFile) gnuF = open(plotFileName, 'w+') gnuHdr = """# Generated by EnrichPlot.py version: %s set size square 0.7 set xr [0:] set data styl points set ylab 'Num Correct Picks' set xlab 'Num Picks' set grid set nokey set term postscript enh color solid "Helvetica" 16 set term X """ % (__VERSION_STRING) print(gnuHdr, file=gnuF) if nTrueActs > 0: print('set yr [0:%d]' % nTrueActs, file=gnuF) print('plot x with lines', file=gnuF) if nModels > 1: everyGap = i / 20 print('replot "%s" using 1:2 with lines,' % (dataFileName), end='', file=gnuF) print('"%s" every %d using 1:2:5 with yerrorbars' % (dataFileName, everyGap), file=gnuF) else: print('replot "%s" with points' % (dataFileName), file=gnuF) gnuF.close() if hasattr(details, 'showPlot') and details.showPlot: try: from Gnuplot import Gnuplot p = Gnuplot() p('load "%s"' % (plotFileName)) input('press return to continue...\n') except Exception: import traceback traceback.print_exc()
def send_line_break(self): if self.lineHeight: self.y = self.y + self.lineHeight self.oldLineHeight = self.lineHeight self.lineHeight = 0 self.x = self.indent self.atbreak = 0 if TRACE: input('lb')
def demo(html=DEMO_HTML): while 1: print('Demo of HTMLPiddler.py') print(' 1. piddlePDF') print(' 2. piddlePIL') #print(' 3. piddleTK') #print(' 4. piddleWX') print(' 0. EXIT') sel = input('Enter Selection Number: ') try: sel = int(sel.strip()) except Exception: sel = -1 if (sel == 0): break elif (sel == 1): demoPDF(html) elif (sel == 2): demoPIL(html) elif (sel == 3): demoTK(html) elif (sel == 4): demoWX(html)
def mainLoop(): global tests, backends backend = None test = None while 1: # print backends on left, tests on right, indicate chosen one of each i = 0 while i < len(backends) or i < len(tests): try: bstr = str(i + 1) + '. ' + backends[i] except Exception: bstr = '' try: tstr = chr(65 + i) + '. ' + tests[i].__name__ except Exception: tstr = '' if i == backend: bflag = '==>' else: bflag = '' if i == test: tflag = '==>' else: tflag = '' print("%10s %-20s %10s %-20s" % (bflag, bstr, tflag, tstr)) i = i + 1 print() inp = input("Selection (0 to exit): ") print() if inp == '0': return if inp: testinp = '' if inp[-1] in LETTERS: testinp = inp[-1] elif inp[0] in LETTERS: testinp = inp[0] backinp = ' '.join(filter(lambda x: x in '0123456789', inp)) if backinp: backend = int(backinp) - 1 if backend < len(backends): docstr = __import__('sping.' + backends[backend], globals(), locals(), backends[backend]).__doc__ #docstr = __import__('sping.'+backends[backend]).__doc__ if docstr: print(docstr) else: print("<no doc string>") else: backend = None if testinp: test = ord(testinp[0].upper()) - ord('A') if test >= 0 and test < len(tests): docstr = tests[test].__doc__ if docstr: print(docstr) else: test = None print # now, if we have a valid backend and test, run it if backend != None and test != None: runtest(backends[backend], tests[test])