How to use filter_event method in localstack

Best Python code snippet using localstack_python

ConfFilter.py

Source:ConfFilter.py Github

copy

Full Screen

1from core import Filter2import inspect3import sys4def get_remove_filter() :5 """ Define list of regex strings to filter input branches to remove from the output.6 Defining a non-empty list does not apply the filter, 7 you must also supply --enableRemoveFilter on the command line.8 If both filters are used, all branches in keep_filter are used9 except for those in remove_filter """10 return []11def get_keep_filter() :12 """ Define list of regex strings to filter input branches to retain in the output. 13 Defining a non-empty list does not apply the filter, 14 you must also supply --enableKeepFilter on the command line15 If both filters are used, all branches in keep_filter are used16 except for those in remove_filter """17 return []18def config_analysis( alg_list, args ) :19 """ Configure analysis modules. Order is preserved """20 # run on the function provided through21 # the args22 for s in inspect.getmembers(sys.modules[__name__]) :23 if s[0] == args['function'] :24 print '*********************************'25 print 'RUN %s' %( args['function'] )26 print '*********************************'27 s[1]( alg_list, args )28def make_final_mu( alg_list, args ) :29 looseobj = args.get('looseobj', False )30 print 'looseobj = ', looseobj31 notrig = args.get('notrig', False )32 print 'notrig = ', notrig33 mtvar = args.get('mtvar', 'mt_lep_met')34 print 'mtvar = ', mtvar35 mtcut = args.get('mtcut', ' > 40')36 print 'mtcut = ', mtcut37 phpt = args.get('phpt', ' > 25 ' )38 print 'phpt = ', phpt39 filter_photon = Filter( 'FilterPhoton' )40 filter_photon.cut_ph_medium = ' == True '41 if not looseobj :42 filter_photon.cut_ph_pt = phpt43 alg_list.append(filter_photon)44 if not looseobj :45 filter_muon = Filter( 'FilterMuon' )46 filter_muon.cut_mu_pt = ' > 10 '47 alg_list.append(filter_muon)48 filter_ele = Filter( 'FilterElectron' )49 filter_ele.cut_el_pt = ' > 10 '50 alg_list.append(filter_ele)51 alg_list.append( Filter('CalcEventVars') )52 filter_event = Filter('FilterEvent')53 if looseobj :54 filter_event.cut_nPh = ' > 1 '55 filter_event.cut_nMu = ' > 0 '56 else :57 filter_event.cut_nPh = ' == 2 '58 filter_event.cut_nMu = ' == 1 '59 filter_event.cut_nEl = ' == 0 '60 if not notrig :61 filter_event.cut_nMuTrig = ' > 0 '62 #filter_event.cut_dr_lep_ph1 = ' > 0.4 '63 #filter_event.cut_dr_lep_ph2 = ' > 0.4 '64 if not looseobj :65 filter_event.cut_dr_ph1_ph2 = ' > 0.4 '66 filter_event.cut_leadPhot_trigMuDR = ' > 0.4 '67 filter_event.cut_sublPhot_trigMuDR = ' > 0.4 '68 if not looseobj :69 filter_event.cut_MuTrig = ' == True '70 filter_event.cut_isEEEE = ' == False '71 # remove diphoton mass cut72 #filter_event.cut_mgg = ' > 15 '73 setattr( filter_event, 'cut_%s' %mtvar, mtcut )74 alg_list.append( filter_event )75 blind_pt = args.get('blind_pt', None )76 if blind_pt == 'None' :77 blind_pt = None78 if blind_pt is not None :79 isData = args.pop('isData', 'False')80 filter_blind = Filter( 'FilterBlind' )81 filter_blind.cut_ph_pt_lead = ' < %d ' %int(blind_pt)82 filter_blind.add_var( 'isData', isData )83 alg_list.append(filter_blind)84def make_final_el( alg_list, args ) :85 looseobj = args.get('looseobj', False )86 print 'looseobj = ', looseobj87 nozmass = args.get('nozmass', False )88 print 'nozmass = ', nozmass89 zmasscr = args.get('zmasscr', False )90 print 'zmasscr = ', zmasscr91 notrig = args.get('notrig', False )92 print 'notrig = ', notrig93 csev = args.get('csev', False )94 print 'csev = ', csev95 overlap_veto = args.get('overlap_veto', False )96 print 'overlap_veto = ', overlap_veto97 invpixlead = args.get('invpixlead', False )98 print 'invpixlead = ', invpixlead99 invpixsubl = args.get('invpixsubl', False )100 print 'invpixsubl = ', invpixsubl101 mtvar = args.get('mtvar', 'mt_lep_met')102 print 'mtvar = ', mtvar103 mtcut = args.get('mtcut', ' > 40')104 print 'mtcut = ', mtcut105 mass_cut = args.get('mass_cut', 10)106 print 'mass_cut = ', mass_cut107 phpt = args.get('phpt', ' > 25 ' )108 print 'phpt = ', phpt109 nelcut = args.get('nelcut', ' == 1 ' )110 print 'nelcut= ', nelcut111 filter_photon = Filter( 'FilterPhoton' )112 filter_photon.cut_ph_medium = ' == True '113 if not looseobj :114 filter_photon.cut_ph_pt = phpt115 alg_list.append(filter_photon)116 if not looseobj :117 filter_muon = Filter( 'FilterMuon' )118 filter_muon.cut_mu_pt = ' > 10 '119 alg_list.append(filter_muon)120 121 filter_ele = Filter( 'FilterElectron' )122 filter_ele.cut_el_pt = ' > 10 '123 alg_list.append(filter_ele)124 alg_list.append( Filter('CalcEventVars') )125 filter_event = Filter('FilterEvent')126 if looseobj :127 filter_event.cut_nPh = ' > 1 '128 filter_event.cut_nEl = ' > 0 '129 else :130 filter_event.cut_nPh = ' == 2 '131 filter_event.cut_nMu = ' == 0 '132 filter_event.cut_nEl = nelcut133 if not notrig :134 filter_event.cut_nElTrig = ' > 0 '135 if csev :136 if invpixlead :137 filter_event.cut_csev_leadph12 = ' == True '138 else :139 filter_event.cut_csev_leadph12 = ' == False '140 if invpixsubl :141 filter_event.cut_csev_sublph12 = ' == True '142 else :143 filter_event.cut_csev_sublph12 = ' == False '144 elif overlap_veto :145 if invpixlead :146 filter_event.cut_overlapVeto_leadph12 = ' == True '147 else :148 filter_event.cut_overlapVeto_leadph12 = ' == False '149 if invpixsubl :150 filter_event.cut_overlapVeto_sublph12 = ' == True '151 else :152 filter_event.cut_overlapVeto_sublph12 = ' == False '153 else :154 if invpixlead :155 filter_event.cut_hasPixSeed_leadph12 = ' == True '156 else :157 filter_event.cut_hasPixSeed_leadph12 = ' == False '158 if invpixsubl :159 filter_event.cut_hasPixSeed_sublph12 = ' == True '160 else :161 filter_event.cut_hasPixSeed_sublph12 = ' == False '162 #filter_event.cut_dr_lep_ph1 = ' > 0.4 '163 #filter_event.cut_dr_lep_ph2 = ' > 0.4 '164 #filter_event.cut_dr_trigele_ph1 = ' > 0.4 '165 #filter_event.cut_dr_trigele_ph2 = ' > 0.4 '166 if not looseobj :167 filter_event.cut_dr_ph1_ph2 = ' > 0.4 '168 #filter_event.cut_leadPhot_trigElDR = ' > 0.4 '169 #filter_event.cut_sublPhot_trigElDR = ' > 0.4 '170 if not looseobj :171 filter_event.cut_ElTrig = ' == True '172 filter_event.cut_isEEEE = ' == False '173 setattr( filter_event, 'cut_%s' %mtvar, mtcut )174 # remove mgg Cut175 #filter_event.cut_mgg = ' > 15 '176 mass_min = 91.2 - mass_cut177 mass_max = 91.2 + mass_cut178 if not nozmass :179 if zmasscr :180 #filter_event.cut_m_lepphph= ' > 86.2 & < 96.2 '181 filter_event.cut_m_trigelphph= ' > %.1f & < %.1f ' %(mass_min, mass_max )182 else :183 #filter_event.cut_m_lepphph= ' > 86.2 & < 96.2 '184 #filter_event.cut_m_lepph1= ' > 86.2 & < 96.2 '185 #filter_event.cut_m_lepph2= ' > 86.2 & < 96.2 '186 #filter_event.invert( 'cut_m_lepphph' )187 #filter_event.invert( 'cut_m_lepph1' )188 #filter_event.invert( 'cut_m_lepph2' )189 filter_event.cut_m_trigelphph = ' > %.1f & < %.1f ' %(mass_min, mass_max )190 filter_event.cut_m_trigelph1 = ' > %.1f & < %.1f ' %(mass_min, mass_max )191 filter_event.cut_m_trigelph2 = ' > %.1f & < %.1f ' %(mass_min, mass_max )192 filter_event.invert( 'cut_m_trigelphph' )193 filter_event.invert( 'cut_m_trigelph1' )194 filter_event.invert( 'cut_m_trigelph2' )195 alg_list.append( filter_event )196 blind_pt = args.get('blind_pt', None )197 if blind_pt == 'None' :198 blind_pt = None199 print 'BLIND PT = ', blind_pt200 if blind_pt is not None :201 isData = args.pop('isData', 'False')202 filter_blind = Filter( 'FilterBlind' )203 filter_blind.cut_ph_pt_lead = ' < %d ' %int(blind_pt)204 filter_blind.add_var( 'isData', isData )205 alg_list.append(filter_blind)206def make_nominal_unblind( alg_list, args ) :207 208 filter_photon = Filter( 'FilterPhoton' )209 filter_photon.cut_ph_medium = ' == True '210 alg_list.append(filter_photon)211 filter_muon = Filter( 'FilterMuon' )212 filter_muon.cut_mu_pt = ' > 10 '213 alg_list.append(filter_muon)214 alg_list.append( Filter('CalcEventVars') )215 filter_event = Filter('FilterEvent')216 filter_event.cut_nPh = ' > 1 '217 filter_event.cut_hasPixSeed_leadph12 = ' == False '218 filter_event.cut_hasPixSeed_sublph12 = ' == False '219 alg_list.append( filter_event )220 blind_pt = args.get('blind_pt', None )221 if blind_pt == 'None' :222 blind_pt = None223 if blind_pt is not None :224 isData = args.pop('isData', 'False')225 filter_blind = Filter( 'FilterBlind' )226 filter_blind.cut_ph_pt_lead = ' < %d ' %int(blind_pt)227 filter_blind.add_var( 'isData', isData )228 alg_list.append(filter_blind)229def make_nominal_unblind_noEleVeto( alg_list, args ) :230 231 filter_photon = Filter( 'FilterPhoton' )232 filter_photon.cut_ph_medium = ' == True '233 alg_list.append(filter_photon)234 filter_muon = Filter( 'FilterMuon' )235 filter_muon.cut_mu_pt = ' > 10 '236 alg_list.append(filter_muon)237 alg_list.append( Filter('CalcEventVars') )238 filter_event = Filter('FilterEvent')239 filter_event.cut_nPh = ' > 1 '240 alg_list.append( filter_event )241 blind_pt = args.get('blind_pt', None )242 if blind_pt == 'None' :243 blind_pt = None244 if blind_pt is not None :245 isData = args.pop('isData', 'False')246 filter_blind = Filter( 'FilterBlind' )247 filter_blind.cut_ph_pt_lead = ' < %d ' %int(blind_pt)248 filter_blind.add_var( 'isData', isData )249 alg_list.append(filter_blind)250def make_nominal_unbzrej( alg_list, args ) :251 filter_photon = Filter( 'FilterPhoton' )252 filter_photon.cut_ph_medium = ' == True '253 alg_list.append(filter_photon)254 filter_muon = Filter( 'FilterMuon' )255 filter_muon.cut_mu_pt = ' > 10 '256 alg_list.append(filter_muon)257 alg_list.append( Filter('CalcEventVars') )258 filter_event = Filter('FilterEvent')259 filter_event.cut_nPh = ' > 1 '260 filter_event.cut_hasPixSeed_leadph12 = ' == False '261 filter_event.cut_hasPixSeed_sublph12 = ' == False '262 alg_list.append( filter_event )263 isData = args.pop('isData', 'False')264 filter_blind = Filter( 'FilterBlind' )265 filter_blind.add_var( 'isData', isData )266 filter_blind.cut_m_lepphph= ' > 86.2 & < 96.2 '267 filter_blind.cut_m_lepph1= ' > 86.2 & < 96.2 '268 filter_blind.cut_m_lepph2= ' > 86.2 & < 96.2 '269 alg_list.append(filter_blind)270def make_looseID_noEleVeto( alg_list, args ) :271 filter_photon = Filter( 'FilterPhoton' )272 filter_photon.cut_ph_mediumNoSIEIE = ' == True '273 alg_list.append(filter_photon)274 filter_muon = Filter( 'FilterMuon' )275 filter_muon.cut_mu_pt = ' > 10 '276 alg_list.append(filter_muon)277 alg_list.append( Filter('CalcEventVars') )278 filter_event = Filter('FilterEvent')279 filter_event.cut_nPh = ' > 1 '280 alg_list.append( filter_event )281def make_looseID_bothVetoPSV( alg_list, args ) :282 filter_muon = Filter( 'FilterMuon' )283 filter_muon.cut_mu_pt = ' > 10 '284 alg_list.append(filter_muon)285 alg_list.append( Filter('CalcEventVars') )286 filter_event = Filter('FilterEvent')287 filter_event.cut_nPh = ' > 1 '288 filter_event.cut_hasPixSeed_leadph12 = ' == False '289 filter_event.cut_hasPixSeed_sublph12 = ' == False '290 alg_list.append( filter_event )291def make_looseID_invPSVSubl( alg_list, args ) :292 filter_muon = Filter( 'FilterMuon' )293 filter_muon.cut_mu_pt = ' > 10 '294 alg_list.append(filter_muon)295 alg_list.append( Filter('CalcEventVars') )296 filter_event = Filter('FilterEvent')297 filter_event.cut_nPh = ' > 1 '298 filter_event.cut_hasPixSeed_leadph12 = ' == False '299 filter_event.cut_hasPixSeed_sublph12 = ' == True '300 alg_list.append( filter_event )301def make_looseID_invPSVLead( alg_list, args ) :302 filter_muon = Filter( 'FilterMuon' )303 filter_muon.cut_mu_pt = ' > 10 '304 alg_list.append(filter_muon)305 alg_list.append( Filter('CalcEventVars') )306 filter_event = Filter('FilterEvent')307 filter_event.cut_nPh = ' > 1 '308 filter_event.cut_hasPixSeed_leadph12 = ' == True '309 filter_event.cut_hasPixSeed_sublph12 = ' == False '310 alg_list.append( filter_event )311def make_looseID_bothVetoCSEV( alg_list, args ) :312 filter_muon = Filter( 'FilterMuon' )313 filter_muon.cut_mu_pt = ' > 10 '314 alg_list.append(filter_muon)315 alg_list.append( Filter('CalcEventVars') )316 filter_event = Filter('FilterEvent')317 filter_event.cut_nPh = ' > 1 '318 filter_event.cut_csev_leadph12 = ' == False '319 filter_event.cut_csev_sublph12 = ' == False '320 alg_list.append( filter_event )321def make_looseID_invCSEVSubl( alg_list, args ) :322 filter_muon = Filter( 'FilterMuon' )323 filter_muon.cut_mu_pt = ' > 10 '324 alg_list.append(filter_muon)325 alg_list.append( Filter('CalcEventVars') )326 filter_event = Filter('FilterEvent')327 filter_event.cut_nPh = ' > 1 '328 filter_event.cut_csev_leadph12 = ' == False '329 filter_event.cut_csev_sublph12 = ' == True '330 alg_list.append( filter_event )331def make_looseID_invCSEVLead( alg_list, args ) :332 filter_muon = Filter( 'FilterMuon' )333 filter_muon.cut_mu_pt = ' > 10 '334 alg_list.append(filter_muon)335 alg_list.append( Filter('CalcEventVars') )336 filter_event = Filter('FilterEvent')337 filter_event.cut_nPh = ' > 1 '338 filter_event.cut_csev_leadph12 = ' == True '339 filter_event.cut_csev_sublph12 = ' == False '340 alg_list.append( filter_event )341def make_final_mumu( alg_list, args ) :342 invpixlead = args.get('invpixlead', False )343 print 'invpixlead = ', invpixlead344 invpixsubl = args.get('invpixsubl', False )345 print 'invpixsubl = ', invpixsubl346 looseobj = args.get('looseobj', False )347 print 'looseobj = ', looseobj348 notrig = args.get('notrig', False )349 print 'notrig = ', notrig350 filter_photon = Filter( 'FilterPhoton' )351 filter_photon.cut_ph_medium = ' == True '352 if not looseobj :353 filter_photon.cut_ph_pt = ' > 15 '354 filter_photon.cut_ph_csev = ' == False '355 alg_list.append(filter_photon)356 if not looseobj :357 filter_muon = Filter( 'FilterMuon' )358 filter_muon.cut_mu_pt = ' > 10 '359 alg_list.append(filter_muon)360 filter_ele = Filter( 'FilterElectron' )361 filter_ele.cut_el_pt = ' > 10 '362 alg_list.append(filter_ele)363 alg_list.append( Filter('CalcEventVars') )364 filter_event = Filter('FilterEvent')365 if looseobj :366 filter_event.cut_nPh = ' > 1 '367 filter_event.cut_nMu = ' > 1 '368 else :369 filter_event.cut_nPh = ' == 2 '370 filter_event.cut_nMu = ' == 2 '371 if not looseobj :372 filter_event.cut_dr_lep_ph1 = ' > 0.4 '373 filter_event.cut_dr_lep_ph2 = ' > 0.4 '374 filter_event.cut_dr_subllep_ph1 = ' > 0.4 '375 filter_event.cut_dr_subllep_ph2 = ' > 0.4 '376 filter_event.cut_dr_ph1_ph2 = ' > 0.4 '377 if not notrig :378 filter_event.cut_DiMuTrig = ' == True '379 if not looseobj :380 filter_event.cut_m_mumu = ' > 40 '381 filter_event.cut_isEEEE = ' == False '382 alg_list.append( filter_event )383def make_final_elel( alg_list, args ) :384 looseobj = args.get('looseobj', False )385 print 'looseobj = ', looseobj386 notrig = args.get('notrig', False )387 print 'notrig = ', notrig388 filter_photon = Filter( 'FilterPhoton' )389 filter_photon.cut_ph_medium = ' == True '390 if not looseobj :391 filter_photon.cut_ph_pt = ' > 15 '392 filter_photon.cut_ph_csev= ' == False '393 #filter_photon.cut_hasPixSeed = ' == False '394 alg_list.append(filter_photon)395 if not looseobj :396 filter_muon = Filter( 'FilterMuon' )397 filter_muon.cut_mu_pt = ' > 10 '398 alg_list.append(filter_muon)399 400 filter_ele = Filter( 'FilterElectron' )401 filter_ele.cut_el_pt = ' > 10 '402 alg_list.append(filter_ele)403 alg_list.append( Filter('CalcEventVars') )404 filter_event = Filter('FilterEvent')405 if looseobj :406 filter_event.cut_nPh = ' > 1 '407 filter_event.cut_nEl = ' > 1 '408 else :409 filter_event.cut_nPh = ' == 2 '410 filter_event.cut_nEl = ' == 2 '411 #filter_event.cut_nMu = ' == 0 '412 if not looseobj :413 filter_event.cut_dr_lep_ph1 = ' > 0.4 '414 filter_event.cut_dr_lep_ph2 = ' > 0.4 '415 filter_event.cut_dr_subllep_ph1 = ' > 0.4 '416 filter_event.cut_dr_subllep_ph2 = ' > 0.4 '417 filter_event.cut_dr_ph1_ph2 = ' > 0.4 '418 if not notrig :419 filter_event.cut_DiElTrig = ' == True '420 if not looseobj :421 filter_event.cut_m_elel = ' > 40 '422 filter_event.cut_isEEEE = ' == False '423 alg_list.append( filter_event )424def make_lep_gamma( alg_list, args ) :425 invpix = args.get('invpix', False )426 print 'invpix = ', invpix427 filter_photon = Filter( 'FilterPhoton' )428 filter_photon.cut_ph_medium = ' == True '429 filter_photon.cut_ph_pt = ' > 15 '430 if invpix :431 filter_photon.cut_hasPixSeed = ' == True '432 else :433 filter_photon.cut_hasPixSeed = ' == False '434 alg_list.append( filter_photon )435 alg_list.append( Filter('CalcEventVars') )436 filter_event = Filter('FilterEvent')437 filter_event.cut_nElTrig = ' > 0 '438 filter_event.cut_nPh = ' > 0 '439 alg_list.append( filter_event )440def make_leplep_gamma( alg_list, args ) :441 filter_photon = Filter( 'FilterPhoton' )442 filter_photon.cut_ph_medium = ' == True '443 filter_photon.cut_ph_pt = ' > 15 '444 eleOlap = args.get( 'eleOlap', False )445 print 'eleOlap = ', eleOlap446 if eleOlap :447 filter_photon.cut_el_ph_dr = ' > 0.4 '448 alg_list.append( filter_photon )449 alg_list.append( Filter('CalcEventVars') )450 filter_event = Filter('FilterEvent')451 filter_event.cut_nLep = ' > 1 '452 filter_event.cut_nPh = ' > 0 '453 alg_list.append( filter_event )454def make_wgjj( alg_list, args ) :455 filter_muon = Filter( 'FilterMuon' )456 filter_muon.cut_mu_pt = ' > 10 '457 alg_list.append(filter_muon)458 filter_jet = Filter( 'FilterJet' )459 filter_jet.cut_jet_pt = ' > 30 '460 alg_list.append(filter_jet)461 alg_list.append( Filter('CalcEventVars') )462 filter_event = Filter('FilterEvent')463 filter_event.cut_nPh = ' == 1 '464 filter_event.cut_nLepTrig = ' > 0 '465 filter_event.cut_nLep = ' == 1 '466 filter_event.cut_nJet30 = ' > 1 '467 filter_event.cut_nJet40 = ' > 0 '468 filter_event.cut_mt_lep_met = ' > 30 '469 alg_list.append( filter_event )470 alg_list.append( Filter( 'CalcDiJetVars' ) )471def make_zgjj( alg_list, args ) :472 filter_muon = Filter( 'FilterMuon' )473 filter_muon.cut_mu_pt = ' > 10 '474 alg_list.append(filter_muon)475 filter_jet = Filter( 'FilterJet' )476 filter_jet.cut_jet_pt = ' > 30 '477 alg_list.append(filter_jet)478 alg_list.append( Filter('CalcEventVars') )479 filter_event = Filter('FilterEvent')480 filter_event.cut_nPh = ' == 1 '481 filter_event.cut_nLepTrig = ' > 0 '482 filter_event.cut_nLep = ' == 2 '483 filter_event.cut_nJet30 = ' > 1 '484 alg_list.append( filter_event )...

