def UpdateElement(): ParametresLst = [] ParametresLst.extend([ CompanyEntry.get(), ProductEntry.get(), TypeNameEntry.get(), InchesEntry.get(), ScreenResolutionEntry.get(), CpuEntry.get(), RamEntry.get(), MemoryEntry.get(), GpuEntry.get(), OpSysEntry.get(), WeightEntry.get(), PriceEurosEntry.get() ]) # print(CompanyEntry.get(), '|', ProductEntry.get(), '|', TypeNameEntry.get(), '|', InchesEntry.get(), # ScreenResolutionEntry.get(), # CpuEntry.get(), '|', RamEntry.get(), '|', MemoryEntry.get(), '|', GpuEntry.get(), '|', OpSysEntry.get(), '|', WeightEntry.get(), # PriceEurosEntry.get()) # print([CompanyEntry.get(), ProductEntry.get(), TypeNameEntry.get(), InchesEntry.get(), # ScreenResolutionEntry.get(), # CpuEntry.get(), RamEntry.get(), MemoryEntry.get(), GpuEntry.get(), OpSysEntry.get(), WeightEntry.get(), # PriceEurosEntry.get()]) # print(ParametresLst) ft.update( collaborations, companies, products, float( lbox.get(lbox.curselection()).split()[ len(lbox.get(lbox.curselection()).split()) - 1]), ft.list_to_dct(ParametresLst))
def task_1_3(alpha, epochs): w1, w2 = [[0], [0]] for x in range(0, epochs): for i, j in zip(w1, w2): nw1, nw2 = f.derivative(w1, w2) w1 = f.update(i, nw1[0], alpha) w2 = f.update(j, nw2[0], alpha) return f.simple_loss([w1[0], w2[0]])
def test_update(self): self.assertEqual(functions.update("##o##", self.rules), "oo#oo") self.assertEqual(functions.update("##o###o##o##", ["##o##"]), "oo#ooo#oo#oo") self.string, self.zeroth = functions.extend_string( self.string, self.zeroth, "#", "o") self.assertEqual(functions.update(self.string, self.rules), "ooooo#ooo#oooo#ooooo#oo#oo#oo#ooooo")
def prims(edge_file_name, start_vertex, draw=False): T = ({start_vertex}, []) G = Weighted_Graph(edge_file_name) cost = 0 while T[0] != G.vertex_set(): update(T, G) if draw == True: G.draw_subgraph(T) for e in T[1]: cost += G.edge_dict()[e] return cost
def edit(sid): '''Edits/updates profile page of the show based on show id (sid)''' conn = functions.getConn('final_project') if request.method == 'GET': if 'username' not in session: flash('you are not logged in. Please login or join') return redirect(url_for('login')) show = functions.getShow(conn, sid) creators = functions.getCreators(conn, sid) warnings = functions.getWarnings(conn, sid) genres = functions.getGenres(conn, sid) tags = functions.getTags(conn, sid) return render_template('edit.html', show=show, creators=creators, warnings=warnings, tags=tags, genres=genres) if request.method == 'POST': newtitle = request.form['show-title'] newnetwork = request.form['show-network'] newyear = request.form['show-release'] newdesc = request.form['show-description'] newscript = request.form['show-script'] try: newfile = request.files['file'] except: newfile = False newgenrelist = request.form.getlist('show-genres') newcreators = request.form.getlist('show-creators') newcwList = request.form.getlist('show-warnings') tag_names = request.form.getlist('tags') tag_vals = request.form.getlist('tag-vals') if newfile: filename = functions.isValidScriptType(newfile, newtitle) if filename: newscript = filename print("*** NEW SCRIPT FILE ***") flash( '''New script uploaded. Please hit SHIFT-REFRESH to refresh the cache and see the new script if it has not updated.''') else: # file is not a valid type return redirect(request.referrer) else: print("No new script") if 'http' not in newscript: flash('''Invalid script link. Please include http:// at the beginning of the link.''') return redirect(request.referrer) functions.update(conn, sid, newtitle, newyear, newnetwork, newgenrelist, newcwList, newscript, newdesc, newcreators, tag_names, tag_vals) return redirect(url_for('profile', sid=sid))
def update(person_id): conn = dbi.connect() if 'username' in session: username = session['username'] if request.form.get('submit') == "choose": username = session['username'] feelings = request.form.get('menu') f.update(conn, feelings, username, person_id) flash('Updated stance successfully') elif request.form.get('submit') == "delete": print('delete') flash('Politician deleted from your list successfully.') f.delete(conn, person_id, username) return redirect(url_for('userpage'))
def run(surface): running = True clock = pygame.time.Clock() cursor = pygame.transform.scale(pygame.image.load("images/cursor.png") ,(16,28)) def_pos=500 button = gui.Button(surface,(100,30),(300,def_pos),(210,0,125),"Button") title = gui.Label(surface,"Fonts/JosefinSans-Bold.ttf",24,"GUI Graphical user interface",(0,0,0),(100,0)) lstbox = gui.ListBox(surface,["list item one","list item two","list item three","item four","item five"],(255,0,0),(200,200),(100,200)) rlstbox = gui.ListBox(surface,["listr item one","listr item two","listr item three","item four","item five"],(0,0,255),(200,200),(400,200)) ckbox = gui.CheckBox(surface,(255,0,0),['hello','aref','Jaffar'],(100,40)) txtbox = gui.textBox(surface,(255,0,0),(255,50,0),(0,100),(200,24)) def update(): button.update() title.update() lstbox.update() txtbox.update(); ckbox.update() rlstbox.update() while running: for event in pygame.event.get(): txtbox.event2(event) if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: txtbox.press(event) if event.key == pygame.K_ESCAPE: running = False if event.key == pygame.K_UP: button.text.color=(255,0,0) button.text.recalc() if event.type == pygame.MOUSEBUTTONDOWN: txtbox.Click() lstbox.clicked() rlstbox.clicked() ckbox.clicked() if button.clicked(): lstbox.listt.pop() lstbox.listt.append("hello") lstbox.calc() ckbox.scolor=(0,0,255) surface.fill((255,255,255)) update() functions.set_cursor(surface,cursor) functions.update(clock,60) pygame.quit()
def updateAjax(): conn = dbi.connect() feelings = request.form.get('feelings') person_id = request.form.get('person_id') if 'username' in session: uid = session['uid'] f.update(conn, feelings, uid, person_id) return jsonify({ 'error': False, 'person_id': person_id, 'feelings': feelings }) else: return jsonify({'error': True, 'err': "Please log in"})
def Prims(edge_list, start_vertex=0, draw=False, show_cost=False): G = Weighted_Graph(edge_list) T = ({start_vertex}, []) if draw == True: G.draw_graph() while T[0] != G.vertex_set(): update(T, G) if draw == True: G.draw_subgraph(T) if show_cost == True: print(f'The optimal cost: {sum([c(e,G) for e in T[1]])}') return T
def handle_text(message): functions.update() message_list = message.text.split() words = functions.word_and_synonims discriptions = functions.words_discription main_word = functions.real_name answer = '' for word in message_list: for i in range(len(words)): if word.lower() in words[i]: answer += word + ' ' if word != words[i][0] or word != main_word[i]: answer += 'или же ' + main_word[i] + ' ' answer += '- это ' + discriptions[i] + '\n' bot.send_message(message.chat.id, answer[:-1], reply_to_message_id=message.message_id)
def test_update(self, obj): a = Mock() a.rename.return_value = [] a.lrange.return_value = [] a.rpush.return_value = [] obj.return_value = a self.assertIsNone(update('', '', '', '', '', ''))
def Prims(edge_file_name, start_vertex=0, draw=False): T = ({start_vertex}, []) G = Weighted_Graph(edge_file_name) if draw == True: G.draw_graph() while T[0] != G.vertex_set(): T = update(T, G) G.draw_subgraph(T) print("The minimum spanning tree costs: " + str(total_sum(T, G))) return T
def run(scheme='RK4', step=1e-2, pdf=False, mp4=False): t0 = time_module.time() print '\n~~~~~~~~~~~~~~ Running two_body program ~~~~~~~~~~~~~~~\n' print 'Using {} scheme'.format(scheme) # assign the initial positions, velocities and masses xarr, varr, marr = fn.setup_2body(ecc=0.) # decelerations time = 0 # start time tfinal = 1e8 #pars.yr*10 dt = step * pars.yr print '\ttimestep of {:.0e} years'.format(dt / pars.yr) print '\tend time of {:.3f} years'.format(tfinal / pars.yr) # compute the total energy, used for verification etot0 = fn.e_tot(xarr, varr, marr) # start main loop # store positions and velocities xarrs, varrs = [], [] while time < tfinal: # calculate forces, update positions and velocities # this involves calling the function that computes the accelerations xarr, varr = fn.update(xarr, varr, marr, dt, scheme=scheme) xarrs.append(xarr.copy()) varrs.append(varr.copy()) # increment time time += dt #end etot = fn.e_tot(xarr, varr, marr) error = (etot - etot0) / etot0 print 'Initial total energy of {:.2e}, final total energy of {:.2e}.\nError of {:.2e}\n'.format( etot0, etot, error) print 'Time taken: {:.2f}s\n'.format(time_module.time() - t0) #visualize.orbit_plot_lines(xarrs, ['y', 'k']) if pdf: visualize.orbit_pdf(xarrs, marr, 0, dt) if mp4: fname = '{}_{:.0g}.mp4'.format(scheme.lower(), dt / pars.yr) visualize.make_mp4(xarrs, marr, 0, dt, mp4_file=fname) return error
def server_post(): action = request.forms.get('action') if action == "CREATE": student = request.forms.get('student') subjects = request.forms.get('subjects') rates = request.forms.get('rates') create(student, subjects, rates) elif action == "UPDATE": student= request.forms.get('student') prev_subject = request.forms.get('prev_subject') prev_mark = request.forms.get('prev_mark') new_student = request.forms.get('new_student') new_subject = request.forms.get('new_subject') new_mark = request.forms.get('new_mark') update(student, prev_subject, prev_mark, new_student, new_subject, new_mark) elif action == "DELETE": student = request.forms.get('student') subject = request.forms.get('subject') mark = request.forms.get('mark') delete(student, subject, mark)
def command_line(dictionary): while True: command = input('Enter your command: ') if command == 'exit': return 'exit' elif command == 'move': functions.move() elif command == 'help': for command, description in list(commands_list.items()): print(command + ' = ' + description) elif command == 'add': functions.add() return functions.update() elif command == 'remove': functions.remove() elif command == 'print': continue elif command == 'show': functions.show() elif command == 'train': return functions.train(dictionary)
for data in result: if (dataHistory[0] == data[0]): a = 1 if (a == 0): print("-- RUN DELETE FOR ID = %d" % (dataHistory[0])) functions.delete(config.histories_1[0], dataHistory, cursor_bank, db_bank) functions.delete(config.histories_1[0], dataHistory, cursor_toko, db_toko) functions.delete(config.tables_1[0], dataHistory, cursor_toko, db_toko) #update listener if (result != history): print("-- EVENT SUCCESS OR UPDATE DETECTED --") for data in result: for dataHistory in history: if (data[0] == dataHistory[0]): if (data != dataHistory): functions.update(config.histories_1[0], data, cursor_bank, db_bank) functions.update(config.histories_1[0], data, cursor_toko, db_toko) functions.update(config.tables_1[0], data, cursor_toko, db_toko) except (pymysql.Error, pymysql.Warning) as e: print(e) # Untuk delay time.sleep(1)
def update(self): self.text_field.text = functions.update() self.year_field.text = (f"Du bist {str(functions.year)} Jahre alt.")
def update_message(message): func.update(str(message.from_user.username)) bot.send_message(message.from_user.id, "Ваши дедлайны успешно обновлены")
UT = np.zeros((N + 1, NT)) Cv = np.zeros((N, NT)) acceptance_r = np.zeros((N, NT)) T2 = np.zeros((N, NT)) T1 = np.zeros((N, NT)) # R,dx,dy = f.grid(width, length, N, theta) # fignr = 0 # pf.orientation(fignr, R[:,:,0], dx, dy, width, length) #%% Algorithm theta = np.zeros((width, length, N)) [theta, UTb, avUT, scaledenergy, acceptance_r, Cv, T2, T1, Ui] = f.update(Uiold, Uinew, Ui, UT, theta, length, width, epsilon, T, mu, N, M, delta, k, acceptance_r, Cv, NT, kT, T2, T1) #%% thetadirec = np.linspace(-np.pi, np.pi, 360) Uidirec = -epsilon * (np.cos(2 * thetadirec) + mu * np.cos(thetadirec)) #%% Fitting specific heat x = np.zeros( (int(N / 2) - 1, NT) ) # x is confusing but it was meant as xi (and it is actually y data to make it even better :p) taucv = np.zeros(NT) sigmacv = np.zeros(NT) for i in range(NT): x[:, i] = f.error(Cv[int(N / 2):, i]) taucv[i], pp = curve_fit(f.function,
import regex as re import functions with open(sys.argv[1], "r") as f: text = f.readlines() text = [line.strip() for line in text] iterations = int(input("Enter the number of iterations: ")) rules = [] zeroth = 0 for line in text: line = re.sub("\.", "o", line) if "initial" in line: *head, state = line.split() elif "=> #" in line: sub_state, _, result = line.split() rules.append(sub_state) #print(f"i.0:\t{state}") for i in range(iterations): state, zeroth = functions.extend_string(state, zeroth, "#", "o") state, zeroth = functions.reduce_string(state, zeroth, "#", "o") state = functions.update(state, rules) # print(f"i.{i + 1}:\t{state}") count = functions.count(state, zeroth, "#") print( f"After {iterations} iterations, the sum of the values of pots containing plants is {count}." )
''' Created on 2015-05-27 @author: legnain ''' import functions as fun if __name__ == '__main__': input_file = "emails.csv" daily_count_file = "domain.csv" output_file= "report.csv" daily_domain_list = fun.domains_extract(input_file) daily = fun.update(daily_domain_list, daily_count_file) fun.report30days(daily_count_file, output_file) print " The main file is working"
from functions import showMenu, create, remove, show, update n = 1 while n > 0: showMenu() n = int(input('Uildliin dugaar oruulna uu: ')) if n == 1: show() elif n == 2: create() elif n == 3: remove() elif n == 4: update() else: print('Ta programaas garlaa...') break