当前位置: 首页>>代码示例>>Python>>正文


Python Logger.log_message方法代码示例

本文整理汇总了Python中pynestml.utils.logger.Logger.log_message方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.log_message方法的具体用法?Python Logger.log_message怎么用?Python Logger.log_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynestml.utils.logger.Logger的用法示例。


在下文中一共展示了Logger.log_message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_vectorized_assignment

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def is_vectorized_assignment(cls, assignment):
     """
     Indicates whether the handed over assignment is vectorized, i.e., an assignment of vectors.
     :param assignment: a single assignment.
     :type assignment: ASTAssignment
     :return: True if vectorized, otherwise False.
     :rtype: bool
     """
     from pynestml.symbols.symbol import SymbolKind
     assert isinstance(assignment, ASTAssignment), \
         '(PyNestML.CodeGeneration.Assignments) No or wrong type of assignment provided (%s)!' % type(assignment)
     symbol = assignment.get_scope().resolve_to_symbol(assignment.get_variable().get_complete_name(),
                                                       SymbolKind.VARIABLE)
     if symbol is not None:
         if symbol.has_vector_parameter():
             return True
         else:
             # otherwise we have to check if one of the variables used in the rhs is a vector
             for var in assignment.get_expression().get_variables():
                 symbol = var.get_scope().resolve_to_symbol(var.get_complete_name(), SymbolKind.VARIABLE)
                 if symbol is not None and symbol.has_vector_parameter():
                     return True
             return False
     else:
         Logger.log_message(message='No symbol could be resolved!', log_level=LoggingLevel.ERROR)
         return False
开发者ID:Silmathoron,项目名称:nestml,代码行数:28,代码来源:nest_assignments_helper.py

示例2: check_co_co

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def check_co_co(cls, _neuron=None):
     """
     Checks the coco for the handed over neuron.
     :param _neuron: a single neuron instance.
     :type _neuron: ASTNeuron
     """
     assert (_neuron is not None and isinstance(_neuron, ASTNeuron)), \
         '(PyNestML.CoCo.FunctionCallsConsistent) No or wrong type of neuron provided (%s)!' % type(_neuron)
     cls.__neuronName = _neuron.get_name()
     for userDefinedFunction in _neuron.get_functions():
         cls.processed_function = userDefinedFunction
         symbol = userDefinedFunction.get_scope().resolve_to_symbol(userDefinedFunction.get_name(),
                                                                    SymbolKind.FUNCTION)
         # first ensure that the block contains at least one statement
         if symbol is not None and len(userDefinedFunction.get_block().get_stmts()) > 0:
             # now check that the last statement is a return
             cls.__check_return_recursively(symbol.get_return_type(),
                                            userDefinedFunction.get_block().get_stmts(), False)
         # now if it does not have a statement, but uses a return type, it is an error
         elif symbol is not None and userDefinedFunction.has_return_type() and \
                 not symbol.get_return_type().equals(PredefinedTypes.get_void_type()):
             code, message = Messages.get_no_return()
             Logger.log_message(neuron=_neuron, code=code, message=message,
                                error_position=userDefinedFunction.get_source_position(),
                                log_level=LoggingLevel.ERROR)
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:28,代码来源:co_co_user_defined_function_correctly_defined.py

示例3: endvisit_assignment

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
    def endvisit_assignment(self, node):
        scope = node.get_scope()
        var_name = node.get_variable().get_name()

        _expr = node.get_expression()

        var_symbol = scope.resolve_to_symbol(var_name, SymbolKind.VARIABLE)

        _equals = var_symbol.get_type_symbol().equals(_expr.type)

        message = 'line ' + str(_expr.get_source_position()) + ' : LHS = ' + \
                  var_symbol.get_type_symbol().get_symbol_name() + \
                  ' RHS = ' + _expr.type.get_symbol_name() + \
                  ' Equal ? ' + str(_equals)

        if isinstance(_expr.type, UnitTypeSymbol):
            message += " Neuroscience Factor: " + \
                       str(UnitConverter().get_factor(_expr.type.astropy_unit))

        Logger.log_message(error_position=node.get_source_position(), code=MessageCode.TYPE_MISMATCH,
                           message=message, log_level=LoggingLevel.INFO)

        if _equals is False:
            Logger.log_message(message="Type mismatch in test!",
                               code=MessageCode.TYPE_MISMATCH,
                               error_position=node.get_source_position(),
                               log_level=LoggingLevel.ERROR)
        return
