How to use _summary method in tox

Best Python code snippet using tox_python

récuperation_foot.py

Source:récuperation_foot.py Github

copy

Full Screen

123#Récuperation des données sur Fbref456import time78import pandas as pd9from selenium import webdriver10from selenium.webdriver.chrome.webdriver import WebDriver11from selenium.webdriver.common.by import By12from tqdm import tqdm131415#Cette fonction a pour objectif de nous amener vers la page principal,le parametre de la fonction "elt" correspond un element d'une liste de lien.1617def extraction_fbref(elt):18 driver.get(f"{elt}")19 time.sleep(7)20 try:21 accepte_cookies = driver.find_element(By.XPATH,22 "//*[@id='qc-cmp2-ui']/div[2]/div/button[3]")23 accepte_cookies.click()24 print("Cookies acceptés")25 time.sleep(10)26 except:27 print("Cookies non acceptés")28 time.sleep(7)29 try:30 fermeture_pub = driver.find_element(By.XPATH, f'//*[@id="fs-slot-footer-wrapper"]/button')31 fermeture_pub.click()32 print("Pub fermé")33 time.sleep(5)34 except:35 pass3637#Lorsqu'on est sur la page principale calendrier et résultat d'une saison d'un championnat,nous allons récuperé tout les url des rapports de match figurant dans cette page.3839def rapportdematch():40 urls = driver.find_elements(By.XPATH, '//td[@data-stat="match_report"]/a')41 return [url.get_attribute("href") for url in urls]424344# Cette fonction va scrapper chaque rapport de match,elle va extraire comme information la compo,les joueurs,leur temps de jeu,s'ils jouent à domicile ou non,etc...45# On va convertir nos dictionnaire python en data frame via la librairies Pandas puis nous allons sauvegardé ces données dans un ficher xlsx en faisant un update par journée de match(loopsave).46#Les parametres correspondent au id et au nom du fichier,il y'a 380 match par saison.Lorsqu'on passe a la saison suivante,on lui incrémente la valeur 360(t)4748def scrap_tablea(t,nom_du_fichier):49 id = 0 + t50 loopsave = 151 compo_match = []52 for i in tqdm(lien_rapport_de_match):53 # pbar.update(len(team_url))54 id += 155 loopsave += 156 data = driver.get(i)5758 #--------- Les Xpaths de chaque élement du tableau concernant la premiere equipe59 joueur_equipe_une = driver.find_elements(By.XPATH, f'((//table[contains(@id,"_summary")])[1])/tbody/tr/th/a')60 minute = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[5]')61 position = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[3]')62 # C'est rubrique concernant les performance63 buts = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[6]')64 passe_decisive = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[7]')65 penalty_marqués = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[8]')66 penalty_tirés = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[9]')67 tirs = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[10]')68 tirs_cadrés = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[11]')69 carton_jaune = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[12]')70 carton_rouge = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[13]')71 touches = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[14]')72 pression = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[15]')73 nombre_de_joueur_tacles = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[16]')74 interception = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[17]')75 balles_contrées = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[18]')76 # -------Attendu77 buts_attendus = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[19]')78 buts_attendus_sans_penalty = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[20]')79 buts_attendus_avec_passe_decisive = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[21]')80 # -------Action_menant_à_un_tirs81 action_menant_tirs = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[22]')82 action_menant_buts = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[23]')83 # -------Passes84 passes_reussies = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[24]')85 passes_tentes = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[25]')86 pourcentage_de_passe_reussie = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[26]')87 passe_vers_l_avant = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[27]')88 # -------Balle au pied89 balle_pied = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[28]')90 progression_balle_au_pied = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[29]')91 # -------Dribbles92 reussi = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[30]')93 tenter = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[1])/tbody//td[31]')94 # --- Composition du match & Nom du club à domicile95 club_domicile = driver.find_elements(By.XPATH, '(//div[@class="th"][1])[1]')96 composition_domicile = driver.find_elements(By.XPATH, "(//tbody//th[@colspan = '2'])[1]")97 # -----------------------------Xpath de la deuxieme équipe98 joueur_equipe_deux = driver.find_elements(By.XPATH, f'((//table[contains(@id,"_summary")])[2])/tbody/tr/th/a')99 minute2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[5]')100 position2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[3]')101 #-------Performance102 buts2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[6]')103 passe_decisive2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[7]')104 penalty_marqués2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[8]')105 penalty_tirés2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[9]')106 tirs2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[10]')107 tirs_cadrés2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[11]')108 carton_jaune2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[12]')109 carton_rouge2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[13]')110 touches2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[14]')111 pression2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[15]')112 nombre_de_joueur_tacles2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[16]')113 interception2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[17]')114 balles_contrées2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[18]')115 # -------Attendu116 buts_attendus2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[19]')117 buts_attendus_sans_penalty2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[20]')118 buts_attendus_avec_passe_decisive2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[21]')119 # -------Action menant à un tirs120 action_menant_tirs2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[22]')121 action_menant_buts2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[23]')122 # -------Passes123 passes_reussies2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[24]')124 passes_tentes2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[25]')125 pourcentage_de_passe_reussie2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[26]')126 passe_vers_l_avant2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[27]')127 # -------Balle au pied128 balle_pied2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[28]')129 progression_balle_au_pied2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[29]')130 # -------Dribbles131 reussi2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[30]')132 tenter2 = driver.find_elements(By.XPATH, '((//table[contains(@id,"_summary")])[2])/tbody//td[31]')133 # --- Composition du match & Nom du club à l'exterieur134 composition_exterieur = driver.find_elements(By.XPATH, "(//tbody//th[@colspan = '2'])[3]")135 club_a_lexterieur = driver.find_elements(By.XPATH, '(//div[@class="th"][3])[1]')136137 for j in range(len(joueur_equipe_une)): # Faut separé les deux tableaux138 data_test = {'id': id, 'Club': club_domicile[0].text, 'Equipe à domicile': joueur_equipe_une[j].text,139 'Position': position[j].text, 'Minute joué': minute[j].text,140 'buts': buts[j].text, 'passe décisive': passe_decisive[j].text, 'penalty marqué': penalty_marqués[j].text,141 'penalty tiré': penalty_tirés[j].text, 'tirs': tirs[j].text, 'tirs cadrés': tirs_cadrés[j].text,142 'carton jaune': carton_jaune[j].text,143 'carton rouge': carton_rouge[j].text, 'touches': touches[j].text, 'pression': pression[j].text, 'Nombre de joueur tacles': nombre_de_joueur_tacles[j].text,144 'interception': interception[j].text,145 'balles contrées': balles_contrées[j].text, 'buts attendus': buts_attendus[j].text, 'buts attendus sans penalty': buts_attendus_sans_penalty[j].text,146 'buts attendus avec passe decisive': buts_attendus_avec_passe_decisive[j].text, 'action menant tirs': action_menant_tirs[j].text, 'action menant buts': action_menant_buts[j].text,147 'passes reussies': passes_reussies[j].text, 'passes tentes': passes_tentes[j].text, 'passes reussies%': pourcentage_de_passe_reussie[j].text, 'passe avant': passe_vers_l_avant[j].text,148 'balle au pied': balle_pied[j].text, 'progession balle au pied': progression_balle_au_pied[j].text,149 'Dribble reussi': reussi[j].text, 'Dribble tenter': tenter[j].text,'composition du match': composition_domicile[0].text}150 compo_match.append(data_test)151 compo_match.append({"Equipe à domicile": ""})152153 for g in range(len(joueur_equipe_deux)):154 data_test2 = {'id': id, 'Club': club_a_lexterieur[0].text, 'Equipe à domicile': joueur_equipe_deux[g].text,155 'Position': position2[g].text, 'Minute joué': minute2[g].text,156 'buts': buts2[g].text, 'passe décisive': passe_decisive2[g].text, 'penalty marqué': penalty_marqués2[g].text,157 'penalty tiré': penalty_tirés2[g].text, 'tirs': tirs2[g].text, 'tirs cadrés': tirs_cadrés2[g].text,158 'carton jaune': carton_jaune2[g].text,159 'carton rouge': carton_rouge2[g].text, 'touches': touches2[g].text, 'pression': pression2[g].text, 'Nombre de joueur tacles': nombre_de_joueur_tacles2[g].text,160 'interception': interception2[g].text,161 'balles contrées': balles_contrées2[g].text, 'buts attendus': buts_attendus2[g].text, 'buts attendus sans penalty': buts_attendus_sans_penalty2[g].text,162 'buts attendus avec passe decisive': buts_attendus_avec_passe_decisive2[g].text, 'action menant tirs': action_menant_tirs2[g].text, 'action menant buts': action_menant_buts2[g].text,163 'passes reussies': passes_reussies2[g].text, 'passes tentes': passes_tentes2[g].text, 'passes reussies%': pourcentage_de_passe_reussie2[g].text, 'passe avant': passe_vers_l_avant2[g].text,164 'balle au pied': balle_pied2[g].text, 'progession balle au pied': progression_balle_au_pied2[g].text,165 'Dribble reussi': reussi2[g].text, 'Dribble tenter': tenter2[g].text,'composition du match': composition_exterieur[0].text}166 compo_match.append(data_test2)167 compo_match.append({"Equipe à l'exterieur": ""})168169 if loopsave == 11:170 df_data = pd.DataFrame(compo_match)171 df_data.to_excel(f'{nom_du_fichier}', index=False)172 loopsave = 1173174 return compo_match175176PATH = "C:\SeleniumDrivers\chromedriver.exe"177driver: WebDriver = webdriver.Chrome(PATH)178179liste_lien_pageprincipal = ["https://fbref.com/fr/comps/9/2019-2020/calendrier/Calendrier-et-resultats-2019-2020-Premier-League","https://fbref.com/fr/comps/9/2020-2021/calendrier/Calendrier-et-resultats-2020-2021-Premier-League",180 "https://fbref.com/fr/comps/9/2021-2022/calendrier/Calendrier-et-resultats-2021-2022-Premier-League"]181z=0182# On boucle sur nos fonctions pour qu'on puisse répeter trois la meme action183for elt in liste_lien_pageprincipal :184 z += 1185 extraction_fbref(elt)186 lien_rapport_de_match = rapportdematch()187 if z == 1:188 t = 0189 nom_du_fichier = "Data_saison2019_2020.xlsx"190 elif z == 2:191 t = 380192 nom_du_fichier = "Data_saison2020_2021.xlsx"193 else :194 t = 760195 nom_du_fichier = "Data_saison2021_22.xlsx" ...