Full Screen

Full Screen

Conf.py

Source:Conf.py Github

copy

Full Screen

1from core import Filter2import inspect3import sys4import os5def get_remove_filter() :6 """ Define list of regex strings to filter input branches to remove from the output.7 Defining a non-empty list does not apply the filter, 8 you must also supply --enableRemoveFilter on the command line.9 If both filters are used, all branches in keep_filter are used10 except for those in remove_filter """11 return ['']12def get_keep_filter() :13 """ Define list of regex strings to filter input branches to retain in the output. 14 Defining a non-empty list does not apply the filter, 15 you must also supply --enableKeepFilter on the command line16 If both filters are used, all branches in keep_filter are used17 except for those in remove_filter """18 return []19def config_analysis( alg_list, args ) :20 """ Configure analysis modules. Order is preserved """21 # run on the function provided through22 # the args23 for s in inspect.getmembers(sys.modules[__name__]) :24 if s[0] == args['function'] :25 print '*********************************'26 print 'RUN %s' %( args['function'] )27 print '*********************************'28 s[1]( alg_list, args )29def filter_photon( alg_list, args ) :30 pt_cut = args.get('pt_cut' , ' > 10 ' )31 leadpt_cut = args.get('leadpt_cut' , None )32 aeta_cut = args.get('aeta_cut' , None )33 dr_cut = args.get('dr_cut' , None )34 nph_cut = args.get('nph_cut' , ' == 0 ' )35 isPromptFS_cut = args.get('isPromptFS_cut', None )36 fhpfs_cut = args.get('fhpfs_cut', None)37 isr_cut = args.get('isr_cut' , None)38 wg_cut = args.get('wg_cut', None)39 filter_event = Filter('FilterPhoton')40 filter_event.cut_genph_pt = pt_cut41 if wg_cut:42 filter_event.cut_genph_wg = wg_cut43 if leadpt_cut:44 filter_event.cut_lead_genph_pt = leadpt_cut45 if aeta_cut:46 filter_event.cut_genph_aeta = aeta_cut47 if dr_cut:48 filter_event.cut_genph_dr = dr_cut49 filter_event.cut_n_gen_phot = nph_cut50 if isPromptFS_cut:51 filter_event.cut_genph_isPromptFS = isPromptFS_cut52 if fhpfs_cut:53 filter_event.cut_genph_FHPFS = fhpfs_cut54 if isr_cut:55 filter_event.cut_genph_isr = isr_cut56 alg_list.append( filter_event )57def filter_genht( alg_list, args ) :58 trueht_cut = args.get('trueht_cut', None )59 if trueht_cut is not None :60 filter_event = Filter('FilterTrueHT')61 filter_event.cut_trueht = trueht_cut62 alg_list.append( filter_event )63def filter_mtres( alg_list, args ) :64 mtres_cut = args.get('mtres_cut', None )65 if mtres_cut is not None :66 filter_event = Filter('FilterMTRes')67 filter_event.cut_mtres = mtres_cut68 alg_list.append( filter_event )69def filter_wpt( alg_list, args ) :70 truewpt_cut = args.get('truewpt_cut', None )71 if truewpt_cut is not None :72 filter_event = Filter('FilterTrueWPt')73 filter_event.cut_truewpt = truewpt_cut74 alg_list.append( filter_event )75def filter_hlt( alg_list, args ) :76 hlt_cut = args.get('hlt_cut', None )77 if hlt_cut :78 filter_event = Filter('FilterHLT')79 alg_list.append( filter_event )80def apply_wpt_kneg( alg_list, args ) :81 82 truewpt_bound_lo = args.get('truewpt_bound_lo', 0. )83 truewpt_bound_hi = args.get('truewpt_bound_hi', 13000. )84 truewpt_kneg_lo = args.get('truewpt_kneg_lo', 1. )85 truewpt_kneg_hi = args.get('truewpt_kneg_hi', 1. )86 if (truewpt_kneg_lo != 1. or 87 truewpt_kneg_hi != 1.):88 filter_event = Filter('ApplyTrueWPtKNeg')89 filter_event.add_var( 'truewpt_bound_lo', truewpt_bound_lo )90 filter_event.add_var( 'truewpt_bound_hi', truewpt_bound_hi )91 filter_event.add_var( 'truewpt_kneg_lo', truewpt_kneg_lo )92 filter_event.add_var( 'truewpt_kneg_hi', truewpt_kneg_hi )93 alg_list.append( filter_event )94def filter_combined( alg_list, args ) :95 96 filter_photon( alg_list, args )97 filter_genht( alg_list, args )98 filter_mtres( alg_list, args )99 filter_wpt( alg_list, args )...

