Best Python code snippet using tox_python
nodes.py
Source:nodes.py
...5 ptrn = re.search(r"<(.*?)>", str(node_str))6 return ptrn.group(1).split("'")[1]7class AST:8 @classmethod9 def parse_node(self, obj):10 pass11class Add:12 @classmethod13 def parse_node(self, obj):14 pass15class And:16 @classmethod17 def parse_node(self, obj):18 pass19class AnnAssign:20 @classmethod21 def parse_node(self, obj):22 AST_NODES[get_class_str(obj.target)].parse_node(obj.target)23 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)24 AST_NODES[get_class_str(obj.annotation)].parse_node(obj.annotation)25class Assert:26 @classmethod27 def parse_node(self, obj):28 AST_NODES[get_class_str(obj.test)].parse_node(obj.test)29 AST_NODES[get_class_str(obj.msg)].parse_node(obj.msg)30class Assign:31 @classmethod32 def parse_node(self, obj):33 for node in obj.targets:34 AST_NODES[get_class_str(node)].parse_node(node)35 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)36class AsyncFor:37 @classmethod38 def parse_node(self, obj):39 for node in obj.body:40 AST_NODES[get_class_str(node)].parse_node(node)41 for node in obj.orelse:42 AST_NODES[get_class_str(node)].parse_node(node)43 AST_NODES[get_class_str(obj.target)].parse_node(obj.target)44 AST_NODES[get_class_str(obj.iter)].parse_node(obj.iter)45class AsyncFunctionDef:46 @classmethod47 def parse_node(self, obj):48 AST_NODES[get_class_str(obj.args)].parse_node(obj.args)49 for node in obj.body:50 AST_NODES[get_class_str(node)].parse_node(node)51 for node in obj.decorator_list:52 AST_NODES[get_class_str(node)].parse_node(node)53 OBJECTS.append(obj.name)54class AsyncWith:55 @classmethod56 def parse_node(self, obj):57 for node in obj.body:58 AST_NODES[get_class_str(node)].parse_node(node)59 for node in obj.items:60 AST_NODES[get_class_str(node)].parse_node(node)61class Attribute:62 @classmethod63 def parse_node(self, obj):64 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)65 OBJECTS.append(obj.attr)66class AugAssign:67 @classmethod68 def parse_node(self, obj):69 AST_NODES[get_class_str(obj.target)].parse_node(obj.target)70 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)71class AugLoad:72 @classmethod73 def parse_node(self, obj):74 pass75class AugStore:76 @classmethod77 def parse_node(self, obj):78 pass79class Await:80 @classmethod81 def parse_node(self, obj):82 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)83class BinOp:84 @classmethod85 def parse_node(self, obj):86 AST_NODES[get_class_str(obj.left)].parse_node(obj.left)87 AST_NODES[get_class_str(obj.right)].parse_node(obj.right)88class BitAnd:89 @classmethod90 def parse_node(self, obj):91 pass92class BitOr:93 @classmethod94 def parse_node(self, obj):95 pass96class BitXor:97 @classmethod98 def parse_node(self, obj):99 pass100class BoolOp:101 @classmethod102 def parse_node(self, obj):103 for node in obj.values:104 AST_NODES[get_class_str(node)].parse_node(node)105class Break:106 @classmethod107 def parse_node(self, obj):108 pass109class Bytes:110 @classmethod111 def parse_node(self, obj):112 pass113class Call:114 @classmethod115 def parse_node(self, obj):116 for node in obj.args:117 AST_NODES[get_class_str(node)].parse_node(node)118 for node in obj.keywords:119 AST_NODES[get_class_str(node)].parse_node(node)120 AST_NODES[get_class_str(obj.func)].parse_node(obj.func)121class ClassDef:122 @classmethod123 def parse_node(self, obj):124 OBJECTS.append(obj.name)125 for node in obj.bases:126 AST_NODES[get_class_str(node)].parse_node(node)127 for node in obj.keywords:128 AST_NODES[get_class_str(node)].parse_node(node)129 for node in obj.body:130 AST_NODES[get_class_str(node)].parse_node(node)131 for node in obj.decorator_list:132 AST_NODES[get_class_str(node)].parse_node(node)133 AST_NODES[get_class_str(obj.starargs)].parse_node(obj.starargs)134 AST_NODES[get_class_str(obj.kwargs)].parse_node(obj.kwargs)135class Compare:136 @classmethod137 def parse_node(self, obj):138 for node in obj.comparators:139 AST_NODES[get_class_str(node)].parse_node(node)140 AST_NODES[get_class_str(node)].parse_node(node)141class Constant:142 @classmethod143 def parse_node(self, obj):144 OBJECTS.append(obj.value)145class Continue:146 @classmethod147 def parse_node(self, obj):148 pass149class Del:150 @classmethod151 def parse_node(self, obj):152 pass153class Delete:154 @classmethod155 def parse_node(self, obj):156 for node in obj.targets:157 AST_NODES[get_class_str(node)].parse_node(node)158class Dict:159 @classmethod160 def parse_node(self, obj):161 for node in obj.keys:162 AST_NODES[get_class_str(node)].parse_node(obj.node)163 for node in obj.values:164 AST_NODES[get_class_str(node)].parse_node(obj.node)165class DictComp:166 @classmethod167 def parse_node(self, obj):168 for node in obj.generators:169 AST_NODES[get_class_str(node)].parse_node(node)170 AST_NODES[get_class_str(obj.key)].parse_node(obj.key)171 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)172class Div:173 @classmethod174 def parse_node(self, obj):175 pass176class Ellipsis:177 @classmethod178 def parse_node(self, obj):179 pass180class Eq:181 @classmethod182 def parse_node(self, obj):183 pass184class ExceptHandler:185 @classmethod186 def parse_node(self, obj):187 for node in obj.body:188 AST_NODES[get_class_str(node)].parse_node(node)189 AST_NODES[get_class_str(obj.type)].parse_node(obj.type)190 OBJECTS.append(obj.name)191class Expr:192 @classmethod193 def parse_node(self, obj):194 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)195class Expression:196 @classmethod197 def parse_node(self, obj):198 AST_NODES[get_class_str(obj.body)].parse_node(obj.body)199class ExtSlice:200 @classmethod201 def parse_node(self, obj):202 pass203class FloorDiv:204 @classmethod205 def parse_node(self, obj):206 pass207class For:208 @classmethod209 def parse_node(self, obj):210 for node in obj.body:211 AST_NODES[get_class_str(node)].parse_node(node)212 for node in obj.orelse:213 AST_NODES[get_class_str(node)].parse_node(node)214 AST_NODES[get_class_str(obj.target)].parse_node(obj.target)215 AST_NODES[get_class_str(obj.iter)].parse_node(obj.iter)216class FormattedValue:217 @classmethod218 def parse_node(self, obj):219 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)220class FunctionDef:221 @classmethod222 def parse_node(self, obj):223 AST_NODES[get_class_str(obj.args)].parse_node(obj.args)224 for node in obj.body:225 AST_NODES[get_class_str(node)].parse_node(node)226 for node in obj.decorator_list:227 AST_NODES[get_class_str(node)].parse_node(node)228 OBJECTS.append(obj.name)229class FunctionType:230 @classmethod231 def parse_node(self, obj):232 pass233class GeneratorExp:234 @classmethod235 def parse_node(self, obj):236 for node in obj.generators:237 AST_NODES[get_class_str(node)].parse_node(node)238 AST_NODES[get_class_str(obj.elt)].parse_node(obj.elt)239class Global:240 @classmethod241 def parse_node(self, obj):242 for name in obj.names:243 OBJECTS.append(name)244class Gt:245 @classmethod246 def parse_node(self, obj):247 pass248class GtE:249 @classmethod250 def parse_node(self, obj):251 pass252class If:253 @classmethod254 def parse_node(self, obj):255 for node in obj.body:256 AST_NODES[get_class_str(node)].parse_node(node)257 for node in obj.orelse:258 AST_NODES[get_class_str(node)].parse_node(node)259 AST_NODES[get_class_str(obj.test)].parse_node(obj.test)260class IfExp:261 @classmethod262 def parse_node(self, obj):263 AST_NODES[get_class_str(obj.test)].parse_node(obj.test)264 AST_NODES[get_class_str(obj.body)].parse_node(obj.body)265 AST_NODES[get_class_str(obj.orelse)].parse_node(obj.orelse)266class Import:267 @classmethod268 def parse_node(self, obj):269 pass270class ImportFrom:271 @classmethod272 def parse_node(self, obj):273 pass274class In:275 @classmethod276 def parse_node(self, obj):277 pass278class Index:279 @classmethod280 def parse_node(self, obj):281 pass282class Interactive:283 @classmethod284 def parse_node(self, obj):285 pass286class Invert:287 @classmethod288 def parse_node(self, obj):289 AST_NODES[get_class_str(obj.operand)].parse_node(obj.operand)290class Is:291 @classmethod292 def parse_node(self, obj):293 pass294class IsNot:295 @classmethod296 def parse_node(self, obj):297 pass298class JoinedStr:299 @classmethod300 def parse_node(self, obj):301 for node in obj.values:302 AST_NODES[get_class_str(node)].parse_node(node)303class LShift:304 @classmethod305 def parse_node(self, obj):306 pass307class Lambda:308 @classmethod309 def parse_node(self, obj):310 for node in obj.body:311 AST_NODES[get_class_str(node)].parse_node(node)312 AST_NODES[get_class_str(obj.args)].parse_node(obj.args)313class List:314 @classmethod315 def parse_node(self, obj):316 for node in obj.elts:317 AST_NODES[get_class_str(node)].parse_node(obj.node)318class ListComp:319 @classmethod320 def parse_node(self, obj):321 for node in obj.generators:322 AST_NODES[get_class_str(node)].parse_node(node)323 AST_NODES[get_class_str(obj.elt)].parse_node(obj.elt)324class Load:325 @classmethod326 def parse_node(self, obj):327 pass328class Lt:329 @classmethod330 def parse_node(self, obj):331 pass332class LtE:333 @classmethod334 def parse_node(self, obj):335 pass336class MatMult:337 @classmethod338 def parse_node(self, obj):339 pass340class Mod:341 @classmethod342 def parse_node(self, obj):343 pass344class Module:345 @classmethod346 def parse_node(self, obj):347 for node in obj.body:348 AST_NODES[get_class_str(node)].parse_node(node)349class Mult:350 @classmethod351 def parse_node(self, obj):352 pass353class Name:354 @classmethod355 def parse_node(self, obj):356 OBJECTS.append(obj.id)357class NameConstant:358 @classmethod359 def parse_node(self, obj):360 pass361class NamedExpr:362 @classmethod363 def parse_node(self, obj):364 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)365 AST_NODES[get_class_str(obj.target)].parse_node(obj.target)366class NodeTransformer:367 @classmethod368 def parse_node(self, obj):369 pass370class NodeVisitor:371 @classmethod372 def parse_node(self, obj):373 pass374class Nonlocal:375 @classmethod376 def parse_node(self, obj):377 for name in obj.names:378 OBJECTS.append(name)379class Not:380 @classmethod381 def parse_node(self, obj):382 pass383class NotEq:384 @classmethod385 def parse_node(self, obj):386 pass387class NotIn:388 @classmethod389 def parse_node(self, obj):390 pass391class Num:392 @classmethod393 def parse_node(self, obj):394 pass395class Or:396 @classmethod397 def parse_node(self, obj):398 pass399class Param:400 @classmethod401 def parse_node(self, obj):402 pass403class Pass:404 @classmethod405 def parse_node(self, obj):406 pass407class Pow:408 @classmethod409 def parse_node(self, obj):410 pass411class RShift:412 @classmethod413 def parse_node(self, obj):414 pass415class Raise:416 @classmethod417 def parse_node(self, obj):418 AST_NODES[get_class_str(obj.exec)].parse_node(obj.exec)419 AST_NODES[get_class_str(obj.cause)].parse_node(obj.cause)420class Return:421 @classmethod422 def parse_node(self, obj):423 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)424class Set:425 @classmethod426 def parse_node(self, obj):427 for node in obj.elts:428 AST_NODES[get_class_str(node)].parse_node(obj.node)429class SetComp:430 @classmethod431 def parse_node(self, obj):432 for node in obj.generators:433 AST_NODES[get_class_str(node)].parse_node(node)434 AST_NODES[get_class_str(obj.elt)].parse_node(obj.elt)435class Slice:436 @classmethod437 def parse_node(self, obj):438 AST_NODES[get_class_str(obj.lower)].parse_node(obj.lower)439 AST_NODES[get_class_str(obj.upper)].parse_node(obj.upper)440 AST_NODES[get_class_str(obj.step)].parse_node(obj.step)441class Starred:442 @classmethod443 def parse_node(self, obj):444 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)445class Store:446 @classmethod447 def parse_node(self, obj):448 pass449class Str:450 @classmethod451 def parse_node(self, obj):452 pass453class Sub:454 @classmethod455 def parse_node(self, obj):456 pass457class Subscript:458 @classmethod459 def parse_node(self, obj):460 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)461 AST_NODES[get_class_str(obj.slice)].parse_node(obj.slice)462class Suite:463 @classmethod464 def parse_node(self, obj):465 pass466class Try:467 @classmethod468 def parse_node(self, obj):469 for node in obj.body:470 AST_NODES[get_class_str(node)].parse_node(node)471 for node in obj.orelse:472 AST_NODES[get_class_str(node)].parse_node(node)473 for node in obj.handlers:474 AST_NODES[get_class_str(node)].parse_node(node)475 for node in obj.finalbody:476 AST_NODES[get_class_str(node)].parse_node(node)477class Tuple:478 @classmethod479 def parse_node(self, obj):480 for node in obj.elts:481 AST_NODES[get_class_str(node)].parse_node(obj.node)482class TypeIgnore:483 @classmethod484 def parse_node(self, obj):485 pass486class UAdd:487 @classmethod488 def parse_node(self, obj):489 pass490class USub:491 @classmethod492 def parse_node(self, obj):493 pass494class UnaryOp:495 @classmethod496 def parse_node(self, obj):497 AST_NODES[get_class_str(obj.operand)].parse_node(obj.operand)498class While:499 @classmethod500 def parse_node(self, obj):501 for node in obj.body:502 AST_NODES[get_class_str(node)].parse_node(node)503 for node in obj.orelse:504 AST_NODES[get_class_str(node)].parse_node(node)505 AST_NODES[get_class_str(obj.test)].parse_node(obj.test)506class With:507 @classmethod508 def parse_node(self, obj):509 for node in obj.body:510 AST_NODES[get_class_str(node)].parse_node(node)511 for node in obj.items:512 AST_NODES[get_class_str(node)].parse_node(node)513class Yield:514 @classmethod515 def parse_node(self, obj):516 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)517class YieldFrom:518 @classmethod519 def parse_node(self, obj):520 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)521class _ABC:522 @classmethod523 def parse_node(self, obj):524 pass525class alias:526 @classmethod527 def parse_node(self, obj):528 OBJECTS.append(obj.name)529 OBJECTS.append(obj.asname)530class arg:531 @classmethod532 def parse_node(self, obj):533 OBJECTS.append(obj.arg)534 AST_NODES[get_class_str(obj.annotation)].parse_node(obj.annotation)535class arguments:536 @classmethod537 def parse_node(self, obj):538 for node in obj.posonlyargs:539 AST_NODES[get_class_str(node)].parse_node(node)540 for node in obj.kwonlyargs:541 AST_NODES[get_class_str(node)].parse_node(node)542 for node in obj.args:543 AST_NODES[get_class_str(node)].parse_node(node)544 AST_NODES[get_class_str(obj.vararg)].parse_node(obj.vararg)545 AST_NODES[get_class_str(node.kwarg)].parse_node(node.kwarg)546class boolop:547 @classmethod548 def parse_node(self, obj):549 pass550class cmpop:551 @classmethod552 def parse_node(self, obj):553 pass554class comprehension:555 @classmethod556 def parse_node(self, obj):557 for node in obj.ifs:558 AST_NODES[get_class_str(node)].parse_node(node)559 AST_NODES[get_class_str(obj.target)].parse_node(obj.target)560 AST_NODES[get_class_str(obj.iter)].parse_node(obj.iter)561class excepthandler:562 @classmethod563 def parse_node(self, obj):564 pass565class expr:566 @classmethod567 def parse_node(self, obj):568 pass569class expr_context:570 @classmethod571 def parse_node(self, obj):572 pass573class keyword:574 @classmethod575 def parse_node(self, obj):576 OBJECTS.append(obj.arg)577 AST_NODES[get_class_str(obj.value)].parse_node(obj.value)578class mod:579 @classmethod580 def parse_node(self, obj):581 pass582class operator:583 @classmethod584 def parse_node(self, obj):585 pass586class slice:587 @classmethod588 def parse_node(self, obj):589 pass590class stmt:591 @classmethod592 def parse_node(self, obj):593 pass594class type_ignore:595 @classmethod596 def parse_node(self, obj):597 pass598class unaryop:599 @classmethod600 def parse_node(self, obj):601 pass602class withitem:603 @classmethod604 def parse_node(self, obj):605 AST_NODES[get_class_str(obj.context_expr)].parse_node(obj.context_expr)606 AST_NODES[get_class_str(obj.optional_vars)].parse_node(obj.optional_vars)607AST_NODES = {608 "_ast.AST": AST,609 "_ast.Add": Add,610 "_ast.And": And,611 "_ast.AnnAssign": AnnAssign,612 "_ast.Assert": Assert,613 "_ast.Assign": Assign,614 "_ast.AsyncFor": AsyncFor,615 "_ast.AsyncFunctionDef": AsyncFunctionDef,616 "_ast.AsyncWith": AsyncWith,617 "_ast.Attribute": Attribute,618 "_ast.AugAssign": AugAssign,619 "_ast.AugLoad": AugLoad,620 "_ast.AugStore": AugStore,...
parser.py
Source:parser.py
1from typing import List, Tuple2from icg import IntermidateCodeGenerator3from scanner import Scanner, Token4from utils import (5 write_parse_tree_to_file,6 write_syntax_errors_to_file,7 print_parser_log,8 reverse_format_non_terminal,9)10from parse_diagram import (11 get_transation_diagrams,12 DiagramNode,13 IllegalToken,14 MissingToken,15)16from anytree import Node17class Parser:18 def __init__(self, scanner: Scanner, icg: IntermidateCodeGenerator):19 self.scanner = scanner20 self.transation_diagrams: dict[str, DiagramNode] = get_transation_diagrams()21 self.past_node_stack: List[Tuple[DiagramNode, DiagramNode]] = []22 self.parse_tree_root = Node("Program")23 self.current_token: Token = None24 self.current_node: DiagramNode = self.transation_diagrams["program"]25 self.syntax_errors: List = []26 self.parse_node: Node = self.parse_tree_root27 self.icg = icg28 self.get_next_token()29 def get_next_token(self):30 self.current_token = self.scanner.get_next_token()31 def save_to_file(self):32 write_syntax_errors_to_file(self.syntax_errors)33 write_parse_tree_to_file(self.parse_tree_root)34 def log(self):35 print_parser_log(self.current_node, self.current_token, self.past_node_stack)36 def add_syntax_error(self, message):37 self.syntax_errors.append(message)38 def start_parsing(self):39 found_terminal = False40 # TODO refactore this function41 while True:42 try:43 # walk through parse diagram44 (45 next_edge,46 found_terminal,47 return_node_name,48 ) = self.current_node.next_diagram_tree_node(49 self.current_token,50 reverse_format_non_terminal(self.parse_node.name),51 )52 if next_edge != None:53 self.current_node = next_edge.next_node54 next_parse_node_name = next_edge.parse_tree_name55 action_symbol = next_edge.action_symbols56 else:57 self.current_node = next_parse_node_name = action_symbol = None58 except IllegalToken:59 self.add_syntax_error(60 f"#{self.scanner.line_number} : syntax error, {self.current_token.ilegal_token_message}"61 )62 if self.current_token.lexeme == "$":63 # remove orphan nodes64 self.parse_node.parent.children = [65 i66 for i in self.parse_node.parent.children67 if i != self.parse_node68 ]69 break70 # get next token after illegal token happens71 self.get_next_token()72 continue73 except MissingToken as e:74 self.syntax_errors.append(75 f"#{self.scanner.line_number} : syntax error, missing {e.next_edge.parse_tree_name}"76 )77 # walk forward in diagram78 self.current_node = e.next_edge.next_node79 continue80 # call code gen when reach action symbol81 if action_symbol != None:82 for action in action_symbol:83 self.icg.code_gen(action, self.current_token)84 # can walk in diagram tree85 if next_parse_node_name:86 self.parse_node = Node(87 next_parse_node_name if not found_terminal else self.current_token,88 self.parse_node,89 )90 # fall back to last diagram91 else:92 self.parse_node = self.parse_node.parent93 if not self.current_node:94 if not self.parse_node:95 break96 self.parse_node = self.parse_node.parent97 # go deep to another diagram98 if return_node_name:99 if len(self.current_node.next_edges) != 0:100 self.past_node_stack.append((self.current_node, self.parse_node))101 self.current_node = self.transation_diagrams[return_node_name]102 # terminal is matched103 if found_terminal:104 self.parse_node = self.parse_node.parent105 self.get_next_token()106 found_terminal = False107 # end of parse108 if self.current_token.lexeme == "$" and len(self.past_node_stack) == 0:109 break110 # move back current_node pointer to last return node111 if not self.current_node:112 self.current_node, self.parse_node = self.past_node_stack.pop(113 len(self.past_node_stack) - 1114 )...
test_code.py
Source:test_code.py
1# SPDX-License-Identifier: MIT2# Copyright (c) 2021 Akumatic3from code import *4def test_explode(a, b):5 tmp = parse_node(a)6 tmp.explode()7 return str(tmp) == str(parse_node(b))8def test():9 vals = read_file("test_input_2.txt")10 assert str(parse_node([1,2])) == "[1,2]"11 assert str(add(parse_node([1,2]), parse_node([[3,4],5]))) == "[[1,2],[[3,4],5]]"12 assert test_explode([[[[[9,8],1],2],3],4], [[[[0,9],2],3],4])13 assert test_explode([7,[6,[5,[4,[3,2]]]]], [7,[6,[5,[7,0]]]])14 assert test_explode([[6,[5,[4,[3,2]]]],1], [[6,[5,[7,0]]],3])15 assert test_explode([[3,[2,[1,[7,3]]]],[6,[5,[4,[3,2]]]]], [[3,[2,[8,0]]],[9,[5,[4,[3,2]]]]])16 assert test_explode([[3,[2,[8,0]]],[9,[5,[4,[3,2]]]]], [[3,[2,[8,0]]],[9,[5,[7,0]]]])17 print("Passed explosion test")18 assert str(add(parse_node([[[[4,3],4],4],[7,[[8,4],9]]]), parse_node([1,1]))) == str(parse_node([[[[0,7],4],[[7,8],[6,0]]],[8,1]]))19 print("Passed reduction test")20 assert str(sum_nodes([[1,1], [2,2], [3,3], [4,4]])) == "[[[[1,1],[2,2]],[3,3]],[4,4]]"21 assert str(sum_nodes([[1,1], [2,2], [3,3], [4,4], [5,5]])) == "[[[[3,0],[5,3]],[4,4]],[5,5]]"22 assert str(sum_nodes([[1,1], [2,2], [3,3], [4,4], [5,5], [6,6]])) == "[[[[5,0],[7,4]],[5,5]],[6,6]]"23 assert str(sum_nodes(read_file("test_input_1.txt"))) == "[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]"24 assert str(sum_nodes(vals)) == "[[[[6,6],[7,6]],[[7,7],[7,0]]],[[[7,7],[7,7]],[[7,8],[9,9]]]]"25 print("Passed summing nodes test")26 assert get_magnitude(parse_node([[1,2],[[3,4],5]])) == 143.27 assert get_magnitude(parse_node([[[[0,7],4],[[7,8],[6,0]]],[8,1]])) == 1384.28 assert get_magnitude(parse_node([[[[1,1],[2,2]],[3,3]],[4,4]])) == 445.29 assert get_magnitude(parse_node([[[[3,0],[5,3]],[4,4]],[5,5]])) == 791.30 assert get_magnitude(parse_node([[[[5,0],[7,4]],[5,5]],[6,6]])) == 1137.31 assert get_magnitude(parse_node([[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]])) == 3488.32 assert part1(vals) == 414033 print("Passed magnitude test")34 assert part2(vals) == 399335 print("Passed Part 2")36if __name__ == "__main__":...
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!!