开发者ID:Silmathoron,项目名称:nestml,代码行数:30,代码来源:expression_type_calculation_test.py

示例4: visit_assignment

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def visit_assignment(self, node):
     symbol = node.get_scope().resolve_to_symbol(node.get_variable().get_complete_name(),
                                                 SymbolKind.VARIABLE)
     if symbol is None:
         code, message = Messages.get_variable_not_defined(node.get_variable().get_complete_name())
         Logger.log_message(code=code, message=message, error_position=node.get_source_position(),
                            log_level=LoggingLevel.ERROR, neuron=self.neuron)
开发者ID:Silmathoron,项目名称:nestml,代码行数:9,代码来源:co_co_all_variables_defined.py

示例5: visit_simple_expression

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
    def visit_simple_expression(self, node):
        """
        Visits a single variable as contained in a simple expression and derives its type.
        :param node: a single simple expression
        :type node: ASTSimpleExpression
        """
        assert isinstance(node, ASTSimpleExpression), \
            '(PyNestML.Visitor.VariableVisitor) No or wrong type of simple expression provided (%s)!' % type(node)
        assert (node.get_scope() is not None), \
            '(PyNestML.Visitor.VariableVisitor) No scope found, run symboltable creator!'

        scope = node.get_scope()
        var_name = node.get_variable().get_name()
        var_resolve = scope.resolve_to_symbol(var_name, SymbolKind.VARIABLE)

        # update the type of the variable according to its symbol type.
        if var_resolve is not None:
            node.type = var_resolve.get_type_symbol()
            node.type.referenced_object = node
        else:
            # check if var_name is actually a type literal (e.g. "mV")
            var_resolve = scope.resolve_to_symbol(var_name, SymbolKind.TYPE)
            if var_resolve is not None:
                node.type = var_resolve
                node.type.referenced_object = node
            else:
                message = 'Variable ' + str(node) + ' could not be resolved!'
                Logger.log_message(code=MessageCode.SYMBOL_NOT_RESOLVED,
                                   error_position=node.get_source_position(),
                                   message=message, log_level=LoggingLevel.ERROR)
                node.type = ErrorTypeSymbol()
        return
开发者ID:Silmathoron,项目名称:nestml,代码行数:34,代码来源:ast_variable_visitor.py

示例6: visit_expression

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
    def visit_expression(self, node):
        """
        Visits an expression which uses a binary logic operator and updates the type.
        :param node: a single expression.
        :type node: ast_expression
        """
        lhs_type = node.get_lhs().type
        rhs_type = node.get_rhs().type

        lhs_type.referenced_object = node.get_lhs()
        rhs_type.referenced_object = node.get_rhs()

        if isinstance(lhs_type, BooleanTypeSymbol) and isinstance(rhs_type, BooleanTypeSymbol):
            node.type = PredefinedTypes.get_boolean_type()
        else:
            if isinstance(lhs_type, BooleanTypeSymbol):
                offending_type = lhs_type
            else:
                offending_type = rhs_type
            code, message = Messages.get_type_different_from_expected(BooleanTypeSymbol(), offending_type)
            Logger.log_message(code=code, message=message,
                               error_position=lhs_type.referenced_object.get_source_position(),
                               log_level=LoggingLevel.ERROR)
            node.type = ErrorTypeSymbol()
        return
开发者ID:Silmathoron,项目名称:nestml,代码行数:27,代码来源:ast_binary_logic_visitor.py

