def test_function_call_with_comments(self): function_call = ' # pre\n' \ ' min(1,2) # in\n' \ ' # post\n\n' model = ModelParser.parse_block(function_call) model_printer = ASTNestMLPrinter() self.assertEqual(function_call, model_printer.print_node(model))
def test_function_call_with_comments(self): function_call = '\n/* pre */\n' \ 'min(1,2) # in\n' \ '/* post */\n\n' model = ModelParser.parse_stmt(function_call) model_printer = ASTNestMLPrinter() self.assertEqual(function_call, model_printer.print_node(model))
def test_declaration_with_comments(self): declaration = ' # pre\n' \ ' test mV = 10mV # in\n' \ ' # post\n\n' model = ModelParser.parse_block(declaration) model_printer = ASTNestMLPrinter() self.assertEqual(declaration, model_printer.print_node(model))
def test_function_call_with_comments(self): function_call = '\n/* pre */\n' \ 'min(1,2) # in\n' \ '/* post */\n\n' model = ModelParser.parse_stmt(function_call) model_printer = ASTNestMLPrinter() self.assertEqual(function_call, model_printer.print_node(model))
def test_equations_block_with_comments(self): block = '# pre\n' \ 'equations: # in\n' \ 'end\n' \ '# post\n\n' model = ModelParser.parse_equations_block(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_assignment_with_comments(self): assignment = ' # pre\n' \ ' a = b # in\n' \ ' # post\n' \ '\n' model = ModelParser.parse_block(assignment) model_printer = ASTNestMLPrinter() self.assertEqual(assignment, model_printer.print_node(model))
def test_neuron_with_comments(self): neuron = '\n/*pre*/\n' \ 'neuron test: # in\n' \ 'end\n' \ '/*post*/\n\n' model = ModelParser.parse_neuron(neuron) model_printer = ASTNestMLPrinter() self.assertEqual(neuron, model_printer.print_node(model))
def test_function_without_comments(self): t_function = 'function test(Tau_1 ms) real:\n' \ ' exact_integration_adjustment real = ((1 / Tau_2) - (1 / Tau_1)) * ms\n' \ ' return normalisation_factor\n' \ 'end\n' model = ModelParser.parse_function(t_function) model_printer = ASTNestMLPrinter() self.assertEqual(t_function, model_printer.print_node(model))
def test_function_without_comments(self): t_function = 'function test(Tau_1 ms) real:\n' \ ' exact_integration_adjustment real = ((1 / Tau_2) - (1 / Tau_1)) * ms\n' \ ' return normalisation_factor\n' \ 'end\n' model = ModelParser.parse_function(t_function) model_printer = ASTNestMLPrinter() self.assertEqual(t_function, model_printer.print_node(model))
def test_while_stmt_with_comments(self): stmt = '\n/*pre*/\n' \ 'while true: # in \n' \ 'end\n' \ '/*post*/\n\n' model = ModelParser.parse_while_stmt(stmt) model_printer = ASTNestMLPrinter() self.assertEqual(stmt, model_printer.print_node(model))
def test_while_stmt_with_comments(self): stmt = '\n/*pre*/\n' \ 'while true: # in \n' \ 'end\n' \ '/*post*/\n\n' model = ModelParser.parse_while_stmt(stmt) model_printer = ASTNestMLPrinter() self.assertEqual(stmt, model_printer.print_node(model))
def test_for_stmt_with_comments(self): stmt = '\n/*pre*/\n' \ 'for i in 10 - 3.14...10 + 3.14 step -1: # in\n' \ 'end\n' \ '/*post*/\n\n' model = ModelParser.parse_for_stmt(stmt) model_printer = ASTNestMLPrinter() self.assertEqual(stmt, model_printer.print_node(model))
def test_update_block_with_comments(self): block = '\n/*pre*/\n' \ 'update: # in\n' \ 'end\n' \ '/*post*/\n\n' model = ModelParser.parse_update_block(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_declaration_with_comments(self): declaration = '\n' \ '/*pre*/\n' \ 'test mV = 10mV # in\n' \ '/*post*/\n\n' model = ModelParser.parse_declaration(declaration) model_printer = ASTNestMLPrinter() self.assertEqual(declaration, model_printer.print_node(model))
def test_for_stmt_with_comments(self): stmt = '\n/*pre*/\n' \ 'for i in 10 - 3.14...10 + 3.14 step -1: # in\n' \ 'end\n' \ '/*post*/\n\n' model = ModelParser.parse_for_stmt(stmt) model_printer = ASTNestMLPrinter() self.assertEqual(stmt, model_printer.print_node(model))
def test_update_block_with_comments(self): block = '\n/*pre*/\n' \ 'update: # in\n' \ 'end\n' \ '/*post*/\n\n' model = ModelParser.parse_update_block(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_neuron_with_comments(self): neuron = '# pre\n' \ 'neuron test: # in\n' \ 'end\n' \ '# post\n\n' model = ModelParser.parse_nestml_compilation_unit(neuron) model_printer = ASTNestMLPrinter() self.assertEqual(neuron, model_printer.print_node(model))
def test_neuron_with_comments(self): neuron = '\n/*pre*/\n' \ 'neuron test: # in\n' \ 'end\n' \ '/*post*/\n\n' model = ModelParser.parse_neuron(neuron) model_printer = ASTNestMLPrinter() self.assertEqual(neuron, model_printer.print_node(model))
def test_assignment_with_comments(self): assignment = '\n' \ '/* pre */\n' \ 'a = b # in\n' \ '/* post */\n' \ '\n' model = ModelParser.parse_assignment(assignment) model_printer = ASTNestMLPrinter() self.assertEqual(assignment, model_printer.print_node(model))
def test_neuron_with_docstring(self): neuron = '"""hello, world\n' \ '\n' \ '3.141592653589793"""\n' \ 'neuron test:\n' \ 'end\n' model = ModelParser.parse_neuron(neuron) model_printer = ASTNestMLPrinter() self.assertEqual(neuron, model_printer.print_node(model))
def test_block_with_variables_with_comments(self): block = '# pre1\n' \ '# pre2\n' \ 'state: # in\n' \ 'end\n' \ '# post1\n' \ '# post2\n\n' model = ModelParser.parse_block_with_variables(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_function_with_comments(self): t_function = '# pre func\n' \ 'function test(Tau_1 ms) real: # in func\n' \ ' # decl pre\n' \ ' exact_integration_adjustment real = ((1 / Tau_2) - (1 / Tau_1)) * ms # decl in\n' \ ' # decl post\n' \ '\n' \ ' return normalisation_factor\n' \ 'end\n' \ '# post func\n\n' model = ModelParser.parse_function(t_function) model_printer = ASTNestMLPrinter() self.assertEqual(t_function, model_printer.print_node(model))
def test_block_with_variables_with_comments(self): block = '\n' \ '/* pre1\n' \ '* pre2\n' \ '*/\n' \ 'state: # in\n' \ 'end\n' \ '/* post1\n' \ '* post2\n' \ '*/\n\n' model = ModelParser.parse_block_with_variables(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_function_with_comments(self): t_function = '\n' \ '/*pre func*/\n' \ 'function test(Tau_1 ms) real: # in func\n\n' \ ' /* decl pre */\n' \ ' exact_integration_adjustment real = ((1 / Tau_2) - (1 / Tau_1)) * ms # decl in\n' \ ' /* decl post */\n' \ '\n' \ ' return normalisation_factor\n' \ 'end\n' \ '/*post func*/\n\n' model = ModelParser.parse_function(t_function) model_printer = ASTNestMLPrinter() self.assertEqual(t_function, model_printer.print_node(model))
def test_while_stmt_without_comments(self): stmt = 'while true:\n' \ 'end\n' model = ModelParser.parse_while_stmt(stmt) model_printer = ASTNestMLPrinter() self.assertEqual(stmt, model_printer.print_node(model))
def test_update_block_without_comments(self): block = 'update:\n' \ 'end\n' model = ModelParser.parse_update_block(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_assignment_without_comments(self): assignment = 'a = b\n' model = ModelParser.parse_assignment(assignment) model_printer = ASTNestMLPrinter() self.assertEqual(assignment, model_printer.print_node(model))
def test_neuron_without_comments(self): neuron = 'neuron test:\n' \ 'end\n' model = ModelParser.parse_neuron(neuron) model_printer = ASTNestMLPrinter() self.assertEqual(neuron, model_printer.print_node(model))
def test_block_with_variables_without_comments(self): block = 'state:\n' \ 'end' model = ModelParser.parse_block_with_variables(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_unit_type(self): unit = '1/(mV*kg**2)' model = ModelParser.parse_unit_type(unit) model_printer = ASTNestMLPrinter() self.assertEqual(unit, model_printer.print_node(model))
def test_update_block_without_comments(self): block = 'update:\n' \ 'end\n' model = ModelParser.parse_update_block(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_unary_operator(self): ops = {'-', '+', '~'} for op in ops: model = ModelParser.parse_unary_operator(op) model_printer = ASTNestMLPrinter() self.assertEqual(op, model_printer.print_node(model))
def test_block_with_variables_without_comments(self): block = 'state:\n' \ 'end' model = ModelParser.parse_block_with_variables(block) model_printer = ASTNestMLPrinter() self.assertEqual(block, model_printer.print_node(model))
def test_function_call_without_comments(self): function_call = 'min(1,2)\n' model = ModelParser.parse_stmt(function_call) model_printer = ASTNestMLPrinter() self.assertEqual(function_call, model_printer.print_node(model))
def test_while_stmt_without_comments(self): stmt = 'while true:\n' \ 'end\n' model = ModelParser.parse_while_stmt(stmt) model_printer = ASTNestMLPrinter() self.assertEqual(stmt, model_printer.print_node(model))
def test_declaration_without_comments(self): declaration = 'test mV = 10mV\n' model = ModelParser.parse_declaration(declaration) model_printer = ASTNestMLPrinter() self.assertEqual(declaration, model_printer.print_node(model))
def test_unit_type(self): unit = '1/(mV*kg**2)' model = ModelParser.parse_unit_type(unit) model_printer = ASTNestMLPrinter() self.assertEqual(unit, model_printer.print_node(model))
def test_variable(self): var = 'V_m' model = ModelParser.parse_variable(var) model_printer = ASTNestMLPrinter() self.assertEqual(var, model_printer.print_node(model))
def test_function_call_without_comments(self): function_call = 'min(1,2)\n' model = ModelParser.parse_stmt(function_call) model_printer = ASTNestMLPrinter() self.assertEqual(function_call, model_printer.print_node(model))
def test_unary_operator(self): ops = {'-', '+', '~'} for op in ops: model = ModelParser.parse_unary_operator(op) model_printer = ASTNestMLPrinter() self.assertEqual(op, model_printer.print_node(model))
def test_variable(self): var = 'V_m' model = ModelParser.parse_variable(var) model_printer = ASTNestMLPrinter() self.assertEqual(var, model_printer.print_node(model))
def test_assignment_without_comments(self): assignment = 'a = b\n' model = ModelParser.parse_assignment(assignment) model_printer = ASTNestMLPrinter() self.assertEqual(assignment, model_printer.print_node(model))
def test_neuron_without_comments(self): neuron = 'neuron test:\n' \ 'end\n' model = ModelParser.parse_neuron(neuron) model_printer = ASTNestMLPrinter() self.assertEqual(neuron, model_printer.print_node(model))
def __str__(self): from pynestml.utils.ast_nestml_printer import ASTNestMLPrinter return ASTNestMLPrinter().print_node(self)
def test_declaration_without_comments(self): declaration = 'test mV = 10mV\n' model = ModelParser.parse_declaration(declaration) model_printer = ASTNestMLPrinter() self.assertEqual(declaration, model_printer.print_node(model))