Full Screen

Full Screen

test_summary.py

Source:test_summary.py Github

copy

Full Screen

...4import pymfe._internal5import pymfe._summary6import pymfe.mfe7import numpy as np8def test_get_summary():9 assert not set(pymfe.mfe.MFE.valid_summary()).symmetric_difference(10 pymfe._internal.VALID_SUMMARY11 )12def test_sum_histogram():13 mf = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]14 aux = pymfe._summary.sum_histogram(mf, bins=5)15 assert np.allclose(np.array([0.2, 0.2, 0.2, 0.2, 0.2]), aux)16def test_sum_quantiles():17 mf = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]18 aux = pymfe._summary.sum_quantiles(mf, package="numpy")19 assert np.allclose(np.array([1.0, 3.25, 5.5, 7.75, 10.0]), aux)20 with pytest.raises(ValueError):21 pymfe._summary.sum_quantiles(mf, package="asd")22 aux = pymfe._summary.sum_quantiles(mf, package="scipy")23 assert np.allclose(np.array([1.0, 2.95, 5.5, 8.05, 10.0]), aux)...

Full Screen

Full Screen

climateclassificationdisplay.py

Source:climateclassificationdisplay.py Github

copy

Full Screen

1from math import sin, cos, pi2import pygame3def coolscale(v):4 m = 10205 r = 255 - m * v if v < 0.25 else 06 g = (255 if v < 0.75 else7 255 - m * (v - 0.75))8 b = (255 - m * v if v < 0.25 else9 m * (v - 0.25) if v < 0.5 else10 255)11 return r, g, b12class ClimateClassDisplay(object):13 dt = 0.0114 15 def __init__(self, summary, sealevel):16 self._summary = summary17 self._sealevel = sealevel18 self.dirty = True19 @property20 def rotate(self):21 return self._rotate22 @rotate.setter23 def rotate(self, value):24 self._rotate = value25 self.dirty = True26 CLIMATE = 027 THRESHOLD = 128 MOISTURE = 229 @property30 def mode(self):31 return self._mode32 @mode.setter33 def mode(self, value):34 self._mode = value35 self.dirty = True36 def handle(self, e):37 return False38 colors = {39 u'A' : {40 u'f' : (0,0,255),41 u'm' : (0,63,255),42 u'w' : (0,127,255) },43 u'B' : {44 u'S' : (255,127,0),45 u'W' : (255,0,0) },46 u'C' : {47 u'f' : (0,255,0),48 u's' : (255,255,0),49 u'w' : (127,255,0) },50 u'D' : {51 u'f' : (0,255,255),52 u's' : (255,0,255),53 u'w' : (127,127,255) },54 u'E' : {55 u'F' : (127,127,127),56 u'T' : (191,191,191) }57 }58 59 def draw(self, surface):60 if self.dirty or self._screen.get_size() != surface.get_size():61 self._screen = pygame.Surface(surface.get_size(), 0, 32)62 63 self._screen.fill((0,0,0))64 res = max([len(r) for r in self._summary]), len(self._summary)65 66 template = pygame.Surface((self._screen.get_width()/res[0],67 self._screen.get_height()/res[1]), 0, 32)68 for y in range(res[1]):69 for x in range(len(self._summary[y])):70 block = template.copy()71 r = self.rotate72 o = r * len(self._summary[y])/36073 xo = x + o74 if xo > len(self._summary[y])-1:75 xo -= len(self._summary[y])76 elif xo < 0:77 xo += len(self._summary[y])78 79 h, t, p, thr, k = self._summary[y][xo]80 if h > self._sealevel:81 if self.mode == self.CLIMATE:82 color = self.colors[k[0]][k[1]]83 elif self.mode == self.MOISTURE:84 color = coolscale(p)85 elif self.mode == self.THRESHOLD:86 color = coolscale(thr)87 else:88 if self.mode == self.CLIMATE:89 color = (255,255,255)90 else:91 color = (0,0,0)92 block.fill(color)93 94 self._screen.blit(block,95 ((x + (res[0] - len(self._summary[y]))/2)*block.get_width(),96 y*block.get_height()))97 self.dirty = False98 ...

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