def check_url(url): """ Checks if the url is a valid wikipedia page """ if url[:30] == 'https://en.wikipedia.org/wiki/' and len(url) > 30: warning.grid_remove() pos_dict = {} pos_dict['pronouns'] = pro_var.get() pos_dict['conjunctions'] = con_var.get() pos_dict['prepositions'] = pre_var.get() pos_dict['articles'] = art_var.get() graph.main(url, pos_dict) else: warning.grid()
def main(): """Runs all PyMPL examples.""" print "equivknapsack:" equivknapsack.main() print "equivknapsack01:" equivknapsack01.main() print "graph:" graph.main() print "instance:" instance.main()
def main(): quit = -1 while quit < 0: print "-" * 30 + " Project 1 " + "-" * 30 # print "Choose:" print "\n\n For a: \n 1: Graph Figure 7.16 in [GT] page 364 \n Default values (from = 'BWI', to = ['SFO','LAX']) \n\n For b: \n 2: MC with (3,2) \n 3: MC with (4,3) \n\n To Quit: \n 4: quit\n\n" choice = input('Enter your choise: ') if choice == 4: quit = 1 elif choice == 3: mc.main(4, 3) elif choice == 2: mc.main(3, 2) elif choice == 1: gr.main()
def test(): net.eval() testloss = 0 correct = 0 for data, target in testloader: data= data.cuda() target= target.cuda() outputs=net(data) testloss += F.nll_loss(outputs, target, reduction='sum').item() pred = outputs.argmax(dim=1, keepdim=True) correct += pred.eq(target.view_as(pred)).cpu().sum().item() loss= testloss/len(testloader.dataset) print('\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.0f}%)\n'.format( loss, correct, len(testloader.dataset), 100. * correct / len(testloader.dataset))) graph.append2y(100. * correct / len(testloader.dataset)) if graph.showgraph==True: graph.main() elif showgraph==True: graph.showgraph=True
def industryGraph(industry): print industry if 'subgraphs' in request.args: subgraphs = request.args["subgraphs"] subgraphs = int(subgraphs) industry = industry.replace("_"," ") response = gpy.main(industry,conn, subgraphs) file = industry.replace(" ", "_") + "_" + str(subgraphs) + ".json" with open(file, "wb") as f: json.dump(response, f) return json.dumps(response, ensure_ascii=False) else: return "PLEASE ADD AN INDUSTRY ARGUMENT"
os.system("rm -f label_prop_output.txt") if i == 1: os.system("junto config simple_config") else: os.system("touch dump") os.system("junto config simple_config > dump") print '+--- output for part', i, 'generated' #return to main STEP dir for next parts os.chdir("..") nope = (5, 10, 12, 18, 22, 24) # i is the iterator to run all parts print '+--- Initiate Graph Generation ---+\n' for i in range(1, 31): #part removed if i in nope: print '\npart', i, 'ignored\n' continue else: #use input for graph print '\nRunning part', i, '\n' graph.main(i) merge.main(i) print 'Part', i, 'graph generated\n' juntofy(i) time.sleep(0.5)
old_time, oldres = read_stats(-opt_diff) else: stats_time, res = read_stats(-delta) if opt_diff: old_time, oldres = read_stats(-delta-opt_diff) keys = res.keys() keys.sort(lambda x,y: cmp(res[y][3]+2*res[y][4],res[x][3]+2*res[x][4])) if opt_write: f = open(os.path.expanduser("~/public_html/data/new_stats.py"),"a") f.write(repr( (time.time() , res ) ) +"\n") f.close() write_templates(res) import graph graph.main() else: if opt_diff: diffs = {} for i in res.keys() : if not i in oldres.keys(): oldres[i] = (0,0,0,0,0,0,1,0) diffs[i] = ( res[i][0] - oldres[i][0], \ res[i][1] - oldres[i][1], \ res[i][2] - oldres[i][2], \ res[i][3] - oldres[i][3], \ res[i][4] - oldres[i][4], \ res[i][5] - oldres[i][5], \ res[i][6] - oldres[i][6], \ res[i][7] - oldres[i][7] ) total = total_q0 = total_q1 = total_q2 = total_q3 = total_q4 = 0
import request_and_store import Calculate import graph import translation if __name__ == "__main__": language = input("Language choice: ") abr = translation.lang_abr(language) product = input( translation.translateText( abr, "Type of food you are looking for (Ex. pork, beef, fish, etc.): ")) mode = input( translation.translateText( abr, "What do you care about the most? 1 for calories, 2 for cost, 3 for nutritients: " )) product = translation.translateText("en", product) while True: if mode != "1" and mode != "2" and mode != "3": mode = input("Invalid mode! Try again:") else: break request_and_store.main(product) Calculate.calculate_cost_and_write(abr, product) graph.main(mode, product)
def run(): global entry ign = entry.get() graph.main(ign)
acc.append((speed[-1] - speed[-2]) / delta) else: speed.append(float('nan')) acc.append(float('nan')) def listener(): rospy.init_node('listener', anonymous=True, disable_signals=True) rospy.Subscriber("/odom", Odometry, odometryCb) rospy.spin() class MyDataset(graph.Dataset): def __init__(self, title, x, y): super(MyDataset, self).__init__(title, x, y) def range(self): if len(self.x) >= shown_time * odom_rate: return (self.x[-1] - shown_time, self.x[-1]) else: return (self.x[0], self.x[-1]) if __name__ == '__main__': thread.start_new_thread(listener, ()) datasets = [ MyDataset("Speed", ticks, speed), MyDataset("Acceleration", ticks, acc), ] graph.main("ROS Monitor", datasets, mutex)
from graph import main import mpld3 import matplotlib.pyplot as plt from pathlib import Path output_path = Path('RESULTS') output_path.mkdir(exist_ok=True) plot = main(style='default', show_bounds=False, linewidth=2, dpi=100, size=[16, 15]) mpld3.save_html(plot[1][0], str(output_path / Path('abs_freq.html')), template_type='simple') mpld3.save_html(plot[1][1], str(output_path / Path('rel_freq.html')), template_type='simple') plt.close("all") plot = main(style='dark_background', show_bounds=True, linewidth=0.75, dpi=100, size=[16, 15]) plot[1][0].savefig(str(output_path / Path('abs_freq.png'))) plot[1][1].savefig(str(output_path / Path('rel_freq.png'))) plot[0].show()