Beispiel #1
0
 def test_invalid_expression_correctly_typed(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoIllegalExpression.nestml'))
     self.assertEqual(len(Logger.get_all_messages_of_level_and_or_neuron(model.get_neuron_list()[0],
                                                                         LoggingLevel.ERROR)), 6)
Beispiel #2
0
 def test_valid_continuous_input_ports_not_specified(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoContinuousInputPortQualifierSpecified.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #3
0
 def test_valid_spike_input_port_without_datatype(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoSpikeInputPortWithoutType.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #4
0
 def test_valid_ode_correctly_typed(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoOdeCorrectlyTyped.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #5
0
 def test_valid_parameters_assigned_only_in_parameters_block(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoParameterAssignedOutsideBlock.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #6
0
 def test_valid_ode_vars_outside_init_block_detected(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoOdeVarNotInInitialValues.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #7
0
 def test_invalid_convolve_correctly_parameterized(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoConvolveNotCorrectlyParametrized.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 1)
Beispiel #8
0
 def test_valid_no_values_assigned_to_input_ports(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoValueAssignedToInputPort.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #9
0
 def test_invalid_order_of_equations_correct(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoNoOrderOfEquations.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 2)
Beispiel #10
0
 def test_valid_function_unique_and_defined(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoFunctionNotUnique.nestml'))
     self.assertEqual(
         len(Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #11
0
 def test_valid_inline_expression_has_several_lhs(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoInlineExpressionWithSeveralLhs.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #12
0
 def test_invalid_each_block_unique(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoEachBlockUnique.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 2)
Beispiel #13
0
 def test_invalid_variable_redeclaration(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoVariableRedeclared.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 1)
Beispiel #14
0
 def test_invalid_current_buffers_not_specified_with_keywords(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoCurrentBufferQualifierSpecified.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 1)
Beispiel #15
0
 def test_valid_init_values_have_rhs_and_ode(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoInitValuesWithoutOde.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.WARNING)), 2)
Beispiel #16
0
 def test_valid_numerator_of_unit_one(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoUnitNumeratorNotOne.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #17
0
 def test_valid_incorrect_return_stmt_detected(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoIncorrectReturnStatement.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #18
0
 def test_valid_no_nest_collision(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoNestNamespaceCollision.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #19
0
 def test_valid_vector_parameter_size(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoVectorDeclarationSize.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #20
0
 def test_valid_redundant_input_port_keywords_detected(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoInputPortWithRedundantTypes.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #21
0
 def test_valid_compound_expression_correctly_typed(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CompoundOperatorWithDifferentButCompatibleUnits.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #22
0
 def test_valid_function_with_wrong_arg_number_detected(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoFunctionCallNotConsistentWrongArgNumber.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #23
0
 def test_invalid_vector_in_non_vector_declaration_detected(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoVectorInNonVectorDeclaration.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_neuron(model.get_neuron_list()[0], LoggingLevel.ERROR)), 1)
Beispiel #24
0
 def test_invalid_element_not_defined_in_scope(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoVariableNotDefined.nestml'))
     self.assertEqual(len(Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0],
                                                                       LoggingLevel.ERROR)), 4)
Beispiel #25
0
 def test_valid_integrate_odes_called_if_equations_defined(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoIntegrateOdesCalledIfEquationsDefined.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #26
0
 def test_valid_element_in_same_line(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoElementInSameLine.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #27
0
 def test_invalid_inline_expression_has_several_lhs(self):
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(
             os.path.realpath(
                 os.path.join(os.path.dirname(__file__), 'invalid')),
             'CoCoInlineExpressionWithSeveralLhs.nestml'))
     assert model is None
Beispiel #28
0
    def test_expression_after_magnitude_conversion_in_direct_assignment(self):
        Logger.set_logging_level(LoggingLevel.NO)
        model = ModelParser.parse_model(
            os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'resources')),
                         'DirectAssignmentWithDifferentButCompatibleUnits.nestml'))
        printed_rhs_expression = print_rhs_of_first_assignment_in_update_block(model)

        self.assertEqual(printed_rhs_expression, '1000.0 * (10*V)')
Beispiel #29
0
 def test_valid_output_port_defined_if_emit_call(self):
     """test that no error is raised when the output block is missing, but not emit_spike() functions are called"""
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')),
                      'CoCoOutputPortDefinedIfEmitCall.nestml'))
     self.assertEqual(len(
         Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
Beispiel #30
0
 def test_invalid_output_port_defined_if_emit_call(self):
     """test that an error is raised when the emit_spike() function is called by the neuron, but a spiking output port is not defined"""
     Logger.set_logging_level(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')),
                      'CoCoOutputPortDefinedIfEmitCall-2.nestml'))
     self.assertTrue(len(Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0],
                                                                      LoggingLevel.ERROR)) > 0)