class Window: def __init__(self, controller): self._window = tk.Tk() self._controller = controller # ustawianie parametrów okna self._window.title('Kasjer') self._window.iconbitmap('icon.ico') self._window.geometry('1000x550') bg = tk.PhotoImage(file='bg.gif') background_label = tk.Label(self._window, image=bg) background_label.place(x=0, y=0, relwidth=1, relheight=1) background_label.image = bg self.rightView = RightView(self._window, controller) self.leftView = LeftView(self._window, controller) self.summary = Summary(controller) def start(self): self._window.mainloop() def destroy(self): self._window.destroy() self.summary.start()
def to_summary(self): self.frame.grid_remove() self.label.set('SUMMARY') self.home_button.pack(side='right') self.run_button.pack(side='right') self.header.grid(row=0, column=0, columnspan=1, sticky='nsew') self.title.pack(side='left') self.summary = Summary(self.master, self.valves) self.frame = self.summary self.frame.grid(row=1, column=0)
def __init__(self, master): self.valves = self.get_valves() self.master = master self.master.configure(bg='sky blue') self.password = '******' self.momentary = Momentary(self.master, self.valves) self.edit = Edit(self.master, self.valves) self.summary = Summary(self.master, self.valves) self.preferences = Preferences(self.master, self.valves) self.run_screen = RunScreen(self.master, self.valves) self.header = self.make_header(self.master) self.home = self.home_page(self.master) self.frame = self.home
def get_stats(position, cards, betting): p1_contrib = 100 p2_contrib = 100 p1_pfr, p2_pfr, p1_vpip, p2_vpip = pfr_vpip(position, betting[0], p1_contrib, p2_contrib) amt, winner = amt_winner(position, betting[0], betting[1], [p1_contrib, p2_contrib], cards) # need to count the winner and the amount that they won!!! return Summary(p1_pfr, p2_pfr, p1_vpip, p2_vpip, amt, winner)
def main(): """Run the benchmark per arguments""" sum = Summary() options, args = getopt(sys.argv[1:], 'a:c:n:', ['list-projects', 'actions=', 'help', 'compiler=']) opt_actions = actions.default_actions set_compilers = [] opt_repeats = 1 for opt, optarg in options: if opt == '--help': show_help() return elif opt == '--list-projects': list_projects() return elif opt == '--actions' or opt == '-a': opt_actions = actions.parse_opt_actions(optarg) elif opt == '--compiler' or opt == '-c': set_compilers.append(compiler.parse_opt(optarg)) elif opt == '-n': opt_repeats = int(optarg) if not set_compilers: set_compilers = compiler.default_compilers() # Find named projects, or run all by default if args: chosen_projects = [find_project(name) for name in args] else: chosen_projects = trees.values() for proj in chosen_projects: proj.pre_actions(opt_actions) for comp in set_compilers: build = Build(proj, comp, opt_repeats) build.build_actions(opt_actions, sum) sum.print_table()
def main(): """Run the benchmark per arguments""" sum = Summary() options, args = getopt(sys.argv[1:], "a:c:n:", ["list-projects", "actions=", "help", "compiler="]) opt_actions = actions.default_actions set_compilers = [] opt_repeats = 1 for opt, optarg in options: if opt == "--help": show_help() return elif opt == "--list-projects": list_projects() return elif opt == "--actions" or opt == "-a": opt_actions = actions.parse_opt_actions(optarg) elif opt == "--compiler" or opt == "-c": set_compilers.append(compiler.parse_opt(optarg)) elif opt == "-n": opt_repeats = int(optarg) if not set_compilers: set_compilers = compiler.default_compilers() # Find named projects, or run all by default if args: chosen_projects = [find_project(name) for name in args] else: chosen_projects = trees.values() for proj in chosen_projects: proj.pre_actions(opt_actions) for comp in set_compilers: build = Build(proj, comp, opt_repeats) build.build_actions(opt_actions, sum) sum.print_table()
def main(): # create the pandas data frame for the training data df = pd.read_csv("artificial_intelligence.csv") # read the text from the pd dataframe and break into a list of sentences sentences = [] for s in df['article_text']: sentences.append(sent_tokenize(s)) # flatten list in to 1d list of sentences text = [y for x in sentences for y in x] summary = Summary(text, 10).summary print(summary)
def __init__(self): try: RootPanelCls.__init__(self) vpanel = VerticalPanel() self.menuBar = Menu() vpanel.add(self.menuBar) self.datePicker = DatePicker() vpanel.add(self.datePicker) self.timeGrid = TimeGrid() vpanel.add(self.timeGrid) self.summary = Summary() vpanel.add(self.summary) self.add(vpanel) except: raise
def get_summary(self, url): raw_html = self.simple_get(url) print(len(raw_html)) #Get article and summarize it html = self.get_html(str(raw_html)) article = self.get_article(html) title = self.get_title(html) if len(article.split(".")) > 40: summ = summarizer.summarize(self.unicodetoascii(article), ratio=0.1) else: summ = summarizer.summarize(self.unicodetoascii(article), ratio=0.2) summ = Summary(html, summ, self.unicodetoascii(title).title()) self.get_science_terms(summ) self.get_definitions(summ) return summ
RN.Select() return RN if __name__ == "__main__": #Self Test w = WordWrap() w.show() # w.addText('Line 1\n\n') # w.addText('Line 2\n\n') # w.addText('Line 3\n\n') # w.addText('Line 4\n\n') from Summary import Summary S = Summary(summaryTitle='Summary Title', subTitle='subtitle') S.addAssumption('Assume this is a test') S.addInput(label='Solar Flux', value=1.0, units='BTU/sqin', format='%g') S.addOutput(label='Tea Temperature', value=100.0, units='C', format='%g') summ = S sel = w.selectCharacter(1) w.changeEndSelection(-1) #T1 = w.wordApp.Selection.ConvertToTable() #w.wordDoc.Styles("Endnote Reference").Font.Size = 10 #w.wordDoc.Styles("Endnote Reference").Font.Name = "Courier New" #w.setAllTableCellStyle( Table=T1, StyleName="Endnote Reference")
class GUI: def __init__(self, master): self.valves = self.get_valves() self.master = master self.master.configure(bg='sky blue') self.password = '******' self.momentary = Momentary(self.master, self.valves) self.edit = Edit(self.master, self.valves) self.summary = Summary(self.master, self.valves) self.preferences = Preferences(self.master, self.valves) self.run_screen = RunScreen(self.master, self.valves) self.header = self.make_header(self.master) self.home = self.home_page(self.master) self.frame = self.home def make_header(self, master): header = Frame(master, bg='sky blue') self.label = StringVar() self.label.set('NONE') self.start_label = StringVar() self.start_label.set('START') self.lock_label = StringVar() self.lock_label.set('LOCKED') self.title = Label(header, textvariable=self.label, pady=20, font=('Lucida Console', 50)) self.title.config(bg='sky blue', fg='RoyalBlue4') self.run_image = PhotoImage(file="img/animate.png").subsample(x=5, y=5) self.run_button = Button(header, image=self.run_image, command=self.run, bg='SkyBlue4', activebackground='midnight blue', border=5) self.start_button = Button(header, textvariable=self.start_label, font=('Lucida Console', 30), command=self.start_stop, height=5) self.start_button.config(bg='brown3', activebackground='brown4', fg='white', activeforeground='white', width=10, border=5) self.save_image = PhotoImage(file="img/save.png").subsample(x=5, y=5) self.save_button = Button(header, image=self.save_image, command=self.save, bg='SkyBlue4', activebackground='midnight blue', border=5) self.save_button.config(state='disabled') self.reset_image = PhotoImage(file="img/reset.png").subsample(x=5, y=5) self.reset_button = Button(header, image=self.reset_image, command=self.reset, bg='SkyBlue4', activebackground='midnight blue', border=5) self.home_image = PhotoImage(file="img/home.png").subsample(x=5, y=5) self.home_button = Button(header, image=self.home_image, command=self.to_home, bg='SkyBlue4', activebackground='midnight blue', border=5) self.locked_image = PhotoImage(file="img/lock.png").subsample(x=5, y=5) self.unlocked_image = PhotoImage(file="img/unlock.png").subsample(x=5, y=5) self.lock_button = Button(header, image=self.locked_image, command=self.lock, bg='SkyBlue4', activebackground='midnight blue', border=5, textvariable=self.lock_label) return header def home_page(self, master): frame = Frame(master) frame.grid(row=0, column=0) image = PhotoImage(file="img/guido.gif") bg = Label(frame, image=image) bg.image = image bg.grid(row=0, column=0, rowspan=4, columnspan=2) index = 0 while index < 3: frame.grid_columnconfigure(index, minsize=200) frame.grid_rowconfigure(index, minsize=80) index += 1 summary_button = HomeButton(frame, self.to_summary, 'img/summary.png') summary_button.grid(row=0, column=0, sticky='w') edit_button = HomeButton(frame, self.to_edit, 'img/edit.png') edit_button.grid(row=0, column=1, sticky='e') momentary_button = HomeButton(frame, self.to_momentary, 'img/momentary.png') momentary_button.grid(row=1, column=0, sticky='w') preferences_button = HomeButton(frame, self.to_pref, 'img/preferences.png') preferences_button.grid(row=1, column=1, sticky='e') music = HomeButton(frame, self.to_summary, 'img/music.png') music.grid(row=2, column=0, sticky='w') info = HomeButton(frame, self.to_summary, 'img/info.png') info.grid(row=2, column=1, sticky='e') return frame # CSV file input def get_valves(self): valves = [Valve('VALVE 1', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 2', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 3', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 4', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 5', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 6', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 7', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 8', 'DEFAULT', 'Action A', 'Action B', [0, 0])] file = open('data.csv', 'rt', newline='') try: reader = csv.reader(file, lineterminator='\n') index = 0 for row in reader: if index == 0: index += 1 continue else: run = int(row[4]) delay = int(row[5]) interval = [run, delay] valves[index - 1] = Valve(row[0], row[1], row[2], row[3], interval) index += 1 finally: file.close() return valves def lock(self): if self.lock_label.get() == 'LOCKED': window = Toplevel() window.geometry('318x550') self.keypad = Keypad(window, self, self.password) else: self.save_button.config(state='disabled') self.edit.lock() self.preferences.lock() self.lock_label.set('LOCKED') self.lock_button.config(image=self.locked_image) def save(self): self.save_pref() self.save_edit() def save_edit(self): file = open('data.csv', 'w') interval = self.edit.get_intervals() try: writer = csv.writer(file, lineterminator='\n') writer.writerow(('Name', 'Setting', 'Action A', 'Action B', 'Runtime', 'Delaytime')) index = 0 for i in self.valves: i.set_interval([interval[index].get(), interval[index + 8].get()]) valve_interval = i.get_interval() if self.edit.plusInterval[index].cget('state') == 'disabled' and self.edit.motor[index].cget('state') != 'disabled': i.set_setting('MOTOR') writer.writerow((i.get_name().get(), i.get_setting(), i.get_action_a().get(), i.get_action_b().get(), 0, 0)) elif interval[index].get() is 0: i.set_setting('INACTIVE') writer.writerow((i.get_name().get(), i.get_setting(), 'NONE', 'NONE', 0, 0)) else: i.set_setting('DEFAULT') writer.writerow((i.get_name().get(), i.get_setting(), i.get_action_a().get(), i.get_action_b().get(), valve_interval[0], valve_interval[1])) index += 1 finally: file.close() # must fix def save_pref(self): index = 0 for i in self.valves: num = index * 3 if self.preferences.entry_field[num].get(): i.set_name(self.preferences.entry_field[num].get()) self.preferences.entry_field[num].delete(0, 'end') if self.preferences.entry_field[num + 1].get(): i.set_action_a(self.preferences.entry_field[num + 1].get()) self.preferences.entry_field[num + 1].delete(0, 'end') if self.preferences.entry_field[num + 2].get(): i.set_action_b(self.preferences.entry_field[num + 2].get()) self.preferences.entry_field[num + 2].delete(0, 'end') index += 1 def start_stop(self): if self.start_label.get() == 'START': self.start_label.set('STOP') self.master.update() self.run_screen.run_all(True) self.home_button.config(state='disabled') else: self.start_label.set('START') self.run_screen.run_all(False) self.home_button.config(state='normal') def run(self): self.summary.grid_remove() self.run_button.pack_forget() self.run_screen.make_frame() self.frame = self.run_screen self.frame.grid(row=0, column=0) self.header.grid(row=0, column=1) self.label.set('RUN') self.title.pack(side='top') self.start_button.pack() self.home_button.pack(side='bottom') def to_home(self): self.momentary.end_all() self.momentary.delete_frame() self.lock_button.pack_forget() self.run_button.pack_forget() self.save_button.pack_forget() self.reset_button.pack_forget() self.home_button.pack_forget() self.start_button.pack_forget() self.preferences.grid_remove() self.frame.grid_remove() self.header.grid_remove() self.frame = self.home self.frame.grid(row=0, column=0) def to_summary(self): self.frame.grid_remove() self.label.set('SUMMARY') self.home_button.pack(side='right') self.run_button.pack(side='right') self.header.grid(row=0, column=0, columnspan=1, sticky='nsew') self.title.pack(side='left') self.summary = Summary(self.master, self.valves) self.frame = self.summary self.frame.grid(row=1, column=0) def to_edit(self): self.frame.grid_remove() self.label.set('EDIT PROGRAM') self.header.grid(row=0, column=0, columnspan=1, sticky='nsew') self.home_button.pack(side='right') self.save_button.pack(side='right') self.lock_button.pack(side='right') self.reset_button.pack(side='right') self.title.pack(side='left') self.frame = self.edit self.frame.grid(row=1, column=0) def to_momentary(self): self.frame.grid_forget() self.label.set('MOMENTARY') self.header.grid(row=0, column=0, columnspan=12, sticky='ew') self.title.pack(side='left') self.home_button.pack(side='right') self.momentary.make_frame() def to_pref(self): self.frame.grid_remove() self.label.set('PREFERENCES') self.header.grid(row=0, column=0, columnspan=1, sticky='nsew') self.home_button.pack(side='right') self.save_button.pack(side='right') self.lock_button.pack(side='right') self.reset_button.pack(side='right') self.title.pack(side='left') self.frame = self.preferences self.frame.grid(row=1, column=0) def reset(self): self.master.quit() def access_granted(self): self.lock_label.set('UNLOCKED') self.lock_button.config(image=self.unlocked_image) self.save_button.config(state='normal') index = 0 while index < 8: self.edit.minusInterval[index].config(state='normal') self.edit.minusDelay[index].config(state='normal') self.edit.plusInterval[index].config(state='normal') self.edit.plusDelay[index].config(state='normal') self.edit.motor[index].config(state='normal') self.edit.adv[index].config(state='normal') index += 1 for each in self.preferences.entry_field: each.config(state='normal') self.edit.set_seconds() self.save_button.config(state='normal')
arcpy.AddMessage("!!!!!!!!!!Error tool not up to date!!!!!!!!!!") arcpy.AddMessage("Please download the latest version of the tool at") arcpy.AddMessage("http://www.sco.wisc.edu/parcels/tools/") arcpy.AddMessage("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") arcpy.AddMessage("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") exit() except Exception: arcpy.AddMessage("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") arcpy.AddMessage( "Check the change log at http://www.sco.wisc.edu/parcels/tools/") arcpy.AddMessage( "to make sure the latest version of the tool is installed before submitting" ) #Create summary object summary = Summary() base = os.path.dirname(os.path.abspath(__file__)) if inputDict['isSearchable'] == 'true': #Load files for current domain lists #streetNames = [line.strip() for line in open(os.path.join(base, '..\data\V3_StreetName_Simplified.txt'), 'r')] #street name list streetTypes = [ line.strip() for line in open( os.path.join(base, '..\data\V5_StreetType_Simplified.txt'), 'r') ] #street types domain list unitIdTypes = [ line.strip() for line in open( os.path.join(base, '..\data\V5_UnitId_Simplified.txt'), 'r') ] #unitid domain list
def close(self): self._tracked_month.save() summ = Summary.from_file(self._data_dir / 'Summary.csv') summ.update(data_dir=self._data_dir) summ.save()
def main(): """Run the benchmark per arguments""" # Ensure that stdout and stderr are line buffered, rather than # block buffered, as might be the default when running with # stdout/stderr redirected to a file; this ensures that the # output is prompt, even when the script takes a long time for # a single step, and it also avoids confusing intermingling of # stdout and stderr. sys.stdout = os.fdopen(1, "w", 1) sys.stderr = os.fdopen(2, "w", 1) sum = Summary() options, args = getopt(sys.argv[1:], 'a:c:n:f:', ['list-projects', 'actions=', 'help', 'compiler=', 'cc=', 'cxx=', 'output=', 'force=']) opt_actions = actions.default_actions opt_cc = 'cc' opt_cxx = 'c++' opt_output = None opt_compilers = [] opt_repeats = 1 opt_force = 1 for opt, optarg in options: if opt == '--help': show_help() return elif opt == '--list-projects': list_projects() return elif opt == '--actions' or opt == '-a': opt_actions = actions.parse_opt_actions(optarg) elif opt == '--cc': opt_cc = optarg elif opt == '--cxx': opt_cxx = optarg elif opt == '--output': opt_output = optarg elif opt == '--compiler' or opt == '-c': opt_compilers.append(optarg) elif opt == '-n': opt_repeats = int(optarg) elif opt == '-f' or opt == '--force': opt_force = int(optarg) if opt_compilers: set_compilers = [compiler.parse_compiler_opt(c, cc=opt_cc, cxx=opt_cxx) for c in opt_compilers] else: set_compilers = compiler.default_compilers(cc=opt_cc, cxx=opt_cxx) # Find named projects, or run all by default if args: chosen_projects = [find_project(name) for name in args] else: chosen_projects = trees.values() for proj in chosen_projects: # Ignore actions we did in a previous benchmark run, absent -f. # We only run the project's pre-actions if one of the builds # needs it because it hasn't successfully run 'configure' yet. project_actions, _ = actions.remove_unnecessary_actions( opt_actions, opt_force, proj.did_download(), 0) proj.pre_actions(project_actions) for comp in set_compilers: build = Build(proj, comp, opt_repeats) _, build_actions = actions.remove_unnecessary_actions( opt_actions, opt_force, proj.did_download(), build.did_configure()) build.build_actions(build_actions, sum) sum.print_table() # If --output was specified, print the table to the output-file too if opt_output: old_stdout = sys.stdout sys.stdout = open(opt_output, 'w') try: sum.print_table() finally: sys.stdout.close() sys.stdout = old_stdout
def __init__(self, subtaskName="simple model", taskName='System Study', controlRoutine=None, author="", constraintTolerance=0.001, probDesc=None, printFilePaths=False): """Inits ParametricSoln.""" if len(author)==0: author = 'anon' self.userOptions = _userOptions self.probDesc = probDesc self.author = author self.taskName = taskName self.constraintTolerance = constraintTolerance self.subtaskName = subtaskName self.desVarDict = LikeDict.LikeDict() #: dictionary of design Variables in system self.resultVarDict = LikeDict.LikeDict() #: dict of result variables in system self.feasibleVarList = [] #: list of Feasible Pairs self.minmaxVarList = [] #: list of MinMax Pairs self.constraintList = [] #: Optimize.optimize might initialize self.controlRoutine = controlRoutine #: will be called to set component design params self.optimizeHistoryL = [] #: holds any optimization summary info as [title, summStr] self.NumEvaluations = 0 #: count number of times the evaluate method is called # make text output file in case's subdirectory scriptName = os.path.split( sys.argv[0] )[-1] scriptPath = os.path.abspath(scriptName)[:] newDirPath = os.path.join( os.path.dirname( scriptPath ) , scriptName[:-3] ) if printFilePaths: print "scriptName:",scriptName print "scriptPath:",scriptPath print "newDirPath:",newDirPath if not os.path.isdir( newDirPath ): os.mkdir( newDirPath ) if printFilePaths: print "created new directory",newDirPath self.scriptName = scriptName self.outputPath = newDirPath self.summFileName = newDirPath + scriptName[:-2] + 'summary' # if multiple ParametricSoln objects, use same summFile if ParametricSoln.__firstParametricSoln: self.summFile = ParametricSoln.__firstParametricSoln.summFile else: self.summFile = open( self.summFileName, 'w' ) self.summFile.write(splashText + '\n\n' ) self.summFile.write( taskName + '\n by: '+author+'\n') self.summFile.write(' date: '+ time.strftime('%A %B %d, %Y')+'\n\n') # if multiple ParametricSoln objects, use same summaryObj if ParametricSoln.__firstParametricSoln: self.summaryObj = ParametricSoln.__firstParametricSoln.summaryObj else: self.summaryObj = Summary(summaryTitle=subtaskName, subTitle='system') # may not use it, but make Pickle file name just in case self.pickleFileName = os.path.join(newDirPath, scriptName[:-2] + 'pickle') # now make HTML file in original script's directory self.htmlFileName = os.path.join( os.path.dirname( scriptPath ), scriptName[:-2] + 'htm' ) if printFilePaths: print 'HTML file:',self.htmlFileName # if multiple ParametricSoln objects, use same htmlFile if ParametricSoln.__firstParametricSoln: self.htmlFile = ParametricSoln.__firstParametricSoln.htmlFile else: self.htmlFile = open( self.htmlFileName, 'w' ) # ============ if probDesc is input =================== # set any variables due to probDesc if probDesc: for a in ["subtaskName", "taskName", "author", "constraintTolerance"]: # if the probDesc attribute exists and has a value, assign it to self if hasattr(probDesc,a) and getattr(probDesc,a): setattr(self, a, getattr(probDesc,a) ) for row in probDesc.desVarL: self.addDesVars( row ) for row in probDesc.resVarL: self.addResultVars( row ) for name, row in probDesc.resVarLimitD.items(): print 'name, row=',name, row self.setResultVariableLimits( name=name, loLimit=row[0], hiLimit=row[1]) if probDesc.controlRoutine: self.setControlRoutine(probDesc.controlRoutine) self.htmlFile.write( HTML_supt.getHead(\ title=self.taskName, task=self.subtaskName, author=self.author, date=time.strftime('%B %d, %Y'), version='ParametricSoln v'+getVersion())) # ============ end of probDesc input =================== if self.userOptions.excel: # if multiple ParametricSoln objects, use same xlDoc if ParametricSoln.__firstParametricSoln: self.xlDoc = ParametricSoln.__firstParametricSoln.xlDoc else: if self.userOptions.show: self.xlDoc = Excel_wrapper.ExcelWrap(Visible=1) else: self.xlDoc = Excel_wrapper.ExcelWrap(Visible=0) self.xlSheetD = {} # make sure no sheet name duplicates self.xlDocName = os.path.join( os.path.dirname( scriptPath ), scriptName[:-2] + 'xls') self.xlSigText = self.subtaskName + '\rParametricSoln v'+getVersion() +\ '\rby: '+self.author +'\r' + time.strftime('%B %d, %Y') +\ '\r' + self.taskName if self.userOptions.ppt: # if multiple ParametricSoln objects, use same pptDoc if ParametricSoln.__firstParametricSoln: self.pptDoc = ParametricSoln.__firstParametricSoln.pptDoc else: self.pptDoc = PPT_wrapper.PPTwrap() if self.userOptions.show: self.pptDoc.show() self.pptDocName = os.path.join( os.path.dirname( scriptPath ), scriptName[:-2] + 'ppt') pptText = self.subtaskName + '\rParametricSoln v'+getVersion() +\ '\rby: '+self.author +'\r' + time.strftime('%B %d, %Y') self.pptDoc.addTextSlide( text=pptText, title=self.taskName) if self.userOptions.word: # if multiple ParametricSoln objects, use same wordDoc if ParametricSoln.__firstParametricSoln: self.wordDoc = ParametricSoln.__firstParametricSoln.wordDoc else: self.wordDoc = Word_wrapper.WordWrap() if self.userOptions.show: self.wordDoc.show() else: self.wordDoc.setFastOptions() self.wordDocName = os.path.join(os.path.dirname( scriptPath ), scriptName[:-2] + 'doc') self.wordDoc.addText(' ') tableStr = [(self.taskName,),(self.subtaskName, 'ParametricSoln v'+getVersion()), ('by: '+self.author, time.strftime('%B %d, %Y'))] wordTable1 = self.wordDoc.addTable( tableStr , Range=self.wordDoc.selectCharacter(-2), fullWidth=1 ) self.wordDoc.mergeRow( wordTable1, NRow=1) #self.wordDoc.mergeRow( wordTable1, NRow=2) self.wordDoc.setCellStyle(wordTable1,1,1, just='c',bold=True, fontSize=18, bgcolor='15') self.wordDoc.setCellStyle(wordTable1,2,2, just='r') self.wordDoc.setCellStyle(wordTable1,3,2, just='r') self.wordDoc.selectCharacter(-1) self.wordDoc.addText(' ') fontName = "Courier New" if self.userOptions.fontName.lower() == "t": fontName = "Lucida Sans Typewriter" if self.userOptions.fontName.lower() == "l": fontName = "Lucida Console" if self.userOptions.fontName.lower() == "v": fontName = "Bitstream Vera Sans Mono" if self.userOptions.fontName.lower() == "v": fontName = "OCR A Extended" self.tblstyl = self.wordDoc.createTableStyle( name='myStyle', font=fontName,size=8, borders=1, bold=0, keepTogether=1) self.wordDocImagefracPage=0.5 if self.userOptions.imageSize.lower() == 'vs': self.wordDocImagefracPage=0.3 if self.userOptions.imageSize.lower() == 's': self.wordDocImagefracPage=0.4 if self.userOptions.imageSize.lower() == 'm': self.wordDocImagefracPage=0.5 if self.userOptions.imageSize.lower() == 'l': self.wordDocImagefracPage=0.6 if self.userOptions.imageSize.lower() == 'vl': self.wordDocImagefracPage=0.8 # set flag to indicate that self.close() was not yet called self._close_was_called = 0 if ParametricSoln.__firstParametricSoln==None: ParametricSoln.__firstParametricSoln = self
class ParametricSoln(object): """ParaSol (Parametric Solutions) is a python framework in which mathematical models can be investigated parametrically. """ __firstParametricSoln = None #: use to keep track of 1st instance of ParametricSoln def getVersion(self): return getVersion() def __getitem__(self, name): '''return the value of design or result variable with name''' if self.hasDesignVar( name ): dv = self.desVarDict[name] return dv.val elif self.hasResultVar( name ): rv = self.resultVarDict[name] return rv.val else: return None def __setitem__(self, name, val): '''set the value of design or result variable with name''' if self.hasDesignVar( name ): self.setDesignVar(name, val) elif self.hasResultVar( name ): self.setResultVar(name, val) else: print 'ERROR in ParametricSoln.__setitem__, %s is not recognized'%name def __call__(self, *varNames): '''return the values of design and result variables in varNames list''' resultL = [] for name in varNames: if self.hasDesignVar( name ): dv = self.desVarDict[name] resultL.append( dv.val ) if self.hasResultVar( name ): rv = self.resultVarDict[name] resultL.append( rv.val ) if len(resultL)==1: return resultL[0] else: return resultL def __init__(self, subtaskName="simple model", taskName='System Study', controlRoutine=None, author="", constraintTolerance=0.001, probDesc=None, printFilePaths=False): """Inits ParametricSoln.""" if len(author)==0: author = 'anon' self.userOptions = _userOptions self.probDesc = probDesc self.author = author self.taskName = taskName self.constraintTolerance = constraintTolerance self.subtaskName = subtaskName self.desVarDict = LikeDict.LikeDict() #: dictionary of design Variables in system self.resultVarDict = LikeDict.LikeDict() #: dict of result variables in system self.feasibleVarList = [] #: list of Feasible Pairs self.minmaxVarList = [] #: list of MinMax Pairs self.constraintList = [] #: Optimize.optimize might initialize self.controlRoutine = controlRoutine #: will be called to set component design params self.optimizeHistoryL = [] #: holds any optimization summary info as [title, summStr] self.NumEvaluations = 0 #: count number of times the evaluate method is called # make text output file in case's subdirectory scriptName = os.path.split( sys.argv[0] )[-1] scriptPath = os.path.abspath(scriptName)[:] newDirPath = os.path.join( os.path.dirname( scriptPath ) , scriptName[:-3] ) if printFilePaths: print "scriptName:",scriptName print "scriptPath:",scriptPath print "newDirPath:",newDirPath if not os.path.isdir( newDirPath ): os.mkdir( newDirPath ) if printFilePaths: print "created new directory",newDirPath self.scriptName = scriptName self.outputPath = newDirPath self.summFileName = newDirPath + scriptName[:-2] + 'summary' # if multiple ParametricSoln objects, use same summFile if ParametricSoln.__firstParametricSoln: self.summFile = ParametricSoln.__firstParametricSoln.summFile else: self.summFile = open( self.summFileName, 'w' ) self.summFile.write(splashText + '\n\n' ) self.summFile.write( taskName + '\n by: '+author+'\n') self.summFile.write(' date: '+ time.strftime('%A %B %d, %Y')+'\n\n') # if multiple ParametricSoln objects, use same summaryObj if ParametricSoln.__firstParametricSoln: self.summaryObj = ParametricSoln.__firstParametricSoln.summaryObj else: self.summaryObj = Summary(summaryTitle=subtaskName, subTitle='system') # may not use it, but make Pickle file name just in case self.pickleFileName = os.path.join(newDirPath, scriptName[:-2] + 'pickle') # now make HTML file in original script's directory self.htmlFileName = os.path.join( os.path.dirname( scriptPath ), scriptName[:-2] + 'htm' ) if printFilePaths: print 'HTML file:',self.htmlFileName # if multiple ParametricSoln objects, use same htmlFile if ParametricSoln.__firstParametricSoln: self.htmlFile = ParametricSoln.__firstParametricSoln.htmlFile else: self.htmlFile = open( self.htmlFileName, 'w' ) # ============ if probDesc is input =================== # set any variables due to probDesc if probDesc: for a in ["subtaskName", "taskName", "author", "constraintTolerance"]: # if the probDesc attribute exists and has a value, assign it to self if hasattr(probDesc,a) and getattr(probDesc,a): setattr(self, a, getattr(probDesc,a) ) for row in probDesc.desVarL: self.addDesVars( row ) for row in probDesc.resVarL: self.addResultVars( row ) for name, row in probDesc.resVarLimitD.items(): print 'name, row=',name, row self.setResultVariableLimits( name=name, loLimit=row[0], hiLimit=row[1]) if probDesc.controlRoutine: self.setControlRoutine(probDesc.controlRoutine) self.htmlFile.write( HTML_supt.getHead(\ title=self.taskName, task=self.subtaskName, author=self.author, date=time.strftime('%B %d, %Y'), version='ParametricSoln v'+getVersion())) # ============ end of probDesc input =================== if self.userOptions.excel: # if multiple ParametricSoln objects, use same xlDoc if ParametricSoln.__firstParametricSoln: self.xlDoc = ParametricSoln.__firstParametricSoln.xlDoc else: if self.userOptions.show: self.xlDoc = Excel_wrapper.ExcelWrap(Visible=1) else: self.xlDoc = Excel_wrapper.ExcelWrap(Visible=0) self.xlSheetD = {} # make sure no sheet name duplicates self.xlDocName = os.path.join( os.path.dirname( scriptPath ), scriptName[:-2] + 'xls') self.xlSigText = self.subtaskName + '\rParametricSoln v'+getVersion() +\ '\rby: '+self.author +'\r' + time.strftime('%B %d, %Y') +\ '\r' + self.taskName if self.userOptions.ppt: # if multiple ParametricSoln objects, use same pptDoc if ParametricSoln.__firstParametricSoln: self.pptDoc = ParametricSoln.__firstParametricSoln.pptDoc else: self.pptDoc = PPT_wrapper.PPTwrap() if self.userOptions.show: self.pptDoc.show() self.pptDocName = os.path.join( os.path.dirname( scriptPath ), scriptName[:-2] + 'ppt') pptText = self.subtaskName + '\rParametricSoln v'+getVersion() +\ '\rby: '+self.author +'\r' + time.strftime('%B %d, %Y') self.pptDoc.addTextSlide( text=pptText, title=self.taskName) if self.userOptions.word: # if multiple ParametricSoln objects, use same wordDoc if ParametricSoln.__firstParametricSoln: self.wordDoc = ParametricSoln.__firstParametricSoln.wordDoc else: self.wordDoc = Word_wrapper.WordWrap() if self.userOptions.show: self.wordDoc.show() else: self.wordDoc.setFastOptions() self.wordDocName = os.path.join(os.path.dirname( scriptPath ), scriptName[:-2] + 'doc') self.wordDoc.addText(' ') tableStr = [(self.taskName,),(self.subtaskName, 'ParametricSoln v'+getVersion()), ('by: '+self.author, time.strftime('%B %d, %Y'))] wordTable1 = self.wordDoc.addTable( tableStr , Range=self.wordDoc.selectCharacter(-2), fullWidth=1 ) self.wordDoc.mergeRow( wordTable1, NRow=1) #self.wordDoc.mergeRow( wordTable1, NRow=2) self.wordDoc.setCellStyle(wordTable1,1,1, just='c',bold=True, fontSize=18, bgcolor='15') self.wordDoc.setCellStyle(wordTable1,2,2, just='r') self.wordDoc.setCellStyle(wordTable1,3,2, just='r') self.wordDoc.selectCharacter(-1) self.wordDoc.addText(' ') fontName = "Courier New" if self.userOptions.fontName.lower() == "t": fontName = "Lucida Sans Typewriter" if self.userOptions.fontName.lower() == "l": fontName = "Lucida Console" if self.userOptions.fontName.lower() == "v": fontName = "Bitstream Vera Sans Mono" if self.userOptions.fontName.lower() == "v": fontName = "OCR A Extended" self.tblstyl = self.wordDoc.createTableStyle( name='myStyle', font=fontName,size=8, borders=1, bold=0, keepTogether=1) self.wordDocImagefracPage=0.5 if self.userOptions.imageSize.lower() == 'vs': self.wordDocImagefracPage=0.3 if self.userOptions.imageSize.lower() == 's': self.wordDocImagefracPage=0.4 if self.userOptions.imageSize.lower() == 'm': self.wordDocImagefracPage=0.5 if self.userOptions.imageSize.lower() == 'l': self.wordDocImagefracPage=0.6 if self.userOptions.imageSize.lower() == 'vl': self.wordDocImagefracPage=0.8 # set flag to indicate that self.close() was not yet called self._close_was_called = 0 if ParametricSoln.__firstParametricSoln==None: ParametricSoln.__firstParametricSoln = self def __del__(self): if not self._close_was_called: self.close() def close(self): # set flag to show self.close() was called print 'Closing all open files' self._close_was_called = 1 self.htmlFile.write('<table class="mytable">') self.htmlFile.write('<tr><td nowrap>'+ '<pre>' + splash + '</pre>' ) self.htmlFile.write('</td><td width="90%"> </td></tr></table>') self.htmlFile.write( HTML_supt.getFooter() ) self.htmlFile.close() self.summFile.close() if self.userOptions.excel: if self.optimizeHistoryL: rs = [[' ']] for row in self.optimizeHistoryL: title, summStr = row def addText(text): text=text.replace('\r','\n') spL = text.split('\n') for s in spL: rs.append( [s] ) addText( title ) addText( summStr ) addText( '\n\n' ) sheetName="Optimization" if not self.xlSheetD.has_key(sheetName): print 'making excel sheet',sheetName self.xlSheetD[sheetName] = sheetName self.xlDoc.makeDataSheet( rs, sheetName=sheetName, autoFit=0, rowFormatL=None, textFont='Courier New', textFontSize=10) self.xlDoc.xlApp.ActiveWorkbook.SaveAs( self.xlDocName ) if not self.userOptions.open: self.xlDoc.close() if self.userOptions.ppt: self.pptDoc.saveAs( self.pptDocName ) if not self.userOptions.open: self.pptDoc.Quit() if self.userOptions.word: tableStr = [(splash,),] wordTable1 = self.wordDoc.addTable( tableStr, Range=self.wordDoc.selectCharacter(-2) , fullWidth=1) wordTable1.Style = self.tblstyl self.wordDoc.selectCharacter(-1) self.wordDoc.addText(' ') self.wordDoc.saveAs(self.wordDocName) if not self.userOptions.open: self.wordDoc.Quit() print splashText def setDesignVar(self, dvStr, val): dv = self.desVarDict[dvStr] dv.val = floatDammit( val ) #print "in setDesignVar, setting ",dvStr,"to",val def getDesignVar(self, dvStr): dv = self.desVarDict[dvStr] return dv.val def getDesVars(self, *dvItems): '''handle either single design var or list of design vars''' result = [] for dvStr in dvItems: if type(dvStr)==type([1,2]): for s in dvStr: result.append( self.getDesignVar( s ) ) else: result.append( self.getDesignVar( dvStr ) ) if len(result)==1: return result[0] else: return result def getDesignVarAxisLabel(self, dvStr): dv = self.desVarDict[dvStr] return self.getAxisLabel( dvStr, dv ) def getControlDesVarStr(self,key): feasStr = '' if self.hasFeasibleControlVar( key ): fv = self.getFeasibleVarWithControlVar( key ) feasStr = '* -----> ' +\ ' (%s varies to make %s = %g %s)'%(key, fv.outParam.name, fv.feasibleVal, fv.outParam.units) minmaxStr = '' if self.hasMinMaxControlVar( key ): mmv = self.getMinMaxVarWithControlVar( key ) if mmv.findmin: oStr = 'minimize' else: oStr = 'maximize' minmaxStr = '* -----> ' +\ ' (%s varies to %s %s)'%(key, oStr, mmv.outParam.name) return feasStr, minmaxStr def getDesVarShortSummary(self, *omitList): sList = [] for key,dv in self.desVarDict.items(): if key in omitList: continue feasStr, minmaxStr = self.getControlDesVarStr(key) # do NOT show control design variables in desVar... show them in resultVars if not (feasStr or minmaxStr): sList.append( "%s = %g %s"%(key, dv.val, dv.units ) ) return '\n'.join( sList ) def getDesVarSummary(self, *omitList): oList = [( 'NAME','VALUE','MINIMUM','MAXIMUM','DESCRIPTION','','')] for key,dv in self.desVarDict.items(): if key in omitList: continue desc = dv.description if len(dv.units) > 0: desc += ' (%s)'%dv.units feasStr, minmaxStr = self.getControlDesVarStr(key) # do NOT show control design variables in desVar... show them in resultVars if not (feasStr or minmaxStr): oList.append( (key,'%g'%dv.val,'%g'%dv.minVal,'%g'%dv.maxVal, desc, feasStr, minmaxStr ) ) nmax = 1 vmax = 1 mmax = 1 Mmax = 1 dmax = 1 for (n,v,m,M,d,f,mms) in oList: nmax = max( len(n), nmax ) vmax = max( len(v), vmax ) mmax = max( len(m), mmax ) Mmax = max( len(M), Mmax ) dmax = max( len(d), dmax ) sList = [] for (n,v,m,M,d,f,mms) in oList: sList.append( ' %s %s %s %s %s '%(n.rjust(nmax),v.rjust(vmax),m.rjust(mmax), M.rjust(Mmax), d.ljust(dmax))) if len(f)>0: sList.append( '%s %s '%(' '.rjust(nmax),f) ) if len(mms)>0: sList.append( '%s %s '%(' '.rjust(nmax),mms) ) ast = '='*len(sList[0]) head = headerStr( 'Design Variables', '=', len(sList[0]) ) return head + '\n'+\ '\n'.join( sList ) + '\n' + ast + '\n' def getHTMLDesVarSummary(self, *omitList): #print 'self.desVarDict.keys()=',self.desVarDict.keys() #print 'omitList=',omitList if len(omitList) + len(self.feasibleVarList)>=len(self.desVarDict.keys()): return '' summary = '<table class="mytable"><th colspan="4" bgcolor="#CCCCCC">Design Variables (nominal values)</th>' +\ '<tr><td><b>Name</b></td><td><b>Value</b></td><td><b>Units</b></td><td><b>Description</b></td></tr>' for key,dv in self.desVarDict.items(): if key in omitList: continue desc = dv.description if len(dv.units) > 0: desc += ' (%s)'%dv.units feasStr, minmaxStr = self.getControlDesVarStr(key) if feasStr or minmaxStr: continue # do NOT show control design variables in desVar... show them in resultVars #specStr = '<br><b>* -----><b>' #desc += '<br>' + feasStr[8:] + minmaxStr[8:] else: specStr = '' summary += '<tr><td align="left" valign="top">%10s</td><td align="right" valign="top">%12g%s</td><td nowrap align="left" valign="top">%s</td><td nowrap align="left" valign="top">%s</td></tr>\n'%\ (key,dv.val,specStr,dv.units, desc ) return summary + '</table>' def getHTMLResultVarSummary(self): summary = '<table class="mytable"><th colspan="6" bgcolor="#CCCCCC">Result Variables </th>' +\ '<tr><td><b>Name</b></td><td><b>Value</b></td><td><b>Units</b></td><td><b>Description</b></td><td><b>Low Limit</b></td><td><b>High Limit</b></td></tr>' # make local list of effective result variables (includes design control vars) resultVarL = [] #: list of result var objects (rv) including design control vars # resultVarL includes desVars that are control variables, (minmax or feasible) for key,dv in self.desVarDict.items(): if self.hasMinMaxControlVar(key) or self.hasFeasibleControlVar(key): # control varaibles in minmax or feasible change like result vars resultVarL.append(['contVar',key,dv]) for key,rv in self.resultVarDict.items(): resultVarL.append(['resVar',key,rv]) for vType,key,rv in resultVarL: desc = rv.description conVal1 = '---' if vType=='contVar': # a control variable conVal1 = '>%g'%rv.minVal elif rv.loLimit>NEG_INF: conVal1 = '>%g'%rv.loLimit conVal2 = '---' if vType=='contVar': # a control variable conVal2 = '<%g'%rv.maxVal elif rv.hiLimit<POS_INF: conVal2 = '<%g'%rv.hiLimit if len(rv.units) > 0: desc += ' (%s)'%rv.units feasStr, minmaxStr = self.getControlDesVarStr(key) if feasStr or minmaxStr: specStr = '<br><b>* -----><b>' desc += '<br>' + feasStr[8:] + minmaxStr[8:] else: specStr = '' summary += '<tr><td align="left">%10s</td><td align="right">%12g%s</td><td nowrap align="left">%s</td><td nowrap align="left">%s</td><td nowrap align="right">%s</td><td nowrap align="right">%s</td></tr>\n'%\ (key,rv.val,specStr,rv.units, desc, conVal1, conVal2 ) return summary + '</table>' def saveDesVarSummary(self): print 'saving Design Variable Summary to',os.path.split(self.summFileName)[-1] self.summFile.write( self.getDesVarSummary() + '\n' ) self.htmlFile.write('<center><table border="1" class="mytable">') self.htmlFile.write('<th>Design Variable Summary</th>') self.htmlFile.write('<tr><td nowrap>') self.htmlFile.write( self.getHTMLDesVarSummary() ) self.htmlFile.write( self.getHTMLResultVarSummary() ) self.htmlFile.write('</td></tr></table></center>') def setControlRoutine(self, controlRoutine): self.controlRoutine = controlRoutine # call it to make sure all is initialized self.evaluate() def hasDesignVar(self, dvStr): return self.desVarDict.has_key(dvStr) def addDesignVariable(self, name="desvar", InitialVal=0.0, minVal=-1.0E300, maxVal=1.0E300, NSteps=10, units='', desc='', step=None, linear=1): dv = InputParam(name=name, description=desc, units=units, val=InitialVal, minVal=minVal, maxVal=maxVal, NSteps=NSteps, stepVal=None, linear=linear) self.desVarDict[name] = dv try: if dv.NSteps>100: print 'WARNING... more than 100 steps in design variable',name print ' a large number of steps will increase run times' except: pass def addDesVars(self, *dvLists): #must be entered as lists of design variables for dvList in dvLists: #print dvList name,InitialVal,minVal,maxVal,NSteps,units,desc = dvList self.addDesignVariable( name=name, InitialVal=InitialVal, minVal=minVal, maxVal=maxVal, NSteps=NSteps, units=units, desc=desc, step=None, linear=1) def hasFeasibleResultVar(self, fvStr): ans = 0 for fv in self.feasibleVarList: if fvStr.lower() == fv.outParam.name.lower(): ans = 1 return ans def hasFeasibleControlVar(self, fvCVStr): ans = 0 for fv in self.feasibleVarList: if fvCVStr.lower() == fv.inpParam.name.lower(): ans = 1 return ans def getFeasibleVarWithResultVar(self, fvStr): ans = None for fv in self.feasibleVarList: if fvStr.lower() == fv.outParam.name.lower(): ans = fv return ans def getFeasibleVarWithControlVar(self, fvCVStr): ans = 0 for fv in self.feasibleVarList: if fvCVStr.lower() == fv.inpParam.name.lower(): ans = fv return ans def makeFeasiblePair(self, outName="feasvar", feasibleVal=0.0, inpName='inpvar', tolerance=1.0E-6, maxLoops=40, failValue=None): IP = self.desVarDict[inpName] OP = self.resultVarDict[outName] # need to set functionToCall later, in case controlRoutine changes fv = FeasiblePair( inpParam=IP, outParam=OP, functionToCall=None, feasibleVal=feasibleVal, tolerance=tolerance, maxLoops=maxLoops, failValue=failValue) self.feasibleVarList.append( fv ) # make min/max routines def hasMinMaxVar(self, mmvStr): ans = 0 for mmv in self.minmaxVarList: if mmvStr.lower() == mmv.name.lower(): ans = 1 return ans def hasMinMaxControlVar(self, mmvCVStr): ans = 0 for mmv in self.minmaxVarList: if mmvCVStr.lower() == mmv.inpParam.name.lower(): ans = 1 return ans def getMinMaxVar(self, mmvStr): ans = None for mmv in self.minmaxVarList: if mmvStr.lower() == mmv.outParam.name.lower(): ans = mmv return ans def getMinMaxVarWithControlVar(self, mmvCVStr): ans = 0 for mmv in self.minmaxVarList: if mmvCVStr.lower() == mmv.inpParam.name.lower(): ans = mmv return ans def makeMinMaxPair(self, outName="feasvar", findmin=0, inpName='inpvar', tolerance=1.0E-6, maxLoops=400, failValue=None): IP = self.desVarDict[inpName] OP = self.resultVarDict[outName] # need to set functionToCall later, in case controlRoutine changes mmv = MinMaxPair( inpParam=IP, outParam=OP, functionToCall=None, findmin=findmin, tolerance=tolerance, maxLoops=maxLoops, failValue=failValue) self.minmaxVarList.append( mmv ) def setResultVariableLimits(self, name="resultvar", loLimit=NEG_INF, hiLimit=POS_INF): if self.hasResultVar(name): rv = self.resultVarDict[name] rv.loLimit = loLimit rv.hiLimit = hiLimit def addResultVariable(self, name="resultvar", units='', desc='', loLimit=NEG_INF, hiLimit=POS_INF): rv = OutputParam(name=name, description=desc, units=units, val=0.0, loLimit=loLimit, hiLimit=hiLimit) self.resultVarDict[name] = rv def addResultVars(self, *rvLists): for rvList in rvLists: #print rvList if len(rvList)==3: name,units,desc = rvList self.addResultVariable(name,units,desc) else: name,units,desc,loLimit, hiLimit = rvList self.addResultVariable(name,units,desc,loLimit, hiLimit) def hasResultVar(self, rvStr): return self.resultVarDict.has_key(rvStr) def setResultVar(self, rvStr, val): try: rv = self.resultVarDict[rvStr] rv.val = val except: print 'Ignore ERROR in setResultVar... No result variable "%s"'%str(rvStr) def getResultVar(self, rvStr): # accept either result variables OR native attributes if self.resultVarDict.has_key(rvStr): rv = self.resultVarDict[rvStr] return rv.val elif self.hasMinMaxControlVar(rvStr) or self.hasFeasibleControlVar(rvStr) : dv = self.desVarDict[rvStr] return dv.val else: # as last ditch effort assume an attribute of self return getattr(self, rvStr ) def getAxisLabel(self, key, var): # accept either result variables OR native attributes if len(var.description)==0: if len(var.units)==0: label = var.name else: label = var.name + ', ' + var.units else: if len(var.units)==0: label = var.description + ' (' + var.name + ')' else: label = var.description + ', ' + var.units + ' (' + var.name + ')' return label def getResultVarAxisLabel(self, rvStr): # accept either result variables OR native attributes if self.resultVarDict.has_key(rvStr): rv = self.resultVarDict[rvStr] return self.getAxisLabel( rvStr, rv ) elif self.hasMinMaxControlVar(rvStr) or self.hasFeasibleControlVar(rvStr) : dv = self.desVarDict[rvStr] return self.getAxisLabel( rvStr, dv ) else: return rvStr def getResultVarSummary(self): # make local list of effective result variables (includes design control vars) resultVarL = [] #: list of result var objects (rv) including design control vars # resultVarL includes desVars that are control variables, (minmax or feasible) for key,dv in self.desVarDict.items(): if self.hasMinMaxControlVar(key) or self.hasFeasibleControlVar(key): # control varaibles in minmax or feasible change like result vars resultVarL.append(['contVar',key,dv]) for key,rv in self.resultVarDict.items(): resultVarL.append(['resVar',key,rv]) oList = [( 'NAME','VALUE','DESCRIPTION','LOW-LIMIT','HIGH-LIMIT','','')] for vType,key,rv in resultVarL: desc = rv.description conVal1 = '---' if vType=='contVar': # a control variable conVal1 = '>%g'%rv.minVal elif rv.loLimit>NEG_INF: conVal1 = '>%g'%rv.loLimit conVal2 = '---' if vType=='contVar': # a control variable conVal2 = '<%g'%rv.maxVal elif rv.hiLimit<POS_INF: conVal2 = '<%g'%rv.hiLimit if len(rv.units) > 0: desc += ' (%s)'%rv.units feasStr, minmaxStr = self.getControlDesVarStr(key) oList.append(('%s'%key,'%g'%rv.val, '%s'%desc, '%s'%conVal1, '%s'%conVal2, feasStr, minmaxStr )) nmax = 1 vmax = 1 dmax = 1 cmax = 1 lmax = 1 for (n,v,d,c,l,f,mms) in oList: nmax = max( len(n), nmax ) vmax = max( len(v), vmax ) dmax = max( len(d), dmax ) cmax = max( len(c), cmax ) lmax = max( len(l), lmax ) sList = [] for (n,v,d,c,l,f,mms) in oList: sList.append( ' %s %s %s %s %s '%(n.rjust(nmax),v.rjust(vmax),d.ljust(dmax), c.rjust(cmax),l.rjust(lmax))) if len(f)>0: sList.append( '%s %s '%(' '.rjust(nmax),f) ) if len(mms)>0: sList.append( '%s %s '%(' '.rjust(nmax),mms) ) ast = '='*len(sList[0]) head = headerStr( 'Result Variables', '=', len(sList[0]) ) return head + '\n'+\ '\n'.join( sList ) + '\n' + ast + '\n' def saveResultVarSummary(self): print 'saving Result Variable Summary to',os.path.split(self.summFileName)[-1] self.summFile.write( self.getResultVarSummary() + '\n' ) def violatesResultConstraint(self): vioList = [] for key,rv in self.resultVarDict.items(): # only handle inequality constraints, # equality constraints handled by feasibility variables # ignore violations in the nth decimal place cMult = 1.0 + abs(self.constraintTolerance) if rv.loLimit > rv.val*cMult: vioList.append( key + ' < ' + str( rv.loLimit ) ) if rv.hiLimit < rv.val/cMult: vioList.append( key + ' > ' + str( rv.hiLimit ) ) # now make sure no feasibility variables are violated for fv in self.feasibleVarList: rv = self.resultVarDict[fv.outParam.name] # ignore violations in the 4th decimal place epsilon = self.constraintTolerance * max(abs(rv.val), abs(fv.feasibleVal)) if abs(rv.val-fv.feasibleVal) > epsilon: vioList.append( rv.name + ' != ' + str( fv.feasibleVal ) ) return vioList def firstEvaluateIfReqd(self): # called by Optimize.optimize if self.NumEvaluations==0: self.evaluate() def evaluate(self): self.NumEvaluations += 1 #: increment counter for each evaluate call def paramCallBack(): '''special parameter callback (feasible and minmax)''' self.controlRoutine(self) # do minmax params first if len( self.minmaxVarList ) > 0: for mmv in self.minmaxVarList: if mmv.functionToCall is None: mmv.functionToCall = paramCallBack mmv.reCalc() # sets inpParam.val # now do feasible params if len( self.feasibleVarList ) > 0: for fv in self.feasibleVarList: if fv.functionToCall is None: fv.functionToCall = paramCallBack fv.reCalc() # sets inpParam.val # when done with "special" inputs, do final call to control routine self.controlRoutine(self) # call control routine #def reCalc(self): # why a synonym for evaluate? beats me. # self.evaluate() def addAssumption(self, label='generic param'): self.summaryObj.assumptions.append( label ) def addInput(self, label='generic param', value=0.0, units='xxx', format='%g'): self.summaryObj.inputs.append( [label, value, units, format] ) def addOutput(self, label='generic param', value=0.0, units='xxx', format='%g'): self.summaryObj.outputs.append( [label, value, units, format] ) def getAssumptions(self): assumpL = self.summaryObj.getSummAssumptions() assumpL.extend(self.summaryObj.getSummInputs()) assumpL.extend(self.summaryObj.getSummOutputs()) if assumpL: return '\n' + '\n'.join(assumpL) else: return '' def getSummary(self): return '''ParametricSoln: %s '''%(self.subtaskName,) + self.getAssumptions() def saveSummary(self): print 'saving Summary to',os.path.split(self.summFileName)[-1] self.summFile.write( self.getSummary() + '\n' ) def getShortSummary(self): summary = self.getSummary() return summary + '\n' def getShortHTMLSummary(self): lastType = '' summary = ['<center><table class="mytable">', '<th colspan="4" bgcolor="#CCCCCC">Summary </th>'] if self.getAssumptions(): summary.append('<tr><td colspan="4"><hr></td><tr>') assumpL = self.summaryObj.getSummAssumptions() assumpL.extend(self.summaryObj.getSummInputs()) assumpL.extend(self.summaryObj.getSummOutputs()) for assump in assumpL: summary.append('<tr><td colspan="4">%s</td><tr>'%(str(assump),)) summary.append('</table></center>') return '\n'.join( summary ) def saveShortSummary(self): print 'saving Short Summary to',os.path.split(self.summFileName)[-1] self.summFile.write( self.getShortSummary() + '\n' ) print 'saving Short Summary to',os.path.split(self.htmlFileName)[-1] self.htmlFile.write( self.getShortHTMLSummary() + '<br>\n' ) if self.userOptions.excel: xlText = self.getShortSummary() text=xlText.replace('\r','\n') spL = text.split('\n') rs = [['Short Summary ']] for s in spL: eqL = s.split('=') if len( eqL )==2: #rs.append( [eqL[0],"'=",eqL[1]] ) if len( eqL[1].split() )>1: rs.append( [eqL[0],"'=", eqL[1].split()[0], ' '.join( eqL[1].split()[1:]) ] ) else: rs.append( [eqL[0],"'=", eqL[1] ] ) else: rs.append( [s] ) sheetName="ShortSummary" if not self.xlSheetD.has_key(sheetName): print 'making sheet',sheetName self.xlSheetD[sheetName] = sheetName self.xlDoc.makeDataSheet( rs, sheetName=sheetName, autoFit=0, rowFormatL=None) if self.userOptions.ppt: pptText = self.getShortSummary() self.pptDoc.addTextSlide( text=pptText.replace('\n','\r'), title='Summary',textFont='Courier New', textFontSize=14, noBullets=1) if self.userOptions.word: tableStr = [(' Summary ',),(' ',)] wordTable1 = self.wordDoc.addTable( tableStr, Range=self.wordDoc.selectCharacter(-2) ) wordTable1.Style = self.tblstyl self.wordDoc.setCellStyle(wordTable1,1,1, just='c',bold=True, fontName='Arial', fontSize=14, bgcolor='15') self.wordDoc.setCellStyle( wordTable1, 2, 1, text= self.getShortSummary() ) self.wordDoc.selectCharacter(-1) self.wordDoc.addText(' ') def getFullSummary(self): self.saveDesVarSummary() self.saveResultVarSummary() summary = '\n\n' \ '\n======================================' +\ '\n==========FULL SYSTEM SUMMARY=========' +\ '\n======================================\n' +\ self.getSummary() return summary def getFullHTMLSummary(self): if self.getAssumptions(): summary = [self.summaryObj.getItemHTMLSummary()] else: summary = [] return ''.join(summary) def saveFullSummary(self): print 'saving Full Summary to',os.path.split(self.summFileName)[-1] self.summFile.write( self.getFullSummary() + '\n' ) print 'saving Full Summary to',os.path.split(self.htmlFileName)[-1] self.htmlFile.write( self.getFullHTMLSummary() + '<br>\n' ) def saveComment(self, comment=''): print 'saving comment to file' sOut = [] sOut.append('========================================') sOut.append( comment ) sOut.append('========================================') self.summFile.write( '\n'.join( sOut ) ) sOut = [] sOut.append('<center><table class="mytable" width="680">') sOut.append( '<tr><td align="left">%s'%comment ) sOut.append( '</td></tr>' ) sOut.append('</table></center>') self.htmlFile.write( '\n'.join( sOut ) ) def putImageInPPT( self, filename, title): print 'saving Image to',os.path.split(self.pptDocName)[-1] try: self.pptDoc.addImageSlide( imgFile=filename, title=title.replace('\n','\r')) except: print "ERROR... FAILED to put image in PowerPoint file" print traceback.print_exc() def putImageInWord( self, filename): print 'saving Image to',os.path.split(self.wordDocName)[-1] tableStr = [(' ',),(' ',)] wordTable1 = self.wordDoc.addTable( tableStr, Range=self.wordDoc.selectCharacter(-2) ) wordTable1.Style = self.tblstyl self.wordDoc.addImage(filename, Range=wordTable1.Cell(1,1).Range, fracPage=self.wordDocImagefracPage ) self.wordDoc.setCellStyle( wordTable1, 1, 1, just='c') self.wordDoc.setCellStyle( wordTable1, 2, 1, text= self.getDesVarSummary() + self.getResultVarSummary() ) self.wordDoc.selectCharacter(-1) self.wordDoc.addText(' ') def pickleParametricSoln(self): # pickle all of the internal variables itemL = [] # now save ParametricSoln object print 'pickling object', self.__class__.__name__ itemD = {} itemD['className'] = self.__class__.__name__ for key,val in self.__dict__.items(): if type(val) in [type(1), type(1.1), type('s')]: # eliminated list type #print key,val itemD[key]=val # save result and design variables for key,rv in self.resultVarDict.items(): itemD[key] = rv.val for key,dv in self.desVarDict.items(): itemD[key] = dv.val itemD[key+'_units'] = dv.units itemD[key+'_desc'] = dv.description feasStr = '' if self.hasFeasibleControlVar( key ): fv = self.getFeasibleVarWithControlVar( key ) feasStr = '* -----> ' +\ ' (%s varies to make %s = %g %s)'%(key, fv.outParam.name, fv.feasibleVal, fv.outParam.units) itemD[key+'_feas'] = feasStr minmaxStr = '' if self.hasMinMaxControlVar( key ): mmv = self.getMinMaxVarWithControlVar( key ) if mmv.findmin: oStr = 'minimize' else: oStr = 'maximize' minmaxStr = '* -----> ' +\ ' (%s varies to %s %s)'%(key, oStr, mmv.outParam.name) itemD[key+'_minmax'] = minmaxStr # save ParametricSoln dictionary to List itemL.append( itemD ) print 'Saving to Pickle file:',self.pickleFileName fOut = file(self.pickleFileName, 'w') pickle.dump( itemL, fOut ) fOut.close()
import fasttext import json import utils from Summary import Summary with open("data.json", 'r') as f: data = json.load(f) model = fasttext.load_model("wiki.en.bin") # Kmeans -> Relative position for topic in data.keys(): tom_tat = Summary(data=data[topic], model=model) tom_tat.summary("Summay/Summary_1/" + topic + ".txt") # Kmeans -> Absolute position for topic in data.keys(): tom_tat = Summary(data=data[topic], model=model, rel_position=False) tom_tat.summary("Summay/Summary_2/" + topic + ".txt") # Kmeans -> MMR -> Absolute position for topic in data.keys(): tom_tat = Summary(data=data[topic], model=model, rel_position=False, mmr=True) tom_tat.summary("Summay/Summary_3/" + topic + ".txt") #Kmeans -> LSA -> MMR -> Absolute position for topic in data.keys(): tom_tat = Summary(data=data[topic], model=model, rel_position=False, lsa=True, mmr=True) tom_tat.summary("Summay/Summary_1/" + topic + ".txt")
arcpy.AddMessage("!!!!!!!!!!Error tool not up to date!!!!!!!!!!") arcpy.AddMessage("Please download the latest version of the tool at") arcpy.AddMessage("http://www.sco.wisc.edu/parcels/tools/") arcpy.AddMessage("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") arcpy.AddMessage("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") exit() except Exception: arcpy.AddMessage("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") arcpy.AddMessage( "Check the change log at http://www.sco.wisc.edu/parcels/tools/") arcpy.AddMessage( "to make sure the latest version of the tool is installed before submitting" ) #Create summary object summary = Summary() base = os.path.dirname(os.path.abspath(__file__)) if inputDict['isSearchable'] == 'true': #Load files for current domain lists streetNames = [ line.strip() for line in open( os.path.join(base, '..\data\V2_StreetName_Simplified.txt'), 'r') ] #street name list streetTypes = [ line.strip() for line in open( os.path.join(base, '..\data\V2_StreetType_Simplified.txt'), 'r') ] #street types domain list unitIdTypes = [
class GUI: def __init__(self, master): self.valves = self.get_valves() self.master = master self.master.configure(bg='sky blue') self.password = '******' self.momentary = Momentary(self.master, self.valves) self.edit = Edit(self.master, self.valves) self.summary = Summary(self.master, self.valves) self.preferences = Preferences(self.master, self.valves) self.run_screen = RunScreen(self.master, self.valves) self.header = self.make_header(self.master) self.home = self.home_page(self.master) self.frame = self.home def make_header(self, master): header = Frame(master, bg='sky blue') self.label = StringVar() self.label.set('NONE') self.start_label = StringVar() self.start_label.set('START') self.lock_label = StringVar() self.lock_label.set('LOCKED') self.title = Label(header, textvariable=self.label, pady=20, font=('Lucida Console', 50)) self.title.config(bg='sky blue', fg='RoyalBlue4') self.run_image = PhotoImage(file="img/animate.png").subsample(x=5, y=5) self.run_button = Button(header, image=self.run_image, command=self.run, bg='SkyBlue4', activebackground='midnight blue', border=5) self.start_button = Button(header, textvariable=self.start_label, font=('Lucida Console', 30), command=self.start_stop, height=5) self.start_button.config(bg='brown3', activebackground='brown4', fg='white', activeforeground='white', width=10, border=5) self.save_image = PhotoImage(file="img/save.png").subsample(x=5, y=5) self.save_button = Button(header, image=self.save_image, command=self.save, bg='SkyBlue4', activebackground='midnight blue', border=5) self.save_button.config(state='disabled') self.reset_image = PhotoImage(file="img/reset.png").subsample(x=5, y=5) self.reset_button = Button(header, image=self.reset_image, command=self.reset, bg='SkyBlue4', activebackground='midnight blue', border=5) self.home_image = PhotoImage(file="img/home.png").subsample(x=5, y=5) self.home_button = Button(header, image=self.home_image, command=self.to_home, bg='SkyBlue4', activebackground='midnight blue', border=5) self.locked_image = PhotoImage(file="img/lock.png").subsample(x=5, y=5) self.unlocked_image = PhotoImage(file="img/unlock.png").subsample(x=5, y=5) self.lock_button = Button(header, image=self.locked_image, command=self.lock, bg='SkyBlue4', activebackground='midnight blue', border=5, textvariable=self.lock_label) return header def home_page(self, master): frame = Frame(master) frame.grid(row=0, column=0) image = PhotoImage(file="img/guido.gif") bg = Label(frame, image=image) bg.image = image bg.grid(row=0, column=0, rowspan=4, columnspan=2) index = 0 while index < 3: frame.grid_columnconfigure(index, minsize=200) frame.grid_rowconfigure(index, minsize=80) index += 1 summary_button = HomeButton(frame, self.to_summary, 'img/summary.png') summary_button.grid(row=0, column=0, sticky='w') edit_button = HomeButton(frame, self.to_edit, 'img/edit.png') edit_button.grid(row=0, column=1, sticky='e') momentary_button = HomeButton(frame, self.to_momentary, 'img/momentary.png') momentary_button.grid(row=1, column=0, sticky='w') preferences_button = HomeButton(frame, self.to_pref, 'img/preferences.png') preferences_button.grid(row=1, column=1, sticky='e') music = HomeButton(frame, self.to_summary, 'img/music.png') music.grid(row=2, column=0, sticky='w') info = HomeButton(frame, self.to_summary, 'img/info.png') info.grid(row=2, column=1, sticky='e') return frame # CSV file input def get_valves(self): valves = [ Valve('VALVE 1', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 2', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 3', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 4', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 5', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 6', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 7', 'DEFAULT', 'Action A', 'Action B', [0, 0]), Valve('VALVE 8', 'DEFAULT', 'Action A', 'Action B', [0, 0]) ] file = open('data.csv', 'rt', newline='') try: reader = csv.reader(file, lineterminator='\n') index = 0 for row in reader: if index == 0: index += 1 continue else: run = int(row[4]) delay = int(row[5]) interval = [run, delay] valves[index - 1] = Valve(row[0], row[1], row[2], row[3], interval) index += 1 finally: file.close() return valves def lock(self): if self.lock_label.get() == 'LOCKED': window = Toplevel() window.geometry('318x550') self.keypad = Keypad(window, self, self.password) else: self.save_button.config(state='disabled') self.edit.lock() self.preferences.lock() self.lock_label.set('LOCKED') self.lock_button.config(image=self.locked_image) def save(self): self.save_pref() self.save_edit() def save_edit(self): file = open('data.csv', 'w') interval = self.edit.get_intervals() try: writer = csv.writer(file, lineterminator='\n') writer.writerow(('Name', 'Setting', 'Action A', 'Action B', 'Runtime', 'Delaytime')) index = 0 for i in self.valves: i.set_interval( [interval[index].get(), interval[index + 8].get()]) valve_interval = i.get_interval() if self.edit.plusInterval[index].cget( 'state') == 'disabled' and self.edit.motor[index].cget( 'state') != 'disabled': i.set_setting('MOTOR') writer.writerow( (i.get_name().get(), i.get_setting(), i.get_action_a().get(), i.get_action_b().get(), 0, 0)) elif interval[index].get() is 0: i.set_setting('INACTIVE') writer.writerow((i.get_name().get(), i.get_setting(), 'NONE', 'NONE', 0, 0)) else: i.set_setting('DEFAULT') writer.writerow( (i.get_name().get(), i.get_setting(), i.get_action_a().get(), i.get_action_b().get(), valve_interval[0], valve_interval[1])) index += 1 finally: file.close() # must fix def save_pref(self): index = 0 for i in self.valves: num = index * 3 if self.preferences.entry_field[num].get(): i.set_name(self.preferences.entry_field[num].get()) self.preferences.entry_field[num].delete(0, 'end') if self.preferences.entry_field[num + 1].get(): i.set_action_a(self.preferences.entry_field[num + 1].get()) self.preferences.entry_field[num + 1].delete(0, 'end') if self.preferences.entry_field[num + 2].get(): i.set_action_b(self.preferences.entry_field[num + 2].get()) self.preferences.entry_field[num + 2].delete(0, 'end') index += 1 def start_stop(self): if self.start_label.get() == 'START': self.start_label.set('STOP') self.master.update() self.run_screen.run_all(True) self.home_button.config(state='disabled') else: self.start_label.set('START') self.run_screen.run_all(False) self.home_button.config(state='normal') def run(self): self.summary.grid_remove() self.run_button.pack_forget() self.run_screen.make_frame() self.frame = self.run_screen self.frame.grid(row=0, column=0) self.header.grid(row=0, column=1) self.label.set('RUN') self.title.pack(side='top') self.start_button.pack() self.home_button.pack(side='bottom') def to_home(self): self.momentary.end_all() self.momentary.delete_frame() self.lock_button.pack_forget() self.run_button.pack_forget() self.save_button.pack_forget() self.reset_button.pack_forget() self.home_button.pack_forget() self.start_button.pack_forget() self.preferences.grid_remove() self.frame.grid_remove() self.header.grid_remove() self.frame = self.home self.frame.grid(row=0, column=0) def to_summary(self): self.frame.grid_remove() self.label.set('SUMMARY') self.home_button.pack(side='right') self.run_button.pack(side='right') self.header.grid(row=0, column=0, columnspan=1, sticky='nsew') self.title.pack(side='left') self.summary = Summary(self.master, self.valves) self.frame = self.summary self.frame.grid(row=1, column=0) def to_edit(self): self.frame.grid_remove() self.label.set('EDIT PROGRAM') self.header.grid(row=0, column=0, columnspan=1, sticky='nsew') self.home_button.pack(side='right') self.save_button.pack(side='right') self.lock_button.pack(side='right') self.reset_button.pack(side='right') self.title.pack(side='left') self.frame = self.edit self.frame.grid(row=1, column=0) def to_momentary(self): self.frame.grid_forget() self.label.set('MOMENTARY') self.header.grid(row=0, column=0, columnspan=12, sticky='ew') self.title.pack(side='left') self.home_button.pack(side='right') self.momentary.make_frame() def to_pref(self): self.frame.grid_remove() self.label.set('PREFERENCES') self.header.grid(row=0, column=0, columnspan=1, sticky='nsew') self.home_button.pack(side='right') self.save_button.pack(side='right') self.lock_button.pack(side='right') self.reset_button.pack(side='right') self.title.pack(side='left') self.frame = self.preferences self.frame.grid(row=1, column=0) def reset(self): self.master.quit() def access_granted(self): self.lock_label.set('UNLOCKED') self.lock_button.config(image=self.unlocked_image) self.save_button.config(state='normal') index = 0 while index < 8: self.edit.minusInterval[index].config(state='normal') self.edit.minusDelay[index].config(state='normal') self.edit.plusInterval[index].config(state='normal') self.edit.plusDelay[index].config(state='normal') self.edit.motor[index].config(state='normal') self.edit.adv[index].config(state='normal') index += 1 for each in self.preferences.entry_field: each.config(state='normal') self.edit.set_seconds() self.save_button.config(state='normal')
s1 = set(cmdline) s2 = set(proc.cmdline()) if s1.issubset(s2): print('Kill: ' + ' '.join(proc.cmdline())) proc.kill() sleep(3) break else: print(buff, end='') print('** EXPR {} END **'.format(n_expr)) print('** END ALL EXPRs **') files = glob('output/SandBag-*/*.csv') cols = ['test-score', 'train-score', 'loss'] summary = Summary(files, cols) for col in cols: print('\n** PLOT: {} **'.format(col.title())) print(summary.data[col]) logy = True if col == 'loss' else False summary.plot(col, out_file='assets/{}.png'.format(col), grouped=True, alpha=0.2, legend=False, title=False, logy=logy) plt.show() IPython.embed()
totError, currParcel = Error.schoolDistCheck(totError, currParcel, "parcelid", "schooldist", "schooldistno", schoolDist_noName_dict, schoolDist_nameNo_dict, "tax", pinSkips, False) totError, currParcel = Error.fieldCompleteness(totError, currParcel, fieldNames, fieldListPass, v3CompDict) totError, currParcel = Error.fieldCompletenessComparison( totError, currParcel, fieldNames, fieldListPass, v3CompDict, getattr(LegacyCountyStats, (coName.replace(" ", "_")) + "LegacyDict")) #End of loop, finalize errors with the writeErrors function, then clear parcel currParcel.writeErrors(row, cursor, fieldNames) currParcel = None # Write all summary-type errors to file via the Summary class summaryTxt = Summary() Summary.writeSummaryTxt(summaryTxt, outDirTxt, outName, totError) # User messages (for testing): arcpy.AddMessage("General Errors: " + str(totError.generalErrorCount)) arcpy.AddMessage("Geometric Errors: " + str(totError.geometricErrorCount)) arcpy.AddMessage("Address Errors: " + str(totError.addressErrorCount)) arcpy.AddMessage("Tax Errors: " + str(totError.taxErrorCount)) #Write feature class from memory back out to hard disk arcpy.FeatureClassToFeatureClass_conversion(output_fc_temp, outDir, outName)
RN = self.wordDoc.Range( Cs(N).Start, Cs(N).End) RN.Select() return RN if __name__ == "__main__": #Self Test w = WordWrap() w.show() # w.addText('Line 1\n\n') # w.addText('Line 2\n\n') # w.addText('Line 3\n\n') # w.addText('Line 4\n\n') from Summary import Summary S = Summary( summaryTitle='Summary Title', subTitle='subtitle') S.addAssumption( 'Assume this is a test' ) S.addInput( label='Solar Flux', value=1.0, units='BTU/sqin', format='%g') S.addOutput(label='Tea Temperature', value=100.0, units='C', format='%g') summ = S sel = w.selectCharacter(1) w.changeEndSelection( -1 ) #T1 = w.wordApp.Selection.ConvertToTable() #w.wordDoc.Styles("Endnote Reference").Font.Size = 10 #w.wordDoc.Styles("Endnote Reference").Font.Name = "Courier New" #w.setAllTableCellStyle( Table=T1, StyleName="Endnote Reference")
mySummary.totalTweetsProcessed += 1 tweetDetails = json.loads(line) mySummary.melbGrid.processTweet(tweetDetails) mySummary.rank = rank return mySummary if rank == 0: # Load the MelbGrid json and parse the data to melbGrid with open('Config/MelbGrid.json', encoding="utf8") as melbGridConfigFile: melbGridConfig = json.load(melbGridConfigFile) summaryList = [] for i in range(size): # Create the array with the data strucutre to populate the information by processing the file # Inilialize the Melb Grid from the MelbGrid.json file data summaryList.append(Summary(MelbGrid(melbGridConfig["features"]))) else: summaryList = None mySummary = comm.scatter(summaryList, root = 0) print("Data place holders scattered") mySummary = processTwitterFile(mySummary, rank, size) endTime = time.time() mySummary.executionTime = endTime - startTime processedList = comm.gather(mySummary, root = 0)