def runTagCheckDouble(api_value, web_page_data1, web_page_data2, tag): """ Using the provided web page data sources, find the content for the tag. Then compare the content values with the expected api value. Return True or False. This function expects a content value and a two web page data sources. Use runTagCheck if expecting only one content value and one web page data source. Use runTagListCheck if expecting multiple content values (in a list). Use runTagListCheckDouble if there are two web page data sources AND content values are in a list. """ # Function returns string in upper case branch_io_tag_from_html_url1 = functions.get_meta_tag_content( web_page_data1, "", tag) branch_io_tag_from_html_url2 = functions.get_meta_tag_content( web_page_data2, "", tag) # Comparison time match1 = functions.compare(api_value, branch_io_tag_from_html_url1) match2 = functions.compare(api_value, branch_io_tag_from_html_url2) if match1 == True and match2 == True: message = " TEST for %s: %s\n" % (tag, PASSED) functions.show_message(message) return True else: message = " TEST for %s: %s\n" % (tag, FAILED) functions.show_message(message) return False
def runTagListCheck(api_value, web_page_data, tag): """ Using the provided web page data source, find the listed content for the tag. Then compare that listed value with the expected api listed value. Return True or False. This function expects a list of content values and a single web page data source. Use runTagCheck if expecting only one content value and one web page data source. Use runTagCheckDouble if there are two web page data sources but only one content value. Use runTagListCheckDouble if there are two web page data sources AND content values are in a list. """ # Function returns string in upper case branch_io_tag_from_html_url = functions.get_meta_tag_content_list( web_page_data, "", tag) # Comparison time match = functions.compare(api_value, branch_io_tag_from_html_url) if match == True: message = " TEST for %s: %s\n" % (tag, PASSED) else: message = " TEST for %s: %s\n" % (tag, FAILED) functions.show_message(message) return match
def build(self): for key in self.game.room_image_dict: if fn.compare(self.doors, key): self.image = self.game.room_image_dict[key] #self.image = self.game.room_image_dict[self.doors] self.tileRoom()
def compare_page(): ''' Get the user's stats and the other user's stats and presents it ''' other_user = request.form.get("other_user_name") # if user input is incorrect, return an error if compare(other_user) == False: flash("Invalid username!") return render_template("index.html") other_user_stats = compare(other_user) # get the user's stats and ranks statistics = stats() correct = statistics[0] score = statistics[1] # generate user ranking in all lists rankings = ranks() rank_nr = rankings[0] rank_score = rankings[1] # get the other user's stats and ranks other_correct = other_user_stats[0] other_score = other_user_stats[1] other_rank_nr = other_user_stats[2] other_rank_score = other_user_stats[3] user = { "correct": correct, "score": score, "rank_nr": rank_nr, "rank_score": rank_score } other_user = { "name": other_user, "correct": other_correct, "score": other_score, "rank_nr": other_rank_nr, "rank_score": other_rank_score } data = [] data.append(user) data.append(other_user) return render_template("compare.html", data=data)
def compareAndPrint(expected, actual): """ This function simply makes a compare, prints PASSED/FAILED, and returns True/False. """ match = functions.compare(expected, actual) if match: message = " TEST: %s\n" % PASSED else: message = " TEST: %s\n" % FAILED functions.show_message(message) return match
def test_nmc_pid(prod_web_page_data, preprod_web_page_data, expected_pid): """ Takes prod_web_page_data, preprod_web_page_data, and an expected_pid. The function will find the nmc:pid for each of the prod and preprod web pages. Then it will compare that pid with the expected pid. This function returns two results: true/false for the prod page and true/false for the preprod page. """ # Get the pid from the page. Function returns string in upper case. pid_from_html_prod = functions.get_meta_tag_content( prod_web_page_data, "", "nmc:pid") pid_from_html_preprod = functions.get_meta_tag_content( preprod_web_page_data, "", "nmc:pid") # Compares the expected pid with the one found on the page. Response is true if it is a match; false if not. print("Checking HTML nmc:pid on PROD") isMatch1 = functions.compare(expected_pid, pid_from_html_prod) print("Checking HTML nmc:pid on PREPROD") isMatch2 = functions.compare(expected_pid, pid_from_html_preprod) return isMatch1, isMatch2
def findlabel(feature_model, dimension_reduction, k, label_choice, image_id): descriptor_type = DescriptorType(feature_model).descriptor_type symantics_type = LatentSymanticsType(dimension_reduction).symantics_type label, value, complementary_value = Labels(label_choice).label source = Database().retrieve_one(image_id, 5) label_targets = Database().retrieve_many(5, label, value) complementary_label_targets = Database().retrieve_many( 5, label, complementary_value) label_similarity_info = functions.compare(source, label_targets, 1, descriptor_type) complementary_label_similarity_info = functions.compare( source, complementary_label_targets, 1, descriptor_type) if label_similarity_info[0][1] > complementary_label_similarity_info[0][1]: predicted = Labels(label_choice)._detupleize_label((label, value)) else: predicted = Labels(label_choice)._detupleize_label( (label, complementary_value)) print(predicted)
def starter(feature_model, dimension_reduction, k, image_id, m): if not feature_model: target_results = Database().retrieve_many(task=1) source_result = Database().retrieve_one(image_id, task=1) descriptor_type = source_result["descriptor_type"] else: _, _ = functions.store_in_db(feature_model, dimension_reduction, k, 2) target_results = Database().retrieve_many(task=2) source_result = Database().retrieve_one(image_id, task=2) descriptor_type = source_result["descriptor_type"] print(functions.compare(source_result, target_results, m, descriptor_type))
def test_nmc_pid_single(web_page_data, expected_pid): """ Takes web_page_data and an expected_pid. The function will find the nmc:pid for the web page. Then it will compare that pid with the expected pid. This function returns one result: true/false. """ # Get the pid from the page. Function returns string in upper case. pid_from_html = functions.get_meta_tag_content(web_page_data, "", "nmc:pid") # Compares the expected pid with the one found on the page. Response is true if it is a match; false if not. print("Checking HTML nmc:pid") isMatch = functions.compare(expected_pid, pid_from_html) return isMatch
def starter(feature_model, dimension_reduction, k, label_choice, image_id, m): if not feature_model: target_results = Database().retrieve_many(task=3) source_result = Database().retrieve_one(image_id, task=3) descriptor_type = source_result["descriptor_type"] else: label, value, _ = Labels(label_choice).label filtered_image_ids = [ item["image_id"] for item in Database().retrieve_metadata_with_labels(label, value) ] _, _ = functions.store_in_db(feature_model, dimension_reduction, k, 4, filtered_image_ids, label, value) target_results = Database().retrieve_many(task=4) source_result = Database().retrieve_one(image_id, task=4) descriptor_type = source_result["descriptor_type"] print(functions.compare(source_result, target_results, m, descriptor_type))
def runTagCheck(api_value, web_page_data, tag): """ Using the provided web page data source, find the content for the tag. Then compare that content value with the expected api value. Return True or False. This function expects a single content value and a single web page data source. """ # Function returns string in upper case branch_io_tag_from_html_url = functions.get_meta_tag_content(web_page_data, "", tag) # Comparison time match = functions.compare(api_value, branch_io_tag_from_html_url) if match == True: message = " TEST for %s: %s\n" % (tag, PASSED) else: message = " TEST for %s: %s\n" % (tag, FAILED) functions.show_message(message) return match
def insertToLog(file1, arr): # this needs to be the non file extension x = 0 db = c1() cursor = db.cursor() l1 = compare(arr) size = len(l1) if (size != 0): while (x != len(l1)): val = str(l1[x]) #state = getStatement(file1) tup = (val, ) if (file1 == "auth"): state = "INSERT INTO auth(ipAddr) VALUES (%s);" cursor.execute(state, tup) elif (file1 == "syslog"): state = "INSERT INTO syslog(ipAddr) VALUES (%s);" cursor.execute(state, tup) elif (file1 == "ufw"): state = "INSERT INTO ufw(ipAddr) VALUES (%s);" cursor.execute(state, tup) elif (file1 == "access"): state = "INSERT INTO access(ipAddr) VALUES (%s);" cursor.execute(state, tup) elif (file1 == "error"): state = "INSERT INTO error(ipAddr) VALUES (%s);" cursor.execute(state, tup) elif (file1 == "proftpd"): state = "INSERT INTO proftpd(ipAddr) VALUES (%s);" cursor.execute(state, tup) print("Will be excuted: ", state) db.commit() s(1) x += 1 db.close()
def main(argv): try: opts, args = getopt.getopt(argv,"hi:o:s:t:f:n:a:b:c:d:g:") except getopt.GetoptError: functions.printHelp() sys.exit(2) for opt, arg in opts: if opt == '-h': functions.printHelp() sys.exit() elif opt == '-i': inputfile = arg elif opt == '-o': outputType = arg elif opt == '-s': sourcefile = arg elif opt == '-t': targetfile = arg elif opt == '-f': from_system = arg elif opt == '-n': num = arg elif opt == '-v': from_system2 = arg elif opt == '-w': inputfile2 = arg elif opt == '-x': sourcefile2 = arg elif opt == '-y': targetfile2 = arg elif opt == '-c': config_file = arg try: config_file except NameError: config_file = False if(config_file): # There is a config file! Get info about inputs config = cp.ConfigParser() config.read(config_file) try: inputfile = config.get('AlignmentsOne', 'InputFile') except NameError: print ('Provide an input file!\n') functions.printHelp() sys.exit() try: from_system = config.get('AlignmentsOne', 'From') except cp.NoOptionError: from_system = 'NeuralMonkey' try: num = config.getint('Options', 'Number') except (cp.NoOptionError, cp.NoSectionError): num = -1 try: outputType = config.get('Options', 'OutputType') except (cp.NoOptionError, cp.NoSectionError): # Set output type to 'web' by default outputType = 'web' if from_system == 'NeuralMonkey' or from_system == 'Marian': try: sourcefile = config.get('AlignmentsOne', 'SourceFile') except cp.NoOptionError: print ('Provide a source sentence file!\n') functions.printHelp() sys.exit() if from_system == 'NeuralMonkey': try: targetfile = config.get('AlignmentsOne', 'TargetFile') except cp.NoOptionError: print ('Provide a target sentence file!\n') functions.printHelp() sys.exit() if outputType == 'compare': try: from_system2 = config.get('AlignmentsTwo', 'From') except cp.NoOptionError: from_system2 = 'NeuralMonkey' try: inputfile2 = config.get('AlignmentsTwo', 'InputFile') except cp.NoOptionError: print ('Provide a input file for the second system!\n') functions.printHelp() sys.exit() if from_system2 == 'NeuralMonkey' or from_system2 == 'Marian': try: sourcefile2 = config.get('AlignmentsTwo', 'SourceFile') except cp.NoOptionError: print ('Provide a source sentence file for the second system!\n') functions.printHelp() sys.exit() if from_system2 == 'NeuralMonkey': try: targetfile2 = config.get('AlignmentsTwo', 'TargetFile') except cp.NoOptionError: print ('Provide a target sentence file for the second system!\n') functions.printHelp() sys.exit() else: # There is no config file. Look for inputs in parameters try: inputfile except NameError: print ('Provide an input file!\n') functions.printHelp() sys.exit() try: from_system except NameError: from_system = 'NeuralMonkey' try: num except NameError: num = -1 try: outputType except NameError: # Set output type to 'web' by default outputType = 'web' if from_system == 'NeuralMonkey' or from_system == 'Marian': try: sourcefile except NameError: print ('Provide a source sentence file!\n') functions.printHelp() sys.exit() if from_system == 'NeuralMonkey': try: targetfile except NameError: print ('Provide a target sentence file!\n') functions.printHelp() sys.exit() if outputType == 'compare': try: from_system2 except NameError: from_system2 = 'NeuralMonkey' try: inputfile2 except NameError: print ('Provide a input file for the second system!\n') functions.printHelp() sys.exit() if from_system2 == 'NeuralMonkey' or from_system2 == 'Marian': try: sourcefile2 except NameError: print ('Provide a source sentence file for the second system!\n') functions.printHelp() sys.exit() if from_system2 == 'NeuralMonkey': try: targetfile2 except NameError: print ('Provide a target sentence file for the second system!\n') functions.printHelp() sys.exit() if outputType != 'color' and outputType != 'block' and outputType != 'block2' and outputType != 'compare': # Set output type to 'web' by default outputType = 'web' if from_system == "NeuralMonkey": srcs = functions.readSnts(sourcefile) tgts = functions.readSnts(targetfile) alis = np.load(inputfile) if from_system == "Nematus" or from_system == "Sockeye": (srcs, tgts, alis) = functions.readNematus(inputfile) if from_system == "OpenNMT": (srcs, tgts, alis) = functions.readNematus(inputfile, 1) if from_system == "Marian": (srcs, tgts, alis) = functions.readAmu(inputfile, sourcefile) data = list(zip(srcs, tgts, alis)) if outputType == 'compare': if from_system2 == "NeuralMonkey": srcs2 = functions.readSnts(sourcefile2) tgts2 = functions.readSnts(targetfile2) alis2 = np.load(inputfile2) if from_system2 == "Nematus" or from_system2 == "Sockeye": (srcs2, tgts2, alis2) = functions.readNematus(inputfile2) if from_system2 == "OpenNMT": (srcs2, tgts2, alis2) = functions.readNematus(inputfile2, 1) if from_system2 == "Marian": (srcs2, tgts2, alis2) = functions.readAmu(inputfile2, sourcefile2) data2 = list(zip(srcs2, tgts2, alis2)) if functions.compare(srcs, srcs2) == False: print ('Source senctences from both systems need to be identical!\n') functions.printHelp() sys.exit() foldername = ntpath.basename(inputfile).replace(".","") + "_" + strftime("%d%m_%H%M", gmtime()) if outputType == 'compare': foldername = 'cmp_' + foldername folder = './web/data/' + foldername try: os.stat(folder) except: os.mkdir(folder) if outputType == 'compare': try: os.stat(folder + '/NMT1') except: os.mkdir(folder + '/NMT1') try: os.stat(folder + '/NMT2') except: os.mkdir(folder + '/NMT2') functions.synchData(data,data2) functions.processAlignments(data, folder + '/NMT1', inputfile, outputType, num) functions.processAlignments(data2, folder + '/NMT2', inputfile2, outputType, num) else: functions.processAlignments(data, folder, inputfile, outputType, num) # Get rid of some junk if outputType == 'web' or outputType == 'compare': webbrowser.open("http://127.0.0.1:47155/?directory=" + foldername) os.system("php -S 127.0.0.1:47155 -t web") else: os.remove(folder + "/" + ntpath.basename(inputfile) + '.ali.js') os.remove(folder + "/" + ntpath.basename(inputfile) + '.src.js') os.remove(folder + "/" + ntpath.basename(inputfile) + '.trg.js') os.remove(folder + "/" + ntpath.basename(inputfile) + '.con.js') os.remove(folder + "/" + ntpath.basename(inputfile) + '.sc.js') os.rmdir(folder)
# print('Lenght of dic: %d'%(len(dic.keys()))) for node in G.nodes(): if (node in ess) and (node in dic.keys()): c+=1 sig.append(dic[node]) # print(c) for i in range(niter): chig=[] if name in ("Information_Centrality","Random_Walk_Betweenness_Centrality","Communicability_Betweenness"): # print('sds') sampled_nodes=rd.sample(trimmed_G.nodes(),c) else: sampled_nodes=rd.sample(G.nodes(),c) for node in sampled_nodes: chig.append(dic[node]) P.append(f.compare(sig,chig)) p_vals_mean[name]=len([i for i in P if i[0]>2.33]) p_vals_med[name]=len([i for i in P if i[1]>2.33]) print("\np values:") for name in p_vals_mean: print(name) print(f.printpv(p_vals_mean[name],niter)) print(f.printpv(p_vals_med[name],niter)) with open('p_val_data/%s/%s.pval'%(string_location,org_name),'w') as file: file.write('pvaltype\tmean\tmedian\n') centrality_list=list(dicshs) for x in centrality_list: file.write(str(x)+'\t'+f.printpv(p_vals_mean[x],niter)+'\t'+f.printpv(p_vals_med[x],niter)+'\n')
elif temp == 'B' or temp == 'b': # We calculate k(e, B) functions.nrofoccurrances(multisetB) else: print("Not a valid input") if check == '8': # We select the operation we want to perform temp = input( "Which operation would you like to perform:\n1 - Inclusion(A subset of B)\n2 - Union(A | B)\n3 - " "Subtraction(A - B)\n4 - " "Intersection(A & B)\n5 - Comparrison\n# ") if temp == '1': # We check if A is a subset of B functions.inclusion(multisetA, multisetB) if temp == '2': # We unite A and B functions.union(multisetA, multisetB) if temp == '3': # We subtract B from A functions.subtraction(multisetA, multisetB) if temp == '4': # We intersect A and B functions.intersection(multisetA, multisetB) if temp == '5': # We compare A and B functions.compare(multisetA, multisetB) if check == '9': temp = input( "Which set would you like to perform this operation for?(A/B) ") if temp == 'A' or temp == 'a': # We output A print("A = ") functions.outputset(multisetA) elif temp == 'B' or temp == 'b': # We output B print("B = ") functions.outputset(multisetB) else: print("Not a valid input")
ax.set_axisbelow(True) ax.grid(True) ax.set_xlabel(f'{metric}') ax.set_title(f'{metric}\nMean = {round(mean,2)}, Standard Deviation = {round(std,2)}') st.pyplot(fig) # Comparison st.header('Compare Two Universities') uni_col1, uni_col2 = st.beta_columns(2) uni1 = uni_col1.selectbox('University 1', df.index) uni2 = uni_col2.selectbox('University 2', df.index) stats1, stats2 = compare(df, uni1, uni2) comp_cols = ['% Satisfied with Teaching', '% Satisfied with Course', '% Satisfied with Assessment', 'Continuation %', '% Graduates in High Skilled Work', 'Applications to Acceptance (%)', 'Student/Staff Ratio', 'Average Salary', 'Academic Services Expenditure per Student', 'Facilities Expenditure per Student'] comparison = pd.DataFrame([df.loc[uni1], df.loc[uni2]])[comp_cols] comparison.reset_index(inplace=True) chart_columns = st.beta_columns(2)
def main(): """Funkcja wykonująca cały program""" modul = modules.Modules() fun = function.Functions() file = files.Files() register = registration.Registration() files_with_code = pythonfiles.FileInDirectory() path = r'.\\' extend = 'py' result = files_with_code.list_directory(path, extend) files.Files.checking_connections_between_files(result) function_list1 = function.Functions.checking_connections_between_functions1( result) function_list2 = fun.checking_weight_of_connections_between_functions( result, function_list1) weight_fun = functions.write_to_file_fun_data(function_list1, function_list2) function.Functions.checking_connections_between_functions( result, weight_fun) modul_list = modules.Modules.searching_for_used_modules(result) modules.Modules.checking_connections_between_modules(result, modul_list) join_list = functions.convert_list_to_list_for_cc( files.Files.filesConnectionList, modules.Modules.modulConnectionList) join_list = list(set(join_list)) cyclomatic_complexity = functions.cyclomatic_complexity() cyclomatic_complexity = functions.compare(function_list1, cyclomatic_complexity) cyclomatic_complexity += join_list menu_choice = functions.menu() if menu_choice == 1: registration.Registration.write_to_file( "FILES", files.Files.filesConnectionList ) # Wpisywanie do pliku połączeń plików registration.Registration.write_to_file( "", files.Files.filesConnectionWeight) elif menu_choice == 2: registration.Registration.write_to_file( "Functions", function.Functions.functionsConnectionList ) # Wpisywanie do pliku połączeń funkcji registration.Registration.write_to_file( "", function.Functions.functionsConnectionWeight) registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY", cyclomatic_complexity) elif menu_choice == 3: registration.Registration.write_to_file( "Modules", files.Files.filesConnectionList ) # Wpisywanie do pliku połączeń modułów registration.Registration.write_to_file( "", modul.Modules.modulConnectionWeight) elif menu_choice == 4: registration.Registration.write_to_file( "FILES", files.Files.filesConnectionList ) # Wpisywanie do pliku połączeń plików registration.Registration.write_to_file( "", files.Files.filesConnectionWeight) registration.Registration.write_to_file( "Functions", function.Functions.functionsConnectionList ) # Wpisywanie do pliku połączeń funkcji registration.Registration.write_to_file( "", function.Functions.functionsConnectionWeight) registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY", cyclomatic_complexity) elif menu_choice == 5: registration.Registration.write_to_file( "FILES", files.Files.filesConnectionList ) # Wpisywanie do pliku połączeń plików registration.Registration.write_to_file( "", files.Files.filesConnectionWeight) registration.Registration.write_to_file( "Modules", modules.Modules.modulConnectionList ) # Wpisywanie do pliku połączeń modułów registration.Registration.write_to_file( "", modules.Modules.modulConnectionWeight) elif menu_choice == 6: registration.Registration.write_to_file( "Functions", function.Functions.functionsConnectionList ) # Wpisywanie do pliku połączeń funkcji registration.Registration.write_to_file( "", function.Functions.functionsConnectionWeight) registration.Registration.write_to_file( "Modules", modules.Modules.modulConnectionList ) # Wpisywanie do pliku połączeń modułów registration.Registration.write_to_file( "", modules.Modules.modulConnectionWeight) registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY", cyclomatic_complexity) elif menu_choice == 7: registration.Registration.write_to_file( "FILES", files.Files.filesConnectionList ) # Wpisywanie do pliku połączeń plików registration.Registration.write_to_file( "", files.Files.filesConnectionWeight) registration.Registration.write_to_file( "Functions", function.Functions.functionsConnectionList ) # Wpisywanie do pliku połączeń funkcji registration.Registration.write_to_file( "", function.Functions.functionsConnectionWeight) registration.Registration.write_to_file( "Modules", modules.Modules.modulConnectionList ) # Wpisywanie do pliku połączeń modułów registration.Registration.write_to_file( "", modules.Modules.modulConnectionWeight) registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY", cyclomatic_complexity) else: print("Wybrałeś opcję z poza zakresu") main()
title_failed = 0 desc_failed = 0 # Title should exist and be exactly like this: # sanitized print(" TEST 1: Title Check") expected_title = "sanitized" expected_title = expected_title.upper() # Function returns string in upper case title = functions.get_title(page_data) og_title = functions.get_meta_tag_content(page_data, "og:title") twitter_title = functions.get_meta_tag_content(page_data, "", "twitter:title") # Comparison time match1 = functions.compare(expected_title, title) match2 = functions.compare(expected_title, og_title) match3 = functions.compare(expected_title, twitter_title) if match1 and match2 and match3: message = " Podcast title: %s\n" % PASSED else: message = " Podcast title: %s\n" % FAILED title_failed += 1 functions.show_message(message) # Description should exist and be exactly like this: # sanitized print(" TEST 2: Description Check")
val = lassoData.lassoValData() test = lassoData.lassoTestData() true_w = pl.loadtxt('lasso_true_w.txt') #True value for the data #Step 1: transform data X = train[0] Y = train[1] (Xc, Yc) = fun.center_data(X, Y) alpha = 0.2 fig = plt.figure() fig.add_subplot(121) w1 = fun.compare(X, Y, M=12, alpha=alpha, basis=fun.basis_sin) plt.bar(range(13), w1[0], color='teal') plt.title('LASSO') fig.add_subplot(122) plt.bar(range(13), w1[1], color='purple') plt.title('ridge') plt.show() fig = plt.figure() fig.add_subplot(121) plt.plot() fig.add_subplot(122) plt.bar(range(13), w1[0], color='teal') plt.title('lambda' =alpha) plt.plot(range(10), np.ones(10), '--r')
def main(): global models global modelThreshold global modelScore print("") print("This script can only process conf.CHUNK (currently: " + str(conf.CHUNK) + ") frames per loop so if the file contains a number of frames which is not divisible by conf.CHUNK the last few frames are dropped") model = [] wavenumber = 1 fileName, modelName, optimalFrames, scriptpath = interactions.getTrainParameters() beginning = time.time() # do it while there are wave files wf = [] while os.path.isfile(str(fileName) + "/" + str(wavenumber) + ".wav"): wf.append((wave.open(str(fileName) + "/" + str(wavenumber) + ".wav"), wavenumber)) print("File " + str(fileName) + "/" + str(wavenumber) + ".wav found.") wavenumber += 1 for i in wf: model.append(preprocess(i)) for i in wf: i[0].close() wavenumber -= 1 print("Processed " + str(wavenumber) + " files in " + str(time.time() - beginning) + " seconds, minimalize them.") if model != []: data = [] for i in range(wavenumber): data.append( (model[i], optimalFrames)) beginning = time.time() f.clearTmpFolder() pool = multiprocessing.Pool(processes=4) result = pool.map(f.minimalizeAndCalcThreshold, data) minimalizedRecords = [] calculatedThresholds = [] for i in result: minimalizedRecords.append(i[0]) calculatedThresholds.append(i[1]) zeroFrame = np.zeros(conf.FEATURES_PER_FRAME, dtype=np.float64) models = [] for i in range(len(minimalizedRecords)): features = copy.deepcopy(minimalizedRecords[i]) tmpFeatures = [copy.deepcopy(zeroFrame) for number in range(optimalFrames)] tmpCounter = [0 for number in range(optimalFrames)] counter = 0. posCounter = [0 for number in range(len(minimalizedRecords))] # for every frame in this record try if we find mergable frames for h in range(optimalFrames): # we try all recordings for j in range(len(minimalizedRecords)): if f.compare(minimalizedRecords[j][h], features[h]) < calculatedThresholds[i][h]: tmpFeatures[h] += minimalizedRecords[j][h] tmpCounter[h] += 1 for h in range(optimalFrames): tmpFeatures[h] = np.divide(tmpFeatures[h], tmpCounter[h]) counter += tmpCounter[h] counter /= optimalFrames models.append(modelImport.Model(tmpFeatures, calculatedThresholds[i], modelName, tmpCounter, scriptpath)) print() print("Computed the models in " + str(time.time() - beginning) + " seconds. Compute their score.") print() beginning = time.time() data = [] for i in range(len(models)): data.append((models[i], fileName, i)) pool = multiprocessing.Pool(processes=4) pool.map(q.qualityCheck, data) models = f.loadModels(tmp=True) print("Computed the scores in " + str(time.time() - beginning) + " seconds.") print() for i in range(len(models)): print("Model Nr:\t" + str(i + 1) + " | Frames:\t" + str(len(models[i].features)) + " | Matches:\t" + str(models[i].matches) + " | Influenced by:\t" + str(models[i].influencedBy) + " | Threshold:\t" + str(models[i].threshold) + " | Score:\t" + str(models[i].score)) # get the model number and substract 1 because list indexing starts # with 0 modelNumber = interactions.getModelNumber(len(models)+1) - 1 print("You selected Model " + str(modelNumber) + " with " + str(models[modelNumber].matches) + " Matches and a Score of: " + str(models[modelNumber].score)) f.storeModel(models[modelNumber])