How to use collected method in Selene

Best Python code snippet using selene_python

balance_data.py

Source:balance_data.py Github

copy

Full Screen

1import numpy as np2import pandas as pd3import os4import cv25from collections import Counter6from input_choices import \7 input_w, input_a, input_s, input_d, \8 input_wa, input_wd, input_ws, input_wsa, \9 input_wsd, input_sa, input_sd, input_nk10from random import shuffle11# for looking at and balancing data sets12# train_data = np.load('data/training_data-1.npy', allow_pickle=True)13# data_frame = pd.DataFrame(train_data)14# print(data_frame.head())15# print(Counter(data_frame[1].apply(str)))16# for data in train_data:17# img = data[0]18# choice = data[1]19# cv2.imshow('test', img)20# print(choice)21# print(img.shape)22# if cv2.waitKey(25) & 0xFF == ord('q'):23# cv2.destroyAllWindows()24# break25# all possible inputs26collected_input_w = []27collected_input_a = []28collected_input_s = []29collected_input_d = []30collected_input_wa = []31collected_input_wd = []32collected_input_ws = []33collected_input_wsa = []34collected_input_wsd = []35collected_input_sa = []36collected_input_sd = []37collected_input_nk = []38# load data39starting_value = 140while True:41 file_name = 'data/training_data-{}.npy'.format(starting_value)42 if os.path.isfile(file_name):43 # load existing data44 print('training_data-{}.npy exists! Loading data...'.format(starting_value))45 curr_data_set = np.load(file_name, allow_pickle=True)46 # analyze data47 data_frame = pd.DataFrame(curr_data_set)48 print(Counter(data_frame[1].apply(str)))49 # split data into singular arrays defined above50 for data in curr_data_set:51 img = data[0]52 choice = data[1]53 if choice == input_w:54 collected_input_w.append([img, choice])55 elif choice == input_a:56 collected_input_a.append([img, choice])57 elif choice == input_s:58 collected_input_s.append([img, choice])59 elif choice == input_d:60 collected_input_d.append([img, choice])61 elif choice == input_wa:62 collected_input_wa.append([img, choice])63 elif choice == input_wd:64 collected_input_wd.append([img, choice])65 elif choice == input_ws:66 collected_input_ws.append([img, choice])67 elif choice == input_wsa:68 collected_input_wsa.append([img, choice])69 elif choice == input_wsd:70 collected_input_wsd.append([img, choice])71 elif choice == input_sa:72 collected_input_sa.append([img, choice])73 elif choice == input_sd:74 collected_input_sd.append([img, choice])75 elif choice == input_nk:76 collected_input_nk.append([img, choice])77 else:78 print("No match for data found!")79 starting_value += 180 else:81 break82collected_data = [collected_input_w, collected_input_a, collected_input_s, collected_input_d,83 collected_input_wa, collected_input_wd, collected_input_ws, collected_input_wsa,84 collected_input_wsd, collected_input_sa, collected_input_sd, collected_input_nk]85total_len = 086highest_nb_input = 087input_idx = 188for cdi in collected_data:89 total_len += len(cdi)90 print(f"Len of current cdi: {len(cdi)}")91 if len(cdi) > highest_nb_input:92 highest_nb_input = len(cdi)93 input_idx += 194avg_len = total_len / input_idx95print(f"Average amount of inputs: {avg_len}")96print(f"Highest number of inputs: {highest_nb_input}")97max_samples_allowed = int(highest_nb_input / 2)98balanced_data = []99for cdi in collected_data:100 curr_cdi = cdi101 while len(curr_cdi) < max_samples_allowed:102 print(f"curr_cdi len {len(curr_cdi)}")103 curr_cdi += curr_cdi104 if len(curr_cdi) >= max_samples_allowed:105 cdi_limited = curr_cdi[:max_samples_allowed]106 print(f"FINAL curr_cdi len {len(cdi_limited)}")107 balanced_data += cdi_limited108 else:109 balanced_data += cdi110shuffle(balanced_data)111# analyze data112data_frame = pd.DataFrame(balanced_data)113print(Counter(data_frame[1].apply(str)))114np.save("data/training_data_balanced.npy", balanced_data)115# avg_len = (len(collected_input_w) + len(collected_input_a) + len(collected_input_s) + len(collected_input_d)116# + len(collected_input_wa) + len(collected_input_wd) + len(collected_input_ws) + len(collected_input_wsa)117# + len(collected_input_wsd) + len(collected_input_sa) + len(collected_input_sd) + len(collected_input_nk)) \...

