Best Python code snippet using tox_python
self_driving.py
Source: self_driving.py
...23 -1, # my_car.steering_torque24 0, # my_car.score25 0, # my_car.crash_energy26 ),27 mapcat(lambda _: (28 -1, # other_car.position_angle29 0, # other_car.position_length30 -1, # other_car.angle31 -1, # other_car.velocity_angle32 0, # other_car.velocity_length33 -1, # other_car.steering_angle34 0, # other_car.score35 0, # other_car.crash_energy36 ), range(7)),37 mapcat(lambda _: (38 -1, # obstacle.position_angle39 0 # obstacle.position_length40 ), range(OBSTACLE_COUNT)),41 mapcat(lambda _: (42 -1, # star.position_angle43 0 # star.position_length44 ), range(STAR_COUNT)),45 )), dtype=np.float32),46 np.array(tuple(concat(47 (48 1, # my_car.position.x49 1, # my_car.position.y50 1, # my_car.angle51 1, # my_car.velocity_angle52 1, # my_car.velocity_length53 1, # my_car.steering_angle54 1, # my_car.steering_torque55 1, # my_car.score56 1, # my_car.crash_energy57 ),58 mapcat(lambda _: (59 1, # other_car.position_angle60 1, # other_car.position_length61 1, # other_car.angle62 1, # other_car.velocity_angle63 1, # other_car.velocity_length64 1, # other_car.steering_angle65 1, # other_car.score66 1, # other_car.crash_energy67 ), range(7)),68 mapcat(lambda _: (69 1, # obstacle.position_angle70 1 # obstacle.position_length71 ), range(OBSTACLE_COUNT)),72 mapcat(lambda _: (73 1, # star.position_angle74 1 # star.position_length75 ), range(STAR_COUNT)),76 )), dtype=np.float32),77 dtype=np.float3278 )79 self.screen = None80 self.reset()81 @classmethod82 def _create_observation(cls, game):83 def get_values(observation):84 return concat(85 flatten(observation['my_car'].values()), # Vec2dã«ã¯xã¨yã®2è¦ç´ ãããã®ã§ãflattenãã¦ããã¾ãã86 mapcat(methodcaller('values'), sorted(observation['other_cars'], key=itemgetter('position_length'))), # è·é¢ãè¿ãé ã«ã½ã¼ããã¾ããåå¾ãåããã»ããè¯ãï¼87 mapcat(methodcaller('values'), sorted(observation['obstacles' ], key=itemgetter('position_length'))), # noqa: E20288 mapcat(methodcaller('values'), sorted(observation['stars' ], key=itemgetter('position_length'))) # noqa: E20289 )90 observation = (91 np.array(tuple(get_values(game.create_observation(game.cars[0]))), np.float32) / # noqa: W50492 np.array(tuple(concat(93 (94 1000, # my_car.position.x95 1000, # my_car.position.y96 np.pi, # my_car.angle97 np.pi, # my_car.velocity_angle98 MAX_SPEED / FPS, # my_car.velocity_length99 np.pi, # my_car.steering_angle100 10, # my_car.steering_torque101 30, # my_car.score102 10 * FPS, # my_car.crash_energy103 ),104 mapcat(lambda _: (105 np.pi, # other_car.position_angle106 1000, # other_car.position_length107 np.pi, # other_car.angle108 np.pi, # other_car.velocity_angle109 MAX_SPEED / FPS * 2, # other_car.velocity_length110 np.pi, # other_car.steering_angle111 30, # other_car.score112 10 * FPS, # other_car.crash_energy113 ), range(7)),114 mapcat(lambda _: (115 np.pi, # obstacle.position_angle116 1000 # obstacle.position_length117 ), range(OBSTACLE_COUNT)),118 mapcat(lambda _: (119 np.pi, # star.position_angle120 1000 # star.position_length121 ), range(STAR_COUNT)),122 )), dtype=np.float32)123 )124 observation[observation < -1] = -1125 observation[observation > 1] = 1 # noqa: E222126 return observation127 def reset(self):128 self.game = Game((self,), self._seed)129 return self._create_observation(self.game)130 @classmethod131 def _calc_car_and_star_distance(cls, game, car):132 return min(map(lambda star: (star.position - car.position).length, game.stars))...
self_driving_2.py
Source: self_driving_2.py
...23 -1, # my_car.steering_torque24 0, # my_car.score25 0, # my_car.crash_energy26 ),27 mapcat(lambda _: (28 -1, # other_car.position_angle29 0, # other_car.position_length30 -1, # other_car.angle31 -1, # other_car.velocity_angle32 0, # other_car.velocity_length33 -1, # other_car.steering_angle34 0, # other_car.score35 0, # other_car.crash_energy36 ), range(7)),37 mapcat(lambda _: (38 -1, # obstacle.position_angle39 0 # obstacle.position_length40 ), range(OBSTACLE_COUNT)),41 mapcat(lambda _: (42 -1, # star.position_angle43 0 # star.position_length44 ), range(STAR_COUNT)),45 )), dtype=np.float32),46 np.array(tuple(concat(47 (48 1, # my_car.position.x49 1, # my_car.position.y50 1, # my_car.angle51 1, # my_car.velocity_angle52 1, # my_car.velocity_length53 1, # my_car.steering_angle54 1, # my_car.steering_torque55 1, # my_car.score56 1, # my_car.crash_energy57 ),58 mapcat(lambda _: (59 1, # other_car.position_angle60 1, # other_car.position_length61 1, # other_car.angle62 1, # other_car.velocity_angle63 1, # other_car.velocity_length64 1, # other_car.steering_angle65 1, # other_car.score66 1, # other_car.crash_energy67 ), range(7)),68 mapcat(lambda _: (69 1, # obstacle.position_angle70 1 # obstacle.position_length71 ), range(OBSTACLE_COUNT)),72 mapcat(lambda _: (73 1, # star.position_angle74 1 # star.position_length75 ), range(STAR_COUNT)),76 )), dtype=np.float32),77 dtype=np.float3278 )79 self.screen = None80 self.reset()81 @classmethod82 def _create_observation(cls, game):83 def get_values(observation):84 return flatten(concat(85 observation['my_car'].values(),86 mapcat(methodcaller('values'), sorted(observation['other_cars'], key=itemgetter('position_length'))), # è·é¢ãè¿ãé ã«ã½ã¼ããã¾ããåå¾ãåããã»ããè¯ãï¼87 mapcat(methodcaller('values'), sorted(observation['obstacles' ], key=itemgetter('position_length'))), # noqa: E20288 mapcat(methodcaller('values'), sorted(observation['stars' ], key=itemgetter('position_length'))) # noqa: E20289 ))90 observation = (91 np.array(tuple(get_values(game.create_observation(game.cars[0]))), np.float32) / # noqa: W50492 np.array(tuple(concat(93 (94 1000, # my_car.position.x95 1000, # my_car.position.y96 np.pi, # my_car.angle97 np.pi, # my_car.velocity_angle98 MAX_SPEED / FPS, # my_car.velocity_length99 np.pi, # my_car.steering_angle100 10, # my_car.steering_torque101 30, # my_car.score102 10 * FPS, # my_car.crash_energy103 ),104 mapcat(lambda _: (105 np.pi, # other_car.position_angle106 1000, # other_car.position_length107 np.pi, # other_car.angle108 np.pi, # other_car.velocity_angle109 MAX_SPEED / FPS * 2, # other_car.velocity_length110 np.pi, # other_car.steering_angle111 30, # other_car.score112 10 * FPS, # other_car.crash_energy113 ), range(7)),114 mapcat(lambda _: (115 np.pi, # obstacle.position_angle116 1000 # obstacle.position_length117 ), range(OBSTACLE_COUNT)),118 mapcat(lambda _: (119 np.pi, # star.position_angle120 1000 # star.position_length121 ), range(STAR_COUNT)),122 )), dtype=np.float32)123 )124 observation[observation < -1] = -1125 observation[observation > 1] = 1 # noqa: E222126 return observation127 def reset(self):128 self.game = Game((self,), self._seed)129 return self._create_observation(self.game)130 @classmethod131 def _calc_car_and_star_distance(cls, game, car):132 return min(map(lambda star: (star.position - car.position).length, game.stars))...
dependencies_visitors.py
Source: dependencies_visitors.py
...25 assert deep_level >= 0, deep_level26 return result27# Specific visitors28def visit_boolean_expression(node):29 return mapcat(visit_node, node['operands'])30def visit_comparaison(node):31 return mapcat(visit_node, (node['left_operand'], node['right_operand']))32def visit_dans(node):33 return visit_node(node['expression'])34def visit_float(node):35 return []36def visit_formula(node):37 formula_name = node['name']38 dependencies = pipe(39 visit_node(node['expression']),40 unique,41 list,42 )43 return (formula_name, dependencies)44def visit_function_call(node):45 return mapcat(visit_node, node['arguments'])46def visit_integer(node):47 return []48def visit_loop_expression(node):49 return mapcat(visit_node, iter_unlooped_nodes(50 loop_variables_nodes=node['loop_variables'],51 node=node['expression'],52 ))53def visit_pour_formula(node):54 return map(visit_node, iter_unlooped_nodes(55 loop_variables_nodes=node['loop_variables'],56 node=node['formula'],57 unloop_keys=['name'],58 ))59def visit_product_expression(node):60 return mapcat(visit_node, node['operands'])61def visit_regle(node):62 return mapcat(63 lambda node1: visit_node(node1) if node1['type'] == 'pour_formula' else [visit_node(node1)],64 node['formulas'],65 )66def visit_sum_expression(node):67 return mapcat(visit_node, node['operands'])68def visit_symbol(node):69 return [node['value']]70def visit_ternary_operator(node):71 return pipe([72 visit_node(node['value_if_true']),73 visit_node(node['condition']),74 visit_node(node['value_if_false']) if 'value_if_false' in node else None,75 ],76 filter(None),77 concat,78 )79def visit_unary(node):...
Check out the latest blogs from LambdaTest on this topic:
When most firms employed a waterfall development model, it was widely joked about in the industry that Google kept its products in beta forever. Google has been a pioneer in making the case for in-production testing. Traditionally, before a build could go live, a tester was responsible for testing all scenarios, both defined and extempore, in a testing environment. However, this concept is evolving on multiple fronts today. For example, the tester is no longer testing alone. Developers, designers, build engineers, other stakeholders, and end users, both inside and outside the product team, are testing the product and providing feedback.
As everyone knows, the mobile industry has taken over the world and is the fastest emerging industry in terms of technology and business. It is possible to do all the tasks using a mobile phone, for which earlier we had to use a computer. According to Statista, in 2021, smartphone vendors sold around 1.43 billion smartphones worldwide. The smartphone penetration rate has been continuously rising, reaching 78.05 percent in 2020. By 2025, it is expected that almost 87 percent of all mobile users in the United States will own a smartphone.
In general, software testers have a challenging job. Software testing is frequently the final significant activity undertaken prior to actually delivering a product. Since the terms “software” and “late” are nearly synonymous, it is the testers that frequently catch the ire of the whole business as they try to test the software at the end. It is the testers who are under pressure to finish faster and deem the product “release candidate” before they have had enough opportunity to be comfortable. To make matters worse, if bugs are discovered in the product after it has been released, everyone looks to the testers and says, “Why didn’t you spot those bugs?” The testers did not cause the bugs, but they must bear some of the guilt for the bugs that were disclosed.
The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
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!!