def show_info(self): data = [] temp = [] for row in self.cursor.execute('SELECT * FROM reservationinfo ORDER BY reservationnumber'): temp = [] for i in row: temp.append(i) data.append(temp) table.create_table(self.connection, self.cursor, data, key='reservation')
def show_unavail_buses_info(self): data = [] temp = [] for row in self.cursor.execute('SELECT * FROM busindex WHERE capacity = occupied ORDER BY busno'): temp = [] for i in row: temp.append(i) data.append(temp) table.create_table(self.connection, self.cursor, data, key='bus')
def setCredentials(self): businfo = self.e_bus.get() data = [] temp = [] for row in self.cursor.execute('SELECT * FROM reservationinfo WHERE busno=? ORDER BY reservationnumber', (businfo,)): temp = [] for i in row: temp.append(i) data.append(temp) table.create_table(self.connection, self.cursor, data, key='reservation') self.master.destroy()
def create_box_post(): # Quick hack to get past flask templating becuase I don't have time to do that i = random.randint(1, 9999999999) # Get response from form lat1 = request.form.getlist('lat1')[0] lon1 = request.form.getlist('lon1')[0] lat2 = request.form.getlist('lat2')[0] lon2 = request.form.getlist('lon2')[0] tower_type = int(request.form.getlist('tower_type')[0]) radioBoxes = dict() radioBoxes['heli'] = 'heli' in request.form radioBoxes['vessel'] = 'vessel' in request.form radioBoxes['diags'] = 'diags' in request.form radioBoxes['log'] = 'log' in request.form radioBoxes['upgrade'] = 'upgrade' in request.form # generate report result = generateReport((lon1, lat1), (lon2, lat2), radioBoxes, tower_type) # map box windmill_lats, windmill_lons = create_box([(lon1, lat1), (lon2, lat2)]) gmap = gmplot.GoogleMapPlotter(43.9, -66.1, 10) gmap.plot(windmill_lats, windmill_lons, 'cornflowerblue', edge_width=10) turbineInfo = result.get('towerList') wmLats = [] wmLongs = [] for i in range(0, len(turbineInfo)): wmLats.append(turbineInfo[i][0]) wmLongs.append(turbineInfo[i][1]) gmap.scatter(wmLats, wmLongs, '#000000', size=400, marker=False) file_name = "templates/my_map" + str(i) + ".html" gmap.draw(file_name) create_table(result) with open(file_name, 'a') as outfile: with open('table.html') as infile: outfile.write(infile.read()) # Return product return render_template("my_map" + str(i) + ".html")
def test_player_state(): table = create_table() player = Player1236(table) s = NoWinState(player) assert s.current_bet().bet_amount == 1 s = s.next_won() assert s.current_bet().bet_amount == 3 s = s.next_won() assert s.current_bet().bet_amount == 2 s = s.next_won() assert s.current_bet().bet_amount == 6 s = s.next_won() assert s.current_bet().bet_amount == 1 s = s.next_lost() assert s.current_bet().bet_amount == 1 s = s.next_won() assert s.current_bet().bet_amount == 3 s = s.next_lost() assert s.current_bet().bet_amount == 1
def graph(title, name, data, popularity): contributors = data[0] projects = data[1] G = nx.Graph() for project in projects: project_contributors = projects[project] for combination in itertools.combinations(project_contributors, r=2): e0 = combination[0] e1 = combination[1] if not G.has_edge(e0,e1) and not G.has_edge(e1,e0): G.add_edge(e0,e1, weight=1) else: G[e0][e1]['weight'] += 1 q = [] cc = [] pl = [] avg_cc = [] popularity_score = [] subgraph_node_number = [] subgraph_edge_number = [] def sample_graphs(subgraphs): return subgraphs N = 0 subgraphs = sample_graphs(nx.connected_component_subgraphs(G)) for subgraph in subgraphs: nodes = subgraph.number_of_nodes() edges = subgraph.number_of_edges() if nodes > 10000: continue if nodes < 3: continue subgraph_node_number.append(nodes) subgraph_edge_number.append(edges) graph_stats = compute_stats(subgraph) random_graph = compute_random_graph(nodes, edges, subgraph) random_stats = compute_stats(random_graph) q_value = get_q(graph_stats, random_stats) if q_value is None: continue N += 1 q.append(q_value) cc.append(graph_stats['cc']) pl.append(graph_stats['pl']) avg_cc.append(graph_stats['avg_cc']) graph_projects = set(sum([contributors[j] for j in subgraph],[])) try: avg_popularity = np.mean([float(popularity[node]) for node in graph_projects]) except ValueError: print "ERROR calculating popularity" avg_popularity = 0 popularity_score.append(avg_popularity) q_bins = np.linspace(min(q),max(q), num=8) q_values = [[] for _ in q_bins] q_idxs = np.digitize(q, q_bins, right=True) for idx,score in zip(q_idxs,popularity_score): q_values[idx].append(score) create_graph(name, q_bins, q_values) create_histogram(name + "-q", "$Q$", q, log_y_scale=True) total_projects = len(set(sum(contributors.values(), []))) write_table("subgraphs_summary_" + name, table.create_table(title + " Summary", "fig:"+name+"_summary_stats", "P: %s, $P_c$: %s, C: %s" % (total_projects, N, len(contributors.keys())), OrderedDict([ ("$Q$", q), ("$C^{\Delta}$", cc), ("$\overline{C^{\lambda}}$", avg_cc), ("$L$", pl), ("N", subgraph_node_number), ("E", subgraph_edge_number) ])))
def run(): choice_from_menu = False while not choice_from_menu: player_choice = menu.menu() if player_choice == '1' or player_choice == '2' or player_choice == '3': choice_from_menu = True else: print("\nThere is no such choice!") input() if player_choice == '1': os.system('clear') x = 3 y = 3 inventory = [] table = t.create_table() cover_table = view.get_empty_table(table) coordinates_a_b = data.find_a_b(table) coordinates_water = data.find_water(table) coordinates_dolars = data.find_dolars(table) money = len(coordinates_dolars) coordinates_items = data.find_item(table) character = character_selection.character_selection() enter_pressed = False while not enter_pressed: os.system('clear') menu.rogulike_title() enter_input = input("Press ENTER to start\n") if enter_input == "": enter_pressed = True while True: inp = data.getch() if inp == "i": os.system("clear") print(inv.print_table(inventory)) print("Your money:", colors.CBOLD + colors.CYELLOW, money - len(coordinates_dolars), colors.CEND, "/", colors.CBOLD + colors.CYELLOW, money, colors.CEND, "$") print("\nPress ENTER to return") quit_inventory = input() os.system("clear") w = moves.moves(table, inp, x, y, character) table = w[0] x = w[1] y = w[2] data.discover_table(table, cover_table, x, y) w = moves.teleport(table, inp, x, y, cover_table, character) table = w[0] x = w[1] y = w[2] data.discover_table(table, cover_table, x, y) w = moves.gate_teleport(table, cover_table, coordinates_a_b, x, y, character) x = w[0] y = w[1] table = w[2] moves.water(coordinates_water, x, y) coordinates_dolars = moves.dolars(coordinates_dolars, x, y) inventory = moves.get_inventory(coordinates_items, x, y, inventory) coordinates_items = moves.items(coordinates_items, x, y) data.discover_table(table, cover_table, x, y) view.print_table(cover_table) if player_choice == '2': os.system('clear') valid_input = False while not valid_input: os.system('clear') a = menu.options_menu() if a == '0': valid_input = True os.system('clear') run() if player_choice == '3': os.system('clear') os._exit(0)
def load_data(): theory_df, pracs_df = create_table(filename, Subject_no, Labs_no) return theory_df, pracs_df
def action_pass(a): global turn, pic_no, turn_team, check, spin_box, max_quote label_mi.config(borderwidth=4, relief='flat') label_rr.config(borderwidth=4, relief='flat') label_kkr.config(borderwidth=4, relief='flat') label_rcb.config(borderwidth=4, relief='flat') def update_player_stats(name, matches, runs, wickets, sr, avg): stats.config(text="Name: " + name + "\nMatches: " + matches + "\nRuns: " + runs + "\nWickets: " + wickets + "\nStrike Rate: " + sr + "\nAverage: " + avg) x = turn % 4 if x == 2: # chance of second team turn_team.config(text="Rajasthan Royals\n Do you want to BID?") # TODO: highlight somehow if a == 2: check = 2 label_rr.config(borderwidth=6, relief='solid') elif x == 3: # chance of 3rd team turn_team.config(text="Kolkata Knight Riders\n Do you want to BID?") # TODO: highlight somehow if a == 2: check = 3 label_kkr.config(borderwidth=6, relief='solid') elif x == 0: # chance of 4th team turn_team.config( text="Royal Challengers Bangalore\n Do you want to BID?") # TODO: highlight somehow if a == 2: check = 4 label_rcb.config(borderwidth=6, relief='solid') elif x == 1: # chance of 1st team turn_team.config(text="Mumbai Indians\n Do you want to BID?") label_mi.config(borderwidth=6, relief='solid') # TODO: highlight somehow if a == 2: check = 1 if turn % 12 == 0 and turn > 0: turn += 1 pic_no += 1 if pic_no == 9: messagebox.showinfo("Auction Complete", "Auction Complete!") table.create_table() file = 'assets/' + str(pic_no) + '.png' curr_player.config(file=file) curr_player.subsample(2) label_player_photo.config(image=curr_player) pi = player_info[str(pic_no)] update_player_stats(pi['name'], str(pi['matches']), str(pi['runs']), str(pi['wickets']), str(pi['strike_rate']), str(pi['average'])) max_quote = 500000 spin_box = Spinbox(from_=500000, to=5000000, increment=100000) spin_box.place(x=525, y=550, height=25, width=150) label_player_price.config( text='Current highest bid for this player is Rs. ' + str(max_quote)) if a == 2: return (2, check) elif a == 1: if check == 1: db = Mysqldb.connect('localhost', 'root', '9802', 'ipl') cursors = db.cursor() global pic_no1 d = player_info[str(pic_no1)] sql = "INSERT INTO RCB(name,matches,runs,wickets,strike_rate,average) VALUES(%s,%s,%s,%s,%s,%s)" cursors.execute(sql, (d['name'], d['matches'], d['runs'], d['wickets'], d['strike_rate'], d['average'])) pic_no1 += 1 db.commit() elif check == 0: db = Mysqldb.connect('localhost', 'root', '9802', 'ipl') cursors = db.cursor() d = player_info[str(pic_no1)] sql = "INSERT INTO KKR(name,matches,runs,wickets,strike_rate,average) VALUES(%s,%s,%s,%s,%s,%s)" cursors.execute(sql, (d['name'], d['matches'], d['runs'], d['wickets'], d['strike_rate'], d['average'])) pic_no1 += 1 db.commit() elif check == 3: db = Mysqldb.connect('localhost', 'root', '9802', 'ipl') cursors = db.cursor() d = player_info[str(pic_no1)] sql = "INSERT INTO RR(name,matches,runs,wickets,strike_rate,average) VALUES(%s,%s,%s,%s,%s,%s)" cursors.execute(sql, (d['name'], d['matches'], d['runs'], d['wickets'], d['strike_rate'], d['average'])) pic_no1 += 1 db.commit() elif check == 2: db = Mysqldb.connect('localhost', 'root', '9802', 'ipl') cursors = db.cursor() d = player_info[str(pic_no1)] sql = "INSERT INTO MI(name,matches,runs,wickets,strike_rate,average) VALUES(%s,%s,%s,%s,%s,%s)" cursors.execute(sql, (d['name'], d['matches'], d['runs'], d['wickets'], d['strike_rate'], d['average'])) pic_no1 += 1 db.commit() elif turn % 12 != 0 or turn == 0: turn += 1 return (1, check)
def action_bid(): global max_quote, turn, b, c, highest_bidder curr_quote = spin_box.get() curr_quote = int(curr_quote) if curr_quote > max_quote: max_quote = curr_quote highest_bidder = turn % 4 print("highest bidder is ", highest_bidder) label_player_price.config( text='Current highest bid for this player is Rs. ' + str(max_quote)) b, c = action_pass(2) else: msg = "FOR BIDDING YOUR BID PRICE MUST BE GREATER THAN PREVIOUS BID VALUE" messagebox.showinfo("You Got some trouble", msg) if b == 2: if highest_bidder == 1: db = Mysqldb.connect('localhost', 'root', '9802', 'ipl') cursors = db.cursor() global pic_no1 d = player_info[str(pic_no1)] sql = "INSERT INTO RCB(name,matches,runs,wickets,strike_rate,average) VALUES(%s,%s,%s,%s,%s,%s)" cursors.execute(sql, (d['name'], d['matches'], d['runs'], d['wickets'], d['strike_rate'], d['average'])) pic_no1 += 1 db.commit() elif highest_bidder == 0: db = Mysqldb.connect('localhost', 'root', '9802', 'ipl') cursors = db.cursor() d = player_info[str(pic_no1)] sql = "INSERT INTO KKR(name,matches,runs,wickets,strike_rate,average) VALUES(%s,%s,%s,%s,%s,%s)" cursors.execute(sql, (d['name'], d['matches'], d['runs'], d['wickets'], d['strike_rate'], d['average'])) pic_no1 += 1 db.commit() elif highest_bidder == 3: db = Mysqldb.connect('localhost', 'root', '9802', 'ipl') cursors = db.cursor() d = player_info[str(pic_no1)] sql = "INSERT INTO RR(name,matches,runs,wickets,strike_rate,average) VALUES(%s,%s,%s,%s,%s,%s)" cursors.execute(sql, (d['name'], d['matches'], d['runs'], d['wickets'], d['strike_rate'], d['average'])) pic_no1 += 1 db.commit() elif highest_bidder == 2: db = Mysqldb.connect('localhost', 'root', '9802', 'ipl') cursors = db.cursor() d = player_info[str(pic_no1)] sql = "INSERT INTO MI(name,matches,runs,wickets,strike_rate,average) VALUES(%s,%s,%s,%s,%s,%s)" cursors.execute(sql, (d['name'], d['matches'], d['runs'], d['wickets'], d['strike_rate'], d['average'])) pic_no1 += 1 db.commit() if pic_no1 == 9: messagebox(text="Auction Complete!") table.create_table()
def graph(title, name, data, popularity): contributors = data[0] projects = data[1] G = nx.Graph() for project in projects: project_contributors = projects[project] for combination in itertools.combinations(project_contributors, r=2): e0 = combination[0] e1 = combination[1] if not G.has_edge(e0, e1) and not G.has_edge(e1, e0): G.add_edge(e0, e1, weight=1) else: G[e0][e1]['weight'] += 1 q = [] cc = [] pl = [] avg_cc = [] popularity_score = [] subgraph_node_number = [] subgraph_edge_number = [] def sample_graphs(subgraphs): return subgraphs N = 0 subgraphs = sample_graphs(nx.connected_component_subgraphs(G)) for subgraph in subgraphs: nodes = subgraph.number_of_nodes() edges = subgraph.number_of_edges() if nodes > 10000: continue if nodes < 3: continue subgraph_node_number.append(nodes) subgraph_edge_number.append(edges) graph_stats = compute_stats(subgraph) random_graph = compute_random_graph(nodes, edges, subgraph) random_stats = compute_stats(random_graph) q_value = get_q(graph_stats, random_stats) if q_value is None: continue N += 1 q.append(q_value) cc.append(graph_stats['cc']) pl.append(graph_stats['pl']) avg_cc.append(graph_stats['avg_cc']) graph_projects = set(sum([contributors[j] for j in subgraph], [])) try: avg_popularity = np.mean( [float(popularity[node]) for node in graph_projects]) except ValueError: print "ERROR calculating popularity" avg_popularity = 0 popularity_score.append(avg_popularity) q_bins = np.linspace(min(q), max(q), num=8) q_values = [[] for _ in q_bins] q_idxs = np.digitize(q, q_bins, right=True) for idx, score in zip(q_idxs, popularity_score): q_values[idx].append(score) create_graph(name, q_bins, q_values) create_histogram(name + "-q", "$Q$", q, log_y_scale=True) total_projects = len(set(sum(contributors.values(), []))) write_table( "subgraphs_summary_" + name, table.create_table( title + " Summary", "fig:" + name + "_summary_stats", "P: %s, $P_c$: %s, C: %s" % (total_projects, N, len(contributors.keys())), OrderedDict([("$Q$", q), ("$C^{\Delta}$", cc), ("$\overline{C^{\lambda}}$", avg_cc), ("$L$", pl), ("N", subgraph_node_number), ("E", subgraph_edge_number)])))