示例7: generate_module_code

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
    def generate_module_code(self, neurons):
        # type: (list(ASTNeuron)) -> None
        """
        Generates code that is necessary to integrate neuron models into the NEST infrastructure.
        :param neurons: a list of neurons
        :type neurons: list(ASTNeuron)
        """
        namespace = {'neurons': neurons,
                     'moduleName': FrontendConfiguration.get_module_name(),
                     'now': datetime.datetime.utcnow()}
        if not os.path.exists(FrontendConfiguration.get_target_path()):
            os.makedirs(FrontendConfiguration.get_target_path())

        with open(str(os.path.join(FrontendConfiguration.get_target_path(),
                                   FrontendConfiguration.get_module_name())) + '.h', 'w+') as f:
            f.write(str(self._template_module_header.render(namespace)))

        with open(str(os.path.join(FrontendConfiguration.get_target_path(),
                                   FrontendConfiguration.get_module_name())) + '.cpp', 'w+') as f:
            f.write(str(self._template_module_class.render(namespace)))

        with open(str(os.path.join(FrontendConfiguration.get_target_path(),
                                   'CMakeLists')) + '.txt', 'w+') as f:
            f.write(str(self._template_cmakelists.render(namespace)))

        if not os.path.isdir(os.path.realpath(os.path.join(FrontendConfiguration.get_target_path(), 'sli'))):
            os.makedirs(os.path.realpath(os.path.join(FrontendConfiguration.get_target_path(), 'sli')))

        with open(str(os.path.join(FrontendConfiguration.get_target_path(), 'sli',
                                   FrontendConfiguration.get_module_name() + "-init")) + '.sli', 'w+') as f:
            f.write(str(self._template_sli_init.render(namespace)))

        code, message = Messages.get_module_generated(FrontendConfiguration.get_target_path())
        Logger.log_message(None, code, message, None, LoggingLevel.INFO)
开发者ID:Silmathoron,项目名称:nestml,代码行数:36,代码来源:nest_codegenerator.py

示例8: analyse_neuron

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def analyse_neuron(self, neuron):
     # type: (ASTNeuron) -> None
     """
     Analyse and transform a single neuron.
     :param neuron: a single neuron.
     """
     code, message = Messages.get_start_processing_neuron(neuron.get_name())
     Logger.log_message(neuron, code, message, neuron.get_source_position(), LoggingLevel.INFO)
     # make normalization
     # apply spikes to buffers
     # get rid of convolve, store them and apply then at the end
     equations_block = neuron.get_equations_block()
     shape_to_buffers = {}
     if neuron.get_equations_block() is not None:
         # extract function names and corresponding incoming buffers
         convolve_calls = OdeTransformer.get_sum_function_calls(equations_block)
         for convolve in convolve_calls:
             shape_to_buffers[str(convolve.get_args()[0])] = str(convolve.get_args()[1])
         OdeTransformer.refactor_convolve_call(neuron.get_equations_block())
         self.make_functions_self_contained(equations_block.get_ode_functions())
         self.replace_functions_through_defining_expressions(equations_block.get_ode_equations(),
                                                        equations_block.get_ode_functions())
         # transform everything into gsl processable (e.g. no functional shapes) or exact form.
         self.transform_shapes_and_odes(neuron, shape_to_buffers)
         self.apply_spikes_from_buffers(neuron, shape_to_buffers)
         # update the symbol table
         symbol_table_visitor = ASTSymbolTableVisitor()
         symbol_table_visitor.after_ast_rewrite_ = True		# ODE block might have been removed entirely: suppress warnings
         neuron.accept(symbol_table_visitor)
开发者ID:Silmathoron,项目名称:nestml,代码行数:31,代码来源:nest_codegenerator.py

示例9: visit_variable

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def visit_variable(self, node):
     """
     Visits each shape and checks if it is used correctly.
     :param node: a single node.
     :type node: AST_
     """
     for shapeName in self.__shapes:
         # in order to allow shadowing by local scopes, we first check if the element has been declared locally
         symbol = node.get_scope().resolve_to_symbol(shapeName, SymbolKind.VARIABLE)
         # if it is not a shape just continue
         if symbol is None:
             code, message = Messages.get_no_variable_found(shapeName)
             Logger.log_message(neuron=self.__neuron_node, code=code, message=message, log_level=LoggingLevel.ERROR)
             continue
         if not symbol.is_shape():
             continue
         if node.get_complete_name() == shapeName:
             parent = self.__neuron_node.get_parent(node)
             if parent is not None:
                 if isinstance(parent, ASTOdeShape):
                     continue
                 grandparent = self.__neuron_node.get_parent(parent)
                 if grandparent is not None and isinstance(grandparent, ASTFunctionCall):
                     grandparent_func_name = grandparent.get_name()
                     if grandparent_func_name == 'curr_sum' or grandparent_func_name == 'cond_sum' or \
                             grandparent_func_name == 'convolve':
                         continue
             code, message = Messages.get_shape_outside_convolve(shapeName)
             Logger.log_message(error_position=node.get_source_position(),
                                code=code, message=message,
                                log_level=LoggingLevel.ERROR)
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:34,代码来源:co_co_no_shapes_except_in_convolve.py

