Best Python code snippet using rester_python
test_geometry.py
Source: test_geometry.py
...11# ---------- 3d ----------12def line_problem_3d_0():13 """A problem with a Line (and no CoincicentConstraints)"""14 problem = GeometricProblem(dimension=3)15 problem.add_variable(Line('l1'),vector([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]))16 return problem 17def line_problem_3d_1():18 """A problem with a Line and 1 CoincicentConstraint"""19 problem = GeometricProblem(dimension=3)20 problem.add_variable(Point('p1'),vector([3.0, 2.0, 1.0]))21 problem.add_variable(Line('l1'),vector([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]))22 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))23 return problem 24def line_problem_3d_2():25 """A problem with a Line and 2 CoincicentConstraints"""26 problem = GeometricProblem(dimension=3)27 problem.add_variable(Point('p1'),vector([3.0, 2.0, 1.0]))28 problem.add_variable(Point('p2'),vector([1.0, 1.0, 1.0]))29 problem.add_variable(Line('l1'),vector([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]))30 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))31 problem.add_constraint(CoincidenceConstraint(Point('p2'), Line('l1')))32 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p2'), 5.0))33 return problem 34def line_problem_3d_3():35 """A problem with a Line and a 3 CoincicentConstraints"""36 problem = GeometricProblem(dimension=3)37 problem.add_variable(Point('p1'),vector([3.0, 2.0, 1.0]))38 problem.add_variable(Point('p2'),vector([1.0, 1.0, 1.0]))39 problem.add_variable(Line('l1'),vector([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]))40 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))41 problem.add_constraint(CoincidenceConstraint(Point('p2'), Line('l1')))42 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p2'), 5.0))43 problem.add_variable(Point('p3'),vector([0.0, 0.0, 1.0]))44 problem.add_constraint(CoincidenceConstraint(Point('p3'), Line('l1')))45 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p3'), 8.0))46 return problem 47def line_problem_3d_4():48 """A problem with a Line and a 4 CoincicentConstraints"""49 problem = GeometricProblem(dimension=3)50 problem.add_variable(Point('p1'),vector([3.0, 2.0, 1.0]))51 problem.add_variable(Point('p2'),vector([1.0, 1.0, 1.0]))52 problem.add_variable(Line('l1'),vector([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]))53 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))54 problem.add_constraint(CoincidenceConstraint(Point('p2'), Line('l1')))55 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p2'), 5.0))56 problem.add_variable(Point('p3'),vector([0.0, 0.0, 1.0]))57 problem.add_constraint(CoincidenceConstraint(Point('p3'), Line('l1')))58 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p3'), 8.0))59 problem.add_variable(Point('p4'),vector([1.0, 0.0, 1.0]))60 problem.add_constraint(CoincidenceConstraint(Point('p4'), Line('l1')))61 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p4'), 0.1))62 return problem 63# ------------2d64def line_problem_2d_0():65 """A problem with a Line (and no CoincicentConstraints)"""66 problem = GeometricProblem(dimension=2)67 problem.add_variable(Line('l1'),vector([0.0, 0.0, 1.0, 1.0]))68 return problem 69def line_problem_2d_1():70 """A problem with a Line and 1 CoincicentConstraint"""71 problem = GeometricProblem(dimension=2)72 problem.add_variable(Point('p1'),vector([3.0, 2.0]))73 problem.add_variable(Line('l1'),vector([0.0, 0.0, 1.0, 1.0]))74 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))75 return problem 76def line_problem_2d_2():77 """A problem with a Line and 2 CoincicentConstraints"""78 problem = GeometricProblem(dimension=2)79 problem.add_variable(Point('p1'),vector([3.0, 2.0]))80 problem.add_variable(Point('p2'),vector([1.0, 1.0]))81 problem.add_variable(Line('l1'),vector([0.0, 0.0, 1.0, 1.0]))82 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))83 problem.add_constraint(CoincidenceConstraint(Point('p2'), Line('l1')))84 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p2'), 5.0))85 return problem 86def line_problem_2d_3a():87 """A problem with a Line and a 3 CoincicentConstraints"""88 problem = GeometricProblem(dimension=2)89 problem.add_variable(Point('p1'),vector([3.0, 2.0]))90 problem.add_variable(Point('p2'),vector([1.0, 1.0]))91 problem.add_variable(Line('l1'),vector([0.0, 0.0, 1.0, 1.0]))92 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))93 problem.add_constraint(CoincidenceConstraint(Point('p2'), Line('l1')))94 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p2'), 5.0))95 problem.add_variable(Point('p3'),vector([1.0, 0.0]))96 problem.add_constraint(CoincidenceConstraint(Point('p3'), Line('l1')))97 problem.add_constraint(DistanceConstraint(Point('p3'), Point('p2'), 8.0))98 return problem 99def line_problem_2d_3b():100 """A problem with a Line and a 3 CoincicentConstraints"""101 problem = GeometricProblem(dimension=2)102 problem.add_variable(Point('p1'),vector([3.0, 2.0]))103 problem.add_variable(Point('p2'),vector([1.0, 1.0]))104 problem.add_variable(Line('l1'),vector([0.0, 0.0, 1.0, 1.0]))105 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))106 problem.add_constraint(CoincidenceConstraint(Point('p2'), Line('l1')))107 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p2'), 5.0))108 problem.add_variable(Point('p3'),vector([1.0, 0.0]))109 problem.add_constraint(CoincidenceConstraint(Point('p3'), Line('l1')))110 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p3'), 8.0))111 return problem 112def line_problem_2d_4():113 """A problem with a Line and a 4 CoincicentConstraints"""114 problem = GeometricProblem(dimension=2)115 problem.add_variable(Point('p1'),vector([3.0, 2.0]))116 problem.add_variable(Point('p2'),vector([1.0, 1.0]))117 problem.add_variable(Line('l1'),vector([0.0, 0.0, 1.0, 1.0]))118 problem.add_constraint(CoincidenceConstraint(Point('p1'), Line('l1')))119 problem.add_constraint(CoincidenceConstraint(Point('p2'), Line('l1')))120 problem.add_constraint(DistanceConstraint(Point('p1'), Point('p2'), 5.0))121 problem.add_variable(Point('p3'),vector([2.0, 0.0]))122 problem.add_constraint(CoincidenceConstraint(Point('p3'), Line('l1')))123 problem.add_constraint(DistanceConstraint(Point('p2'), Point('p3'), 8.0))124 problem.add_variable(Point('p4'),vector([3.0, 0.0]))125 problem.add_constraint(CoincidenceConstraint(Point('p4'), Line('l1')))126 problem.add_constraint(DistanceConstraint(Point('p2'), Point('p4'), 0.1))127 return problem 128def test_line():129 diag_select("(GeometricSolver)|(CoincidenceConstraint)")130 #test(line_problem_2d_0())131 #test(line_problem_2d_1())132 #test(line_problem_2d_2())133 #test(line_problem_2d_3a())134 #test(line_problem_2d_3b())135 #test(line_problem_2d_4())136 #test(line_problem_3d_0())137 #test(line_problem_3d_1())138 test(line_problem_3d_2())...
examples_bprop.py
Source: examples_bprop.py
1import core2def bn_vstruct():3 g = core.BayesNet()4 g.add_variable('X', (0, 1))5 g.add_variable('Y', (0, 1))6 g.add_variable('Z', (0, 1))7 g.add_cpt(None, 'X',8 {0: 0.001,9 1: 0.999})10 g.add_cpt(None, 'Y',11 {0: 0.001,12 1: 0.999})13 g.add_cpt(('X', 'Y'), 'Z',14 {(0, 0, 0): 0.99,15 (0, 0, 1): 0.01,16 (0, 1, 0): 0.99,17 (0, 1, 1): 0.01,18 (1, 0, 0): 0.99,19 (1, 0, 1): 0.01,20 (1, 1, 0): 0.001,21 (1, 1, 1): 0.999})22 return g23# The Naive Bayes network from Problem Set 2, Exercise 2.24def bn_naive_bayes():25 g = core.BayesNet()26 g.add_variable('Coin', ('a', 'b', 'c'))27 g.add_variable('X1', ('H', 'T'))28 g.add_variable('X2', ('H', 'T'))29 g.add_variable('X3', ('H', 'T'))30 g.add_cpt(None, 'Coin', {'a': 1.0 / 3, 'b': 1.0 / 3, 'c': 1.0 / 3})31 g.add_cpt('Coin', 'X1',32 {('a', 'H'): 0.2,33 ('a', 'T'): 0.8,34 ('b', 'H'): 0.6,35 ('b', 'T'): 0.4,36 ('c', 'H'): 0.8,37 ('c', 'T'): 0.2})38 g.add_cpt('Coin', 'X2',39 {('a', 'H'): 0.2,40 ('a', 'T'): 0.8,41 ('b', 'H'): 0.6,42 ('b', 'T'): 0.4,43 ('c', 'H'): 0.8,44 ('c', 'T'): 0.2})45 g.add_cpt('Coin', 'X3',46 {('a', 'H'): 0.2,47 ('a', 'T'): 0.8,48 ('b', 'H'): 0.6,49 ('b', 'T'): 0.4,50 ('c', 'H'): 0.8,51 ('c', 'T'): 0.2})52 return g53# The earthquake network from Problem Set 4.54def bn_earthquake():55 g = core.BayesNet()56 g.add_variable('Earthquake', (0, 1))57 g.add_variable('Burglar', (0, 1))58 g.add_variable('Radio', (0, 1))59 g.add_variable('Alarm', (0, 1))60 g.add_variable('Phone', (0, 1))61 g.add_cpt(None, 'Earthquake',62 {0: 0.999,63 1: 0.001})64 g.add_cpt(None, 'Burglar',65 {0: 0.999,66 1: 0.001})67 g.add_cpt(('Burglar', 'Earthquake'), 'Alarm',68 {(0, 0, 0): 0.999,69 (0, 0, 1): 0.001,70 (1, 0, 0): 0.00999,71 (1, 0, 1): 0.99001,72 (0, 1, 0): 0.98901,73 (0, 1, 1): 0.01099,74 (1, 1, 0): 0.0098901,...
Check out the latest blogs from LambdaTest on this topic:
Lack of training is something that creates a major roadblock for a tester. Often, testers working in an organization are all of a sudden forced to learn a new framework or an automation tool whenever a new project demands it. You may be overwhelmed on how to learn test automation, where to start from and how to master test automation for web applications, and mobile applications on a new technology so soon.
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.
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!!