Best Python code snippet using SeleniumBase
__init__.py
Source:__init__.py
...103 return104 personnage.agir("magie")105 personnage.etats.ajouter("magie")106 if parchemin:107 sort.concentrer(personnage, None, apprendre=False,108 maitrise=maitrise)109 parchemin.charges -= 1110 else:111 sort.concentrer(personnage, None, maitrise=maitrise)112 else:113 if sort.type_cible == "aucune":114 personnage << "|err|Ce sort ne peut être lancé sur une " \115 "cible.|ff|"116 else:117 # Vérification du type de cible118 if sort.type_cible == "personnage" and not isinstance(cible,119 Personnage):120 personnage << "|err|Ce sort ne peut être lancé que sur " \121 "un personnage ou une créature.|ff|"122 return123 if sort.type_cible == "objet" and not isinstance(cible, Objet):124 personnage << "|err|Ce sort ne peut être lancé que sur " \125 "un objet.|ff|"126 return127 if not sort.peut_lancer(personnage):128 personnage << "|err|Vous ne pouvez lancer ce sort.|ff|"129 return130 personnage.agir("magie")131 personnage.etats.ajouter("magie")132 if parchemin:133 sort.concentrer(personnage, cible, apprendre=False,134 maitrise=maitrise)135 parchemin.charges -= 1136 else:...
faisceaux_anim.py
Source:faisceaux_anim.py
1import math2import numpy as np3from Recolocate import Recolocate4from manim import *5from utils import *6from textClasses import *7class MethodeFaisceaux(Scene): 8 def drawPath(self, points, show=True, wait=None, nDash=0, opacity=1, color=ORANGE):9 lines = []10 for k in range(len(points)-1):11 if nDash == 0:12 lines.append(Line(points[k], points[k+1], color=color))13 else:14 d = distance(points[k].get_center(), points[k+1].get_center())15 lines.append(DashedLine(points[k], points[k+1], color=color, dashed_length=.5*d/nDash))16 lines[-1].set_opacity(opacity)17 if show is True:18 if wait is not None:19 self.play(Create(lines[-1]))20 else:21 self.add(lines[-1])22 return lines23 def makeLines(self, angles, center=[0,0,0], radius=1, numberDash=10, wait=.5, color=ORANGE):24 Lines = [makeLineAtAngle(a, center=center, radius=radius, numberDash=numberDash, color=color) for a in angles]25 if wait is not None:26 if wait == 0:27 self.play(*[GrowFromPoint(line, center) for line in Lines])28 else:29 for line in Lines:30 self.play(GrowFromPoint(line, center))31 self.wait(wait)32 return Lines33 def construct(self):34 # Chapter intro35 titre = SplashScreen(title="4 - Développements futurs", titleScale=.5, titleShift=2*UP)36 self.play(FadeIn(titre))37 self.wait(5)38 # Vitesse des calculs39 subTitle = Text("Vitesse des calculs").scale(.35).shift(1.5*UP)40 titre.add(subTitle)41 self.play(FadeIn(subTitle))42 self.wait(4)43 text1 = TextItem("A cause du problème de généralisation, il est nécessaire de calculer les performances des échantillons un certain nombre de fois").shift(UP)44 text2 = TextItem("Compromis entre la précision souhaitée et la puissance de calcul disponible")45 text3 = TextItem("Solutions envisagées :").shift(DOWN)46 text4 = Group(TextItem("exécution multi-coeurs"),47 TextItem("possibilité de sauvegarder des points de contrôle (checkpoint) des exécutions").shift(.7*DOWN),48 TextItem("calculs en plusieurs passes -> observation de résultats de plus en plus précis").shift(2*.7*DOWN))49 text4.shift(2*DOWN+RIGHT)50 text = Group(text1, text2, text3, text4).scale(.5).shift(7*LEFT)51 for t in text:52 self.play(FadeIn(t))53 if t == text1: self.wait(20)54 elif t == text2: self.wait(10)55 elif t == text3: self.wait(1)56 elif t == text4: self.wait(50)57 self.play(FadeOut(text), titre.animate.shift(UP))58 self.play(FadeOut(subTitle))59 self.wait(2)60 # Méthode des faisceaux61 subTitle2 = Text("Méthode des faisceaux").scale(.35).shift(2.5*UP)62 titre.add(subTitle2)63 self.play(FadeIn(subTitle2))64 self.wait(3)65 # Demonstration66 points = Group(*[Dot(color=BLUE, radius=2*DEFAULT_DOT_RADIUS) for _ in range(7)])67 points[0].shift(5*LEFT + 2*DOWN)68 points[1].shift(4*LEFT + UP)69 points[2].shift(2*LEFT + 2*UP)70 points[3].shift(RIGHT)71 points[4].shift(2*RIGHT + 2*UP)72 points[5].shift(6*RIGHT + UP)73 points[6].shift(5*RIGHT + 2*DOWN)74 points.shift(.5*DOWN).scale(.75)75 path = self.drawPath(points, show=False, nDash=10, color=GREEN, opacity=.5)76 for k in range(len(points)):77 if k > 0:78 self.play(FadeIn(points[k]), Create(path[k-1]))79 else:80 self.play(FadeIn(points[k]))81 lines = self.drawPath(points, wait=1)82 self.wait(5)83 self.play(*[FadeOut(l) for l in lines])84 lines = self.drawPath(points[::2], wait=1)85 self.wait(2)86 self.play(*[FadeOut(l) for l in lines])87 lines = self.drawPath(points[::3], wait=1)88 self.wait(8)89 self.play(*[FadeOut(l) for l in lines])90 removeGroup = VGroup(*points[-3:], *path[-3:])91 self.play(FadeOut(removeGroup))92 self.wait(1)93 points, path = points[:-3], path[:-3]94 stayGroup = VGroup(*points, *path)95 self.play(Recolocate(stayGroup, points[0], points[-1], 3*LEFT+1.5*DOWN, 3*RIGHT+1.5*DOWN))96 self.wait(13)97 d = distance(points[0].get_center(), points[-1].get_center())98 # Vignette99 circle = Circle(d, arc_center=points[0].get_center(), color=RED)100 angles = (0, angleBetween(points[0].get_center(), points[1].get_center()),101 angleBetween(points[0].get_center(), points[2].get_center()))102 lines = self.makeLines(angles, center=points[0].get_center(), radius=d, numberDash=20, wait=None)103 self.play(GrowFromCenter(circle), *[GrowFromPoint(l, points[0].get_center()) for l in lines])104 self.wait(3)105 self.play(ShrinkToCenter(circle), *[l.animate.scale(0.001) for l in lines])106 self.remove(circle, *lines)107 self.wait(10)108 # Faisceaux109 line = Line(points[0].get_center(), points[-1].get_center(), color=ORANGE)110 self.play(Create(line))111 self.wait(1)112 hyperplans = [Line(points[0].get_center()+2*DOWN, points[0].get_center()+2*UP, color=GREEN),113 Line(points[-1].get_center()+2*DOWN, points[-1].get_center()+2*UP, color=GREEN)]114 self.play(*[Create(h) for h in hyperplans])115 self.wait(4)116 sampled1 = sampleLine(hyperplans[0], 6)117 sampled2 = sampleLine(hyperplans[1], 6)118 self.play(*[FadeIn(s) for s in sampled1], *[FadeIn(s) for s in sampled2])119 self.wait(3)120 beam = [DashedLine(sampled1[k].get_center(), sampled2[k].get_center(),121 color=ORANGE, dash_length=.5*d/20) for k in range(len(sampled1))]122 self.play(*[Create(b) for b in beam])123 self.wait(3)124 # Cela revient à concentrer Vignette125 drawGroup = Group(stayGroup, line, *hyperplans, *sampled1, *sampled2, *beam)126 self.play(drawGroup.animate.scale(.75))127 self.play(drawGroup.animate.shift(3*LEFT))128 descr1 = TextItem("Cette méthode revient à concentrer Vignette selon une direction").shift(UP)129 descr2 = TextItem("On obtient un meilleur aperçu de l'environnement rencontré\npar le modèle")130 descr3 = TextItem("Du fait de la concentration des droites, moins de discontinuités pour\nla détection de structures").shift(1.1*DOWN)131 descr = Group(descr1, descr2, descr3).scale(.5).shift(3*LEFT+.25*DOWN)132 for d in descr:133 self.play(FadeIn(d))134 self.wait(3)...
TD11_evidence.py
Source:TD11_evidence.py
1# Hugo BERANGER - M2 MIAGE IA2from __future__ import print_function3from pyds import MassFunction4from itertools import product5print('=== creating mass functions ===')6m1 = MassFunction([({'NW', 'N', 'E', 'SE'}, 0.5), ({'C', 'NE'}, 0.3), ({'W', 'SW', 'S'}, 0.2)]) # Q17print('m_1 =', m1) 8m2 = MassFunction([({'SW'}, 0.5), ({'C', 'S'}, 0.3), ({'E', 'SE'}, 0.2)]) # Q29print('m_2 =', m2)10m3 = MassFunction([({'NW', 'N', 'NE', 'W', 'C', 'E', 'SW', 'S', 'SE'}, 0.9), ({'W'}, 0.1)]) # Q311print('m_3 =', m3)12print('\n=== Dempster\'s combination rule, unnormalized conjunctive combination (exact and approximate) ===')13print('Dempster\'s combination rule for m_1, m_2, and m_3 =', m1.combine_conjunctive(m2, m3)) # Q414combined = m1.combine_conjunctive(m2, m3)15# Il faudrait concentrer les recherches dans les secteurs SE et E puis SW > C > S16print('\n=== pignistic transformation ===')17print('pignistic transformation of combined =', combined.pignistic())18print('pignistic transformation of m_1 =', m1.pignistic())19print('pignistic transformation of m_2 =', m2.pignistic())20print('pignistic transformation of m_3 =', m3.pignistic())21# Q522print('\n=== test erreur estimations masses ===')23m1 = MassFunction([({'NW', 'N', 'E', 'SE'}, 0.45), ({'C', 'NE'}, 0.35), ({'W', 'SW', 'S'}, 0.2)])24print('\n=== Dempster\'s combination rule, unnormalized conjunctive combination (exact and approximate) ===')25print('Dempster\'s combination rule for m_1, m_2, and m_3 =', m1.combine_conjunctive(m2, m3)) # Q426combined = m1.combine_conjunctive(m2, m3)27# Il faudrait concentrer les recherches dans les secteurs C puis SW > S > E > SE28# Une legère erreur dans l'estimation des masses change grandement le résultat29print('\n=== pignistic transformation ===')...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!