def ave_score(data, sims): team_data = {} for i in range(sims): teams = random.choices(list(data.keys()), k=6) match = make_match(data, teams[:3], teams[-3:]) scores = match.sim() for team in [team.team for team in match.red_alliance.teams]: if team in list(team_data.keys()): team_data[team]['count'] += 1 team_data[team]['score'] += scores[0] else: team_data[team] = {'count': 1, 'score': scores[0]} for team in [team.team for team in match.blue_alliance.teams]: if team in list(team_data.keys()): team_data[team]['count'] += 1 team_data[team]['score'] += scores[1] else: team_data[team] = {'count': 1, 'score': scores[1]} team_scores = {} for k in team_data: team_scores[k] = team_data[k]['score'] / team_data[k]['count'] return team_scores
def get_video_list(kata): video = {} print(kata) for j in data.keys(): for i in data[j]: video[(" %s "%kata.lower()).find(" %s "%i)] = j key = list(video.keys()) key.sort() videoList = [video[i] for i in key if i>=0] print(videoList) return videoList
def batch_update(): now = int(time.time()) with get_connection_exception('qf_mchnt') as db: keys = data.keys() constants = db.select(table='language_constant', where={ 'code': ('in', keys), 'src': SRC }, fields='code, value') constants = {i['code']: i['value'] for i in constants} # 批量插入 insert_data = [] for k, v in data.iteritems(): k = decode_from_utf8(k) if k not in constants: insert_data.append({ 'code': k, 'value': v, 'ctime': now, 'utime': now, 'src': SRC }) if insert_data: with get_connection_exception('qf_mchnt') as db: db.insert_list('language_constant', insert_data) # 批量更新 with get_connection_exception('qf_mchnt') as db: for k, v in data.iteritems(): k = decode_from_utf8(k) if k in constants and not eq(v, constants[k]): db.update(table='language_constant', values={ 'value': v, 'utime': now }, where={ 'code': k, 'src': SRC })
def ave_rp(data, sims): team_data = {} for i in range(sims): teams = random.choices(list(data.keys()), k=6) match = make_match(data, teams[:3], teams[-3:]) scores = match.sim() for team in [team.team for team in match.red_alliance.teams]: if team in list(team_data.keys()): team_data[team]['count'] += 1 team_data[team]['rp'] += int(scores[0] > scores[1]) * 2 team_data[team]['rp'] += match.red_alliance.sample_auto_quest(only_whole=True) team_data[team]['rp'] += match.red_alliance.sample_face_the_boss(only_whole=True) else: team_data[team] = {'count': 1, 'rp': int(scores[0] > scores[1]) * 2 + match.red_alliance.sample_auto_quest(only_whole=True) + match.red_alliance.sample_face_the_boss(only_whole=True) } for team in [team.team for team in match.blue_alliance.teams]: if team in list(team_data.keys()): team_data[team]['count'] += 1 team_data[team]['rp'] += int(scores[0] > scores[1]) * 2 team_data[team]['rp'] += match.blue_alliance.sample_auto_quest(only_whole=True) team_data[team]['rp'] += match.blue_alliance.sample_face_the_boss(only_whole=True) else: team_data[team] = {'count': 1, 'rp': int(scores[0] > scores[1]) * 2 + match.blue_alliance.sample_auto_quest(only_whole=True) + match.blue_alliance.sample_face_the_boss(only_whole=True) } team_scores = {} for k in team_data: team_scores[k] = team_data[k]['rp'] / team_data[k]['count'] return team_scores
while True: print("") c =input("(L)lihat, (T)ambah, (U)bah, (H)apus, (K)eluar : ") if c.lower() == 't': print("=======Tambah Data=======") nama = input("Nama : ") nim = input("Nim : ") tugas = int(input("Masukan Nilai Tugas : ")) uts = int(input("Masukan Nilai UTS : ")) uas = int(input("Masukan Nilai UAS : ")) akhir = (0.30 * tugas) + (0.35 * uts) + (0.35 * uas) data[nama] = nim, tugas, uts, uas, akhir elif c.lower() == 'u': print('=======Ubah Data Mahasiswa=======') nama = input('Nama : ') if nama in data.keys(): nim = input('Nim : ') tugas = int(input("Masukan Nilai Tugas : ")) uts = int(input("Masukan Nilai UTS : ")) uas = int(input("Masukan Nilai UAS : ")) akhir = (0.30 * tugas) + (0.35 * uts) + (0.35 * uas) data[nama] = nim, tugas, uts, uas, akhir else: print("Data Nilai Tidak Ada".format(nama)) elif c.lower() == 'l': print("=======Daftar Nilai Mahasiswa=======") print("================================================================================================") print(" |NO | NAMA | NIM | TUGAS | UTS | UAS | AKHIR | ") print("================================================================================================") i = 0
from data import data from geoprocessing import * wd = 'Z:/Dropbox/General_Assembly/Projects/project_5/data' arcpy.env.overwriteOutput = True arcpy.env.outputMFlag = "Disabled" for g in data.keys(): if (g == 'sp') | (g == 'rj'): print(f"running for {g}") geog = f"{wd}/{data[g]['census_tract']}" target = f"{wd}/{data[g]['favela']}" for i in [[geog, 'geog'], [target, 'target']]: fc_to_fc( i[0], f"{wd}/processing/processing.gdb/", f"{g}_{i[1]}", ) calculate_area( f"{wd}/processing/processing.gdb/{g}_{i[1]}", f"{i[1]}_orig_area", "squaremeters", ) # create orig area for census tract (aka geog) & favela (aka tar) study_area_circle( f"{wd}/processing/processing.gdb/{g}_target",