示例10: binary_operation_not_defined_error

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def binary_operation_not_defined_error(self, _operator, _other):
     from pynestml.symbols.error_type_symbol import ErrorTypeSymbol
     result = ErrorTypeSymbol()
     code, message = Messages.get_binary_operation_not_defined(lhs=self, operator=_operator, rhs=_other)
     Logger.log_message(code=code, message=message, error_position=self.referenced_object.get_source_position(),
                        log_level=LoggingLevel.ERROR)
     return result
开发者ID:Silmathoron,项目名称:nestml,代码行数:9,代码来源:type_symbol.py

示例11: visit_neuron

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def visit_neuron(self, node):
     """
     Private method: Used to visit a single neuron and create the corresponding global as well as local scopes.
     :return: a single neuron.
     :rtype: ast_neuron
     """
     # set current processed neuron
     Logger.set_current_neuron(node)
     code, message = Messages.get_start_building_symbol_table()
     Logger.log_message(neuron=node, code=code, error_position=node.get_source_position(),
                        message=message, log_level=LoggingLevel.INFO)
     # before starting the work on the neuron, make everything which was implicit explicit
     # but if we have a model without an equations block, just skip this step
     if node.get_equations_blocks() is not None:
         make_implicit_odes_explicit(node.get_equations_blocks())
     scope = Scope(scope_type=ScopeType.GLOBAL, source_position=node.get_source_position())
     node.update_scope(scope)
     node.get_body().update_scope(scope)
     # now first, we add all predefined elements to the scope
     variables = PredefinedVariables.get_variables()
     functions = PredefinedFunctions.get_function_symbols()
     types = PredefinedTypes.get_types()
     for symbol in variables.keys():
         node.get_scope().add_symbol(variables[symbol])
     for symbol in functions.keys():
         node.get_scope().add_symbol(functions[symbol])
     for symbol in types.keys():
         node.get_scope().add_symbol(types[symbol])
开发者ID:Silmathoron,项目名称:nestml,代码行数:30,代码来源:ast_symbol_table_visitor.py

示例12: visit_assignment

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def visit_assignment(self, node):
     symbol = node.get_scope().resolve_to_symbol(node.get_variable().get_name(), SymbolKind.VARIABLE)
     if symbol is not None and (symbol.block_type == BlockType.INPUT_BUFFER_SPIKE or
                                symbol.block_type == BlockType.INPUT_BUFFER_CURRENT):
         code, message = Messages.get_value_assigned_to_buffer(node.get_variable().get_complete_name())
         Logger.log_message(code=code, message=message,
                            error_position=node.get_source_position(),
                            log_level=LoggingLevel.ERROR)
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:co_co_buffer_not_assigned.py

示例13: visit_unit_type

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def visit_unit_type(self, node):
     """
     Check if the coco applies,
     :param node: a single unit type object.
     :type node: ast_unit_type
     """
     if node.is_div and isinstance(node.lhs, int) and node.lhs != 1:
         code, message = Messages.get_wrong_numerator(str(node))
         Logger.log_message(code=code, message=message, error_position=node.get_source_position(),
                            log_level=LoggingLevel.ERROR)
开发者ID:Silmathoron,项目名称:nestml,代码行数:12,代码来源:co_co_correct_numerator_of_unit.py

示例14: handle_target

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
    def handle_target(cls, target):
        if target is None or target.upper() == "NONE":
            target = ""     # make sure `target` is always a string

        if target not in CodeGenerator.get_known_targets():
            code, message = Messages.get_unknown_target(target)
            Logger.log_message(None, code, message, None, LoggingLevel.ERROR)
            raise InvalidTargetException()

        cls.target = target
开发者ID:Silmathoron,项目名称:nestml,代码行数:12,代码来源:frontend_configuration.py

示例15: visit_ode_equation

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import log_message [as 别名]
 def visit_ode_equation(self, node):
     """
     Checks the coco.
     :param node: A single ode equation.
     :type node: ast_ode_equation
     """
     if node.get_lhs().get_differential_order() == 0:
         code, message = Messages.get_order_not_declared(node.get_lhs().get_name())
         Logger.log_message(error_position=node.get_source_position(), code=code,
                            message=message, log_level=LoggingLevel.ERROR)
开发者ID:Silmathoron,项目名称:nestml,代码行数:12,代码来源:co_co_correct_order_in_equation.py


注:本文中的pynestml.utils.logger.Logger.log_message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。