Full Screen

Full Screen

NCBI_Biosample_batch.py

Source:NCBI_Biosample_batch.py Github

copy

Full Screen

1#!/opt/Python/2.7.3/bin/python2import sys3from collections import defaultdict4import numpy as np5import re6import os7import argparse8import glob9from Bio import SeqIO10sys.path.append('/rhome/cjinfeng/BigData/software/ProgramPython/lib')11from utility import gff_parser, createdir12def usage():13 test="name"14 message='''15python CircosConf.py --input circos.config --output pipe.conf16 '''17 print message18def runjob(script, lines):19 cmd = 'perl /rhome/cjinfeng/software/bin/qsub-pbs.pl --maxjob 30 --lines %s --interval 120 --resource nodes=1:ppn=12,walltime=100:00:00,mem=20G --convert no %s' %(lines, script)20 #print cmd 21 os.system(cmd)22def fasta_id(fastafile):23 fastaid = defaultdict(str)24 for record in SeqIO.parse(fastafile,"fasta"):25 fastaid[record.id] = 126 return fastaid27#RIL1 1 /rhome/cjinfeng/Rice/RIL/Illumina_correct/RIL1_0/RIL1_0_CGTACG_FC153L5_p1.fq.gz28def read_list(infile):29 data = defaultdict(lambda : int())30 with open (infile, 'r') as filehd:31 for line in filehd:32 line = line.rstrip()33 if len(line) > 2: 34 unit = re.split(r'\t',line)35 ril = re.sub(r'RIL', r'', unit[0])36 data[ril] = 137 return data38def NCBI_biosample(rils, tsv):39 ofile = open(tsv, 'a')40 for ril in sorted(rils.keys(), key=int):41 #print ril42 print >> ofile, 'RIL%s\tnot collected\tPRJNA316308\tOryza Sativa\tnot collected\tNipponbare x HEG4 RIL%s\tTemperate Japonica\tnot collected\tSeedling\tnot collected\tLeaf\tSusan Wessler\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected\tnot collected' %(ril, ril) 43 ofile.close()44def main():45 parser = argparse.ArgumentParser()46 parser.add_argument('-i', '--input')47 parser.add_argument('-o', '--output')48 parser.add_argument('-v', dest='verbose', action='store_true')49 args = parser.parse_args()50 try:51 len(args.input) > 052 except:53 usage()54 sys.exit(2)55 #cp Plant.1.0.tsv RILs_272.NCBI_biosample.tsv56 os.system('cp ../input/Plant.1.0.tsv RILs_272.NCBI_biosample.tsv')57 rils = read_list(args.input) 58 NCBI_biosample(rils, 'RILs_272.NCBI_biosample.tsv')59if __name__ == '__main__':...

Full Screen

Full Screen

01.py

Source:01.py Github

copy

Full Screen

1cost = float(input())2num_of_months = int(input())3collected = 0.04for i in range(1, num_of_months + 1):5 if i % 2 != 0:6 collected -= collected * 0.167 elif i % 4 == 0:8 collected += collected * 0.259 collected += cost * 0.2510if collected >= cost:11 print(f"Bravo! You can go to Disneyland and you will have {(collected - cost):.2f}lv. for souvenirs.")12else:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selene automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful