How to use _make_group method in autotest

Best Python code snippet using autotest_python

controller_test.py

Source:controller_test.py Github

copy

Full Screen

...55 tolerance = 0.0000156 self.failUnless(vec.x**2 + vec.y**2 + vec.z**2 <= mag**2 + tolerance, (vec, mag))57class ControllerTest(ControllerTestBase):58 59 def _make_group(self):60 from lepton import Particle, ParticleGroup61 g = ParticleGroup()62 g.new(Particle((0,0,0), (0,0,0)))63 g.new(Particle((0,0,0), (1,1,1), size=(2,2,2)))64 g.new(Particle((1,1,1), (-2,-2,-2), size=(3,2,0)))65 g.update(0)66 return g67 def test_Gravity_controller(self):68 from lepton import controller69 group = self._make_group()70 gravity = controller.Gravity((0.5, 1.0, 2.0))71 gravity(0.1, group)72 p = list(group)73 self.assertVector(p[0].velocity, (0.05, 0.1, 0.2))74 self.assertVector(p[1].velocity, (1.05, 1.1, 1.2))75 self.assertVector(p[2].velocity, (-1.95, -1.9, -1.8))76 77 def test_Lifetime_controller(self):78 from lepton import controller, Particle, ParticleGroup79 g = ParticleGroup()80 g.new(Particle(age=0))81 g.new(Particle(age=0.8))82 g.new(Particle(age=1.0))83 g.new(Particle(age=0.75))84 lifetime = controller.Lifetime(max_age=0.75)85 g.update(0)86 lifetime(0, g)87 p = list(g)88 self.assertEqual(len(g), 2)89 self.assertFloatEqiv(p[0].age, 0.0)90 self.assertFloatEqiv(p[1].age, 0.75)91 92 def test_Movement_controller_simple(self):93 from lepton import controller94 group = self._make_group()95 96 # Simple movement, no acceleration or damping97 movement = controller.Movement()98 movement(0.2, group)99 p = list(group)100 self.assertVector(p[0].position, (0,0,0))101 self.assertVector(p[1].position, (0.2,0.2,0.2))102 self.assertVector(p[2].position, (0.6,0.6,0.6))103 def test_Movement_controller_damping_scalar(self):104 from lepton import controller105 group = self._make_group()106 # Movement w/damping107 movement = controller.Movement(damping=0.9)108 movement(0.1, group)109 p = list(group)110 self.assertVector(p[0].velocity, (0,0,0))111 self.assertVector(p[1].velocity, (0.9,0.9,0.9))112 self.assertVector(p[2].velocity, (-1.8,-1.8,-1.8))113 def test_Movement_controller_damping_vector(self):114 from lepton import controller115 group = self._make_group()116 # Movement w/damping vector117 movement = controller.Movement(damping=(1,0.9,1))118 movement(0.1, group)119 p = list(group)120 self.assertVector(p[0].velocity, (0,0,0))121 self.assertVector(p[1].velocity, (1.0,0.9,1.0))122 self.assertVector(p[2].velocity, (-2.0,-1.8,-2.0))123 def test_Growth_controller_simple(self):124 from lepton import controller125 group = self._make_group()126 # Simple growth, no damping127 growth = controller.Growth(1)128 growth(0.2, group)129 p = list(group)130 self.assertVector(p[0].size, (0.2,0.2,0.2))131 self.assertVector(p[1].size, (2.2,2.2,2.2))132 self.assertVector(p[2].size, (3.2,2.2,0.2))133 def test_Growth_controller_damping_scalar(self):134 from lepton import controller135 group = self._make_group()136 # Growth w/damping137 growth = controller.Growth(growth=1, damping=0.9)138 growth(0.1, group)139 growth(0.1, group)140 p = list(group)141 self.assertVector(p[0].size, (0.19,0.19,0.19))142 self.assertVector(p[1].size, (2.19,2.19,2.19))143 self.assertVector(p[2].size, (3.19,2.19,0.19))144 def test_Growth_controller_damping_vector(self):145 from lepton import controller146 group = self._make_group()147 # Growth w/damping vector148 growth = controller.Growth(growth=(2,1,0), damping=(1,0.9,0))149 growth(0.1, group)150 growth(0.1, group)151 p = list(group)152 self.assertVector(p[0].size, (0.4,0.19,0))153 self.assertVector(p[1].size, (2.4,2.19,2))154 self.assertVector(p[2].size, (3.4,2.19,0))155 def test_Movement_controller_max_velocity(self):156 from lepton import controller157 group = self._make_group()158 # Movement w/max velocity159 movement = controller.Movement(max_velocity=0.5)160 movement(0, group)161 p = list(group)162 self.assertMag(p[0].velocity, 0)163 self.assertMag(p[1].velocity, 0.5)164 self.assertMag(p[2].velocity, 0.5)165 def test_Movement_controller_min_velocity(self):166 from lepton import controller167 group = self._make_group()168 # Movement w/min velocity169 movement = controller.Movement(min_velocity=2.0)170 movement(0, group)171 p = list(group)172 self.assertMag(p[0].velocity, 0)173 self.assertMag(p[1].velocity, 2.0)174 self.assertMag(p[2].velocity, math.sqrt(12))175 176 def test_Collector_controller_collect_inside(self):177 from lepton import controller178 group = self._make_group()179 collector = controller.Collector(DummyCubeDomain(size=0.5))180 self.assertEqual(len(group), 3)181 collector(0, group)182 self.assertEqual(len(group), 1)183 self.assertEqual(collector.collected_count, 2)184 p = list(group)185 self.assertVector(p[0].position, (1, 1, 1))186 def test_Collector_controller_collect_outside(self):187 from lepton import controller188 group = self._make_group()189 collector = controller.Collector(DummyCubeDomain(size=0.5), collect_inside=False)190 self.assertEqual(len(group), 3)191 collector(0, group)192 self.assertEqual(len(group), 2)193 self.assertEqual(collector.collected_count, 1)194 p = list(group)195 self.assertVector(p[0].position, (0, 0, 0))196 self.assertVector(p[1].position, (0, 0, 0))197 def test_Collector_controller_callback(self):198 from lepton import controller199 group = self._make_group()200 collector = None201 killed_pos = []202 def callback(particle, pgroup, controller):203 self.assertEqual(controller, collector)204 self.assertEqual(pgroup, group)205 killed_pos.append(tuple(particle.position))206 collector = controller.Collector(DummyCubeDomain(size=0.5), callback=callback)207 collector(0, group)208 self.assertEqual(len(group), 1)209 p = list(group)210 self.assertVector(p[0].position, (1, 1, 1))211 self.assertEqual(killed_pos, [(0,0,0), (0,0,0)])212 213class BounceControllerTest(ControllerTestBase):214 def _make_group(self):215 from lepton import Particle, ParticleGroup216 g = ParticleGroup()217 g.new(Particle(position=(0, 1, 0), velocity=(0, -1, 0))),218 g.new(Particle(position=(0, 1, 0), velocity=(0, -1.5, 0))),219 g.new(Particle(position=(-1, -1, 1), velocity=(2, 2, 0))),220 g.new(Particle(position=(1, 1, 1), velocity=(0, 1, 0)))221 g.update(0)222 p = list(g)223 p[0].position = (0, 0, 0)224 p[1].position = (0, -0.5, 0)225 p[2].position = (1, 1, 1)226 p[3].position = (1, 2, 1)227 return g228 229 def test_Bounce_controller_defaults(self):230 from lepton import controller231 group = self._make_group()232 bounce = controller.Bounce(DummyPlaneDomain())233 bounce(0, group)234 p = list(group)235 self.assertVector(p[0].position, (0, 0, 0))236 self.assertVector(p[0].velocity, (0, 1, 0))237 self.assertVector(p[1].position, (0, 0.5, 0))238 self.assertVector(p[1].velocity, (0, 1.5, 0))239 self.assertVector(p[2].position, (1, -1, 1))240 self.assertVector(p[2].velocity, (2, -2, 0))241 self.assertVector(p[3].position, (1, 2, 1))242 self.assertVector(p[3].velocity, (0, 1, 0))243 def test_Bounce_controller_low_bounce(self):244 from lepton import controller245 group = self._make_group()246 bounce = controller.Bounce(DummyPlaneDomain(), bounce=0.5)247 bounce(0, group)248 p = list(group)249 self.assertVector(p[0].position, (0, 0, 0))250 self.assertVector(p[0].velocity, (0, 0.5, 0))251 self.assertVector(p[1].position, (0, 0.25, 0))252 self.assertVector(p[1].velocity, (0, 0.75, 0))253 self.assertVector(p[2].position, (1, -0.5, 1))254 self.assertVector(p[2].velocity, (2, -1, 0))255 self.assertVector(p[3].position, (1, 2, 1))256 self.assertVector(p[3].velocity, (0, 1, 0))257 def test_Bounce_controller_high_friction(self):258 from lepton import controller259 group = self._make_group()260 bounce = controller.Bounce(DummyPlaneDomain(), friction=0.5)261 bounce(0, group)262 p = list(group)263 self.assertVector(p[0].position, (0, 0, 0))264 self.assertVector(p[0].velocity, (0, 1, 0))265 self.assertVector(p[1].position, (0, 0.5, 0))266 self.assertVector(p[1].velocity, (0, 1.5, 0))267 self.assertVector(p[2].position, (1, -1, 0.5))268 self.assertVector(p[2].velocity, (1, -2, 0))269 self.assertVector(p[3].position, (1, 2, 1))270 self.assertVector(p[3].velocity, (0, 1, 0))271 def test_Bounce_controller_neg_friction(self):272 from lepton import controller273 group = self._make_group()274 bounce = controller.Bounce(DummyPlaneDomain(), friction=-0.5)275 bounce(0, group)276 p = list(group)277 self.assertVector(p[0].position, (0, 0, 0))278 self.assertVector(p[0].velocity, (0, 1, 0))279 self.assertVector(p[1].position, (0, 0.5, 0))280 self.assertVector(p[1].velocity, (0, 1.5, 0))281 self.assertVector(p[2].position, (1, -1, 1.5))282 self.assertVector(p[2].velocity, (3, -2, 0))283 self.assertVector(p[3].position, (1, 2, 1))284 self.assertVector(p[3].velocity, (0, 1, 0))285 def test_Bounce_controller_callback(self):286 from lepton import controller287 group = self._make_group()288 callback_args = []289 def dummy_callback(*args):290 self.assertEqual(len(args), 5)291 callback_args.append(args)292 bounce = controller.Bounce(DummyPlaneDomain(), callback=dummy_callback)293 bounce(0, group)294 p = list(group)295 self.assertEqual(len(callback_args), len(group) - 1)296 for particle, (cbparticle, cbgroup, cbcontroller, cbpoint, cbnormal) in zip(297 p, callback_args):298 # TODO Add particle-particle and vector-vector comparison ops299 self.assertVector(cbparticle.position, particle.position)300 self.failUnless(cbgroup is group, cbgroup)301 self.failUnless(cbcontroller is bounce, cbcontroller)302 self.assertEqual(cbpoint[1], 0)303class MagnetControllerTest(ControllerTestBase):304 def _make_group(self):305 from lepton import Particle, ParticleGroup306 g = ParticleGroup()307 g.new(Particle(position=(0, 1.0, 0), velocity=(0, 0, 0))),308 g.new(Particle(position=(0, 0, 1.0), velocity=(0, 0, 0))),309 g.update(0)310 p = list(g)311 p[0].position = (10.0, 0, 0)312 p[1].position = (0, 0.0, 10.0)313 return g314 315 def test_Magnet_controller_defaults(self):316 # Test one attract iteration 317 # for direction and magnitude of dv.318 from lepton import controller, domain319 from lepton.domain import Sphere320 sphere = Sphere((0, 0, 0), 5, 0)321 group = self._make_group()322 attract = controller.Magnet(sphere, charge=100)323 self.failUnless(attract.domain is sphere)324 self.assertEqual(attract.charge, 100)325 self.assertEqual(attract.exponent, 2)326 self.failUnless(attract.epsilon > 0)327 attract(1.0, group)328 p = list(group)329 self.assertVector(p[0].position, (10.0, 0.0, 0.0))330 self.assertVector(p[1].position, (0, 0.0, 10.0))331 self.assertVector(p[0].velocity, (-4.0, 0.0, 0.0), tolerance=0.0001)332 self.assertVector(p[1].velocity, (0, 0.0, -4.0), tolerance=0.0001)333if __name__=='__main__':...

Full Screen

Full Screen

graph_layout.py

Source:graph_layout.py Github

copy

Full Screen

...58 dbc.Col(weapon_rows),59 ], className='mb-2',)60 def _tab_output(self, name, points, average, std):61 return [62 dbc.Col(self._make_group(self._output_pill('Name', name))),63 dbc.Col(self._make_group(self._output_pill('Pts', points)), width=2),64 dbc.Col(self._make_group(self._output_pill('Avg', average)), width=2),65 dbc.Col(self._make_group(self._output_pill('Std', std)), width=2),66 ]67 def _weapon_output(self, strength, ap, bs, number, damage, shotmod, hitmod, woundmod, savemod, fnpmod, damagemod):68 mods = []69 if shotmod:70 mods.append(dbc.Row(self._make_group(self._output_pill('Shot Modifiers', ', '.join(shotmod)))))71 if hitmod:72 mods.append(dbc.Row(self._make_group(self._output_pill('Hit Modifiers', ', '.join(hitmod)))))73 if woundmod:74 mods.append(dbc.Row(self._make_group(self._output_pill('Wound Modifiers', ', '.join(woundmod)))))75 if savemod:76 mods.append(dbc.Row(self._make_group(self._output_pill('Save Modifiers', ', '.join(savemod)))))77 if fnpmod:78 mods.append(dbc.Row(self._make_group(self._output_pill('FNP Modifiers', ', '.join(fnpmod)))))79 if damagemod:80 mods.append(dbc.Row(self._make_group(self._output_pill('Damage Modifiers', ', '.join(damagemod)))))81 weapon_group = self._make_group(82 [83 *self._output_pill('S', strength),84 *self._output_pill('AP', f'-{ap}'),85 *self._output_pill('BS', f'{bs}+'),86 *self._output_pill('#', number),87 *self._output_pill('D', damage),88 ],89 )90 return dbc.Row(dbc.Col([weapon_group, dbc.Col(mods, className='mb-2')]))91 def _target_output(self, name, points, toughness, save, invuln, fnp, wounds, avg, std):92 return dbc.Row([93 dbc.Col(self._make_group(94 dbc.Input(type="text", value=name, disabled=True),95 ), width=3),96 dbc.Col(self._make_group(97 [98 *self._output_pill('PTS', points),99 *self._output_pill('T', toughness),100 *self._output_pill('SV', f'{save}+'),101 *self._output_pill('INV', f'{invuln}++'),102 *self._output_pill('FNP', f'{fnp}+++'),103 *self._output_pill('W', wounds),104 *self._output_pill('Mean', avg),105 *self._output_pill('σ', std),106 ]107 ), className='mb-2'),108 ], className='mb-2',)109 def _make_group(self, content):110 return dbc.InputGroup(content, size="sm")111 def _output_pill(self, name, value):112 return [113 dbc.InputGroupAddon(name, addon_type="prepend"),114 dbc.Input(type="text", value=value, disabled=True),115 ]116 def static_layout(self):117 content = dcc.Graph(118 id='static_damage_graph',119 style={'height':'80vh'},120 figure=self.figure_template(),121 config={122 'scrollZoom': False,123 'toImageButtonOptions': {...

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