本文整理汇总了Python中tools.testlib.assertAlmostEqual函数的典型用法代码示例。如果您正苦于以下问题:Python assertAlmostEqual函数的具体用法?Python assertAlmostEqual怎么用?Python assertAlmostEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertAlmostEqual函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_reecriture
def test_reecriture():
f = Feuille()
H = f.objets.H = Fonction("2x^2+3x(1+x)", 'R')
def h(x):
return 2*x**2+3*x*(1+x)
assertAlmostEqual(H(17), h(17))
assertAlmostEqual(H(_VAL0), h(_VAL0))
开发者ID:Grahack,项目名称:geophar,代码行数:7,代码来源:test_fonctions.py
示例2: test_executer
def test_executer():
f = Feuille()
o = f.objets
f.executer("A = (1, 2)")
f.executer("A.x += 1")
assert(o.A.x == 2)
f.executer("A' = 3, 4")
f.executer("s = [A A']")
f.executer("I = Milieu(s)")
assertAlmostEqual(o.I.xy, (2.5, 3))
f.executer("del")
assert("I" not in o.noms)
assert("A_prime" in o.noms)
f.executer("del")
f.executer("del")
assert("A_prime" not in o.noms)
f.executer("= (1, 2)")
assert(o.M1.coordonnees == (1, 2))
f.executer("txt0 = `Bonjour !`")
f.executer(r"txt1 = `$P\`ere et m\`ere ont un accent grave.$`")
f.executer("chaine_vide = ``")
assert(o.txt0.texte == "Bonjour !")
assert(o.txt1.texte == r"$P\`ere et m\`ere ont un accent grave.$")
assert(o.chaine_vide.texte == "")
f.executer("M = (5, 7)")
f.executer("C = _")
assert(o.C.x == 5)
f.executer("=((i,sqrt(i)) for i in (3,4,5,6))")
assert(o.M2.xy == (3, sqrt(3)))
assert(o.M3.xy == (4, sqrt(4)))
assert(o.M4.xy == (5, sqrt(5)))
assert(o.M5.xy == (6, sqrt(6)))
开发者ID:Grahack,项目名称:geophar,代码行数:32,代码来源:test_feuille.py
示例3: test_Droite_equation
def test_Droite_equation():
a = randint(50) - randint(50) + 0.1 # afin que a ne soit pas nul
b = randint(50) - randint(50) + random()
c = randint(50) - randint(50) + random()
d, e, f = Droite_equation(a, b, c).equation
assertAlmostEqual((e / d, f / d), (b / a, c / a))
assertEqual(Droite_equation(a, 0, 0).equation[1:], (0, 0))
assertEqual((Droite_equation(0, a, 0).equation[0], Droite_equation(
0, a, 0).equation[2]), (0, 0))
assert (not Droite_equation(0, 0, 0).existe)
d = Droite_equation("y=-5/2x-3/2")
assert (Point(0, -1.5) in d)
assert (Point(-1, 1) in d)
d = Droite_equation("x=2*10**2")
assert (Point(200, -1000) in d)
assert (Point(100, -1000) not in d)
d = Droite_equation("2*x+2*y=1")
assert (Point(0.5, 0) in d)
assert (Point(1, -0.5) in d)
d = Droite_equation("x+y=1")
assert (Point(0, 1) in d)
assert (Point(1, 0) in d)
d = Droite_equation("x+2y=-2")
assert (Point(0, -1) in d)
assert (Point(-2, 0) in d)
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:25,代码来源:test_lignes.py
示例4: test_Carre_centre
def test_Carre_centre():
O = rand_pt()
M = rand_pt()
p = Carre_centre(O, M)
assert(p.centre.existe and p.centre is O)
assert(len(p.cotes) == 4)
assertAlmostEqual(p.aire, p.cotes[0].longueur**2)
开发者ID:Grahack,项目名称:geophar,代码行数:7,代码来源:test_polygones.py
示例5: test_Reflexion
def test_Reflexion():
d = Droite_equation(1, 6, -2)
r = Reflexion(d)
M = Point(random()+randint(50)-randint(50), random()+randint(50)-randint(50))
m = Mediatrice(M, r(M))
assertAlmostEqual(d.equation_reduite, m.equation_reduite)
assert(r(d) is d)
开发者ID:Grahack,项目名称:geophar,代码行数:7,代码来源:test_transformations.py
示例6: test_Triangle
def test_Triangle():
A = rand_pt()
B = rand_pt()
C = rand_pt()
t = Triangle(A, B, C)
O = t.centre_cercle_circonscrit
assertAlmostEqual(Segment(O, A).longueur, Segment(O, C).longueur)
开发者ID:Grahack,项目名称:geophar,代码行数:7,代码来源:test_polygones.py
示例7: test_Quadrilatere
def test_Quadrilatere():
A = rand_pt()
B = rand_pt()
C = rand_pt()
D = rand_pt()
p = Quadrilatere(A, B, C, D)
assertAlmostEqual(p.centre.coordonnees, Barycentre(A, B, C, D).coordonnees)
开发者ID:Grahack,项目名称:geophar,代码行数:7,代码来源:test_polygones.py
示例8: test_session
def test_session():
i = Interprete(verbose = VERBOSE)
i.evaluer("1+7")
i.evaluer("x-3")
i.evaluer("ans()+ans(1)")
assertDernier(i, "x + 5")
i.evaluer("f(x, y, z)=2x+3y-z")
i.evaluer("f(-1, 5, a)")
assertDernier(i, "-a + 13")
i.evaluer("f(x)=x^2-7x+3")
i.evaluer("f'(x)")
assertDernier(i, "2*x - 7")
# Noms réservés
assertRaises(NameError, i.evaluer, "e=3")
assertRaises(NameError, i.evaluer, "pi=3")
assertRaises(NameError, i.evaluer, "i=3")
assertRaises(NameError, i.evaluer, "oo=3")
assertRaises(NameError, i.evaluer, "factorise=3")
# Etc.
# Test des générateurs
i.evaluer('f(x)=x+3')
i.evaluer('[f(j) for j in range(1, 11)]')
assertDernier(i, '[4, 5, 6, 7, 8, 9, 10, 11, 12, 13]')
i.evaluer('tuple(i for i in range(7))')
assertDernier(i, '(0, 1, 2, 3, 4, 5, 6)')
i.evaluer('[j for j in range(7)]')
assertDernier(i, '[0, 1, 2, 3, 4, 5, 6]')
# _11 is an alias for ans(11)
i.evaluer('_11 == _')
assertDernier(i, 'True')
i.evaluer('_7')
assertDernier(i, "2*x - 7")
# _ is an alias for ans(-1), __ is an alias for ans(-2), and so on.
i.evaluer('_ == -7 + 2*x')
assertDernier(i, 'True')
i.evaluer('__')
assertDernier(i, "2*x - 7")
i.evaluer('______') # ans(-6)
assertDernier(i, '(0, 1, 2, 3, 4, 5, 6)')
# Affichage des chaînes en mode text (et non math)
i.evaluer('"Bonjour !"')
assert i.latex_dernier_resultat == u'\u201CBonjour !\u201D'
# Virgule comme séparateur décimal
resultat, latex = i.evaluer('1,2')
assert resultat == '1,2'
assertAlmostEqual(i.derniers_resultats[-1], 1.2)
# Avec un espace, c'est une liste (tuple) par contre
resultat, latex = i.evaluer('1, 2')
assertEqual(resultat, '(1 ; 2)')
resultat, latex = i.evaluer('"1.2"')
assert resultat == '"1.2"'
i.evaluer('?aide')
i.evaluer('aide?')
i.evaluer('aide(aide)')
msg_aide = u"\n== Aide sur aide ==\nRetourne (si possible) de l'aide sur la fonction saisie."
resultats = i.derniers_resultats
assert resultats[-3:] == [msg_aide, msg_aide, msg_aide]
# LaTeX
latex = i.evaluer("gamma(x)")[1]
assertEqual(latex, r'$\mathrm{\Gamma}\left(x\right)$')
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:60,代码来源:test_interprete.py
示例9: test_Parallele
def test_Parallele():
d0 = Droite_equation(2, 1, 7)
A = Point(-2, 3)
d = Parallele(d0, A)
assert(d.parallele(d0))
assert(d.droite is d0 and d.point is A)
assertAlmostEqual(d0.equation[:1], d.equation[:1])
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:7,代码来源:test_lignes.py
示例10: test_Point_equidistant
def test_Point_equidistant():
A = rand_pt()
B = rand_pt()
C = rand_pt()
P = Point_equidistant(A, B, C)
assertAlmostEqual(Segment(A, P).longueur, Segment(B, P).longueur)
assertAlmostEqual(Segment(A, P).longueur, Segment(C, P).longueur)
assert(P in Mediatrice(A, B))
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:8,代码来源:test_points.py
示例11: test_variables
def test_variables():
f = Feuille()
o = f.objets
a = o.a = 3
b = o.b = 5
g = o.g = Fonction("a*x+b")
assertAlmostEqual(g(4), a*4+b)
assertAlmostEqual(g(_VAL0), a*_VAL0+b)
开发者ID:Grahack,项目名称:geophar,代码行数:8,代码来源:test_fonctions.py
示例12: test_Secteur_angulaire
def test_Secteur_angulaire():
u = Vecteur_libre(5.458, -2.546)
v = Vecteur_libre(-5.75, 12.6)
P = Point(2.54, -5.68)
a = Secteur_angulaire(P, u, v)
assert(isinstance(a.etiquette, Label_angle))
assertAlmostEqual(a.val, 2.43538435941)
assertAlmostEqual(a.degre, 139.537245287)
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:8,代码来源:test_angles.py
示例13: test_Pentagone
def test_Pentagone():
A = rand_pt()
B = rand_pt()
C = rand_pt()
D = rand_pt()
E = rand_pt()
p = Pentagone(A, B, C, D, E)
assertAlmostEqual(p.centre.coordonnees, Barycentre(A, B, C, D, E).coordonnees)
开发者ID:Grahack,项目名称:geophar,代码行数:8,代码来源:test_polygones.py
示例14: test_Hexagone
def test_Hexagone():
A = rand_pt()
B = rand_pt()
C = rand_pt()
D = rand_pt()
E = rand_pt()
F = rand_pt()
p = Hexagone(A, B, C, D, E, F)
assertAlmostEqual(p.centre.coordonnees, Barycentre(A, B, C, D, E, F).coordonnees)
开发者ID:Grahack,项目名称:geophar,代码行数:9,代码来源:test_polygones.py
示例15: test_Extremite
def test_Extremite():
v=Vecteur_libre(-4.2, -6.7)
w = Representant(v)
A = w.origine
B = w.extremite
assertAlmostEqual((B.x - A.x, B.y - A.y), (v.x, v.y))
C = Extremite(w, couleur = 'purple')
assert C is B
assert C.style('couleur') == 'purple'
开发者ID:jpg32,项目名称:geophar,代码行数:9,代码来源:test_vecteurs.py
示例16: test_Bissectrice
def test_Bissectrice():
A = Point(1, -5)
B = Point(1.5, -5.3)
C = Point(3, -4)
d = Bissectrice(A, B, C)
a, b, c = d.equation
d, e = (0.0870545184921, -1.03861105199)
assertAlmostEqual(b/a, d)
assertAlmostEqual(c/a, e)
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:9,代码来源:test_lignes.py
示例17: test_Perpendiculaire
def test_Perpendiculaire():
d = Droite_equation(-1, 2, 0)
M = Point()
d0 = Perpendiculaire(d, M)
a, b, c = d.equation
a0, b0, c0 = d0.equation
assert(d.perpendiculaire(d0))
assertAlmostEqual(a*a0 + b*b0, 0)
assert(M in d0)
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:9,代码来源:test_lignes.py
示例18: test_Droite_vectorielle
def test_Droite_vectorielle():
v = Vecteur_libre(1, 7)
A = Point(-2, 3)
d = Droite_vectorielle(A, v)
assert(d.vecteur is v and d.point is A)
assertAlmostEqual(v.y/v.x, -d.equation[0]/d.equation[1])
B = rand_pt()
d1 = Droite_vectorielle(B, v)
assert(d.parallele(d1))
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:9,代码来源:test_lignes.py
示例19: test_Point_final
def test_Point_final():
A = Point(random(),random())
C = Point(random(),random())
u = Vecteur_libre(random(),random())
v = Vecteur(Point(random(), random()), Point(random(), random()))
w = Representant(Vecteur(Point(random(), random()), Point(random(), random())), A)
F = Point_final(C, (u, v, w), (-2, 1.5, 4))
assertEqual(type(F.coordonnees), tuple)
assertAlmostEqual(F.x, C.x -2*u.x+1.5*v.x+4*w.x)
assertAlmostEqual(F.y, C.y -2*u.y+1.5*v.y+4*w.y)
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:10,代码来源:test_points.py
示例20: test_modification_variable
def test_modification_variable():
f = Feuille()
o = f.objets
o.a = Variable(1)
o.fa = "5*sin(4/(a+.5))-1.5"
o.A = Point(o.a, o.fa)
o.fa = "-5*sin(4/(a+.5))+5.5"
o.A = Point(o.a, o.fa)
assertAlmostEqual(o.A.x, o.a)
assertAlmostEqual(o.A.y, o.fa)
开发者ID:Grahack,项目名称:geophar,代码行数:10,代码来源:test_feuille.py
注:本文中的tools.testlib.assertAlmostEqual函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论