Full Screen

Full Screen

difficulty.py

Source:difficulty.py Github

copy

Full Screen

1# function that handles fixtures difficulty data for each team2import pandas as pd 3import numpy as np4from fpl_import import *5# get current gameweek details for default values6gameweek = get_current_gameweek()7def team_difficulty(gameweek_A=gameweek+1, gameweek_B=gameweek+4):8 '''9 returns the difficulty of fixtures faced so far10 input: gameweek_A to gameweek_B are integers determing the range to be considered for difficulty11 output: dataframe showing each team and the total difficulty for the number of gameweeks specified12 '''13 raw_json = get_raw_fpl_tables()14 teams_df = combine_player_teams(raw_json)15 fixtures = get_team_fixtures()16 fixtures = fixtures[(fixtures.event <= gameweek_B) & (fixtures.event >= gameweek_A)] 17 18 index = 019 output_df = pd.DataFrame(columns = ["event","team_id","opponent_id", "home/away", "opponent_difficulty","number_games"])20 21 for event in list(fixtures.event.unique()): 22 23 filter_event = fixtures[fixtures["event"]== event].copy()24 teams_list = list(filter_event.team_a) + list(filter_event.team_h)25 teams = []26 [teams.append(x) for x in teams_list if x not in teams]27 28 29 for team in teams:30 # triple gameweek logic not accounted for yet here, to be improved31 if (team in list(filter_event.team_a)) and (team in list(filter_event.team_h)):32 opponent_id = [filter_event[filter_event["team_a"]==team].team_h.values, \33 filter_event[filter_event["team_h"]==team].team_a.values] 34 opponent_difficulty = [filter_event[filter_event["team_a"]==team].team_a_difficulty.values, \35 filter_event[filter_event["team_h"]==team].team_h_difficulty.values] 36 home = [False, True] 37 38 39 elif team in list(filter_event.team_a):40 opponent_id = filter_event[filter_event["team_a"]==team].team_h.values 41 opponent_difficulty = filter_event[filter_event["team_a"]==team].team_a_difficulty.values42 home = False43 44 else:45 opponent_id = filter_event[filter_event["team_h"]==team].team_a.values46 opponent_difficulty = filter_event[filter_event["team_h"]==team].team_h_difficulty.values47 home = True48 49 output_df.loc[index,"event"] = event50 output_df.loc[index,"team_id"] = team51 output_df.loc[index,"opponent_id"] = np.array(opponent_id).flatten().tolist()52 output_df.loc[index,"home/away"] = np.array(home).flatten()53 output_df.loc[index,"opponent_difficulty"] = np.array(opponent_difficulty).flatten().sum()54 output_df.loc[index,"number_games"] = len(output_df.loc[index,"opponent_id"])55 index += 156 57 58 # filter the dataframe59 output_df = output_df[(output_df.event <= gameweek_B) & (output_df.event >= gameweek_A)] 60 # Add team names61 output_df['team'] = output_df.team_id.map(teams_df['team_data'].set_index('id').name)62 output_df_sums = output_df.groupby("team", as_index = False).sum()63 output_df_sums = output_df_sums[["team","opponent_difficulty", "number_games"]]64 return {'teams_list': output_df, "totals": output_df_sums}65 66 ...

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 localstack 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