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


Python Logger.set_current_neuron方法代码示例

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


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

示例1: visit_neuron

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import set_current_neuron [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

示例2: test

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import set_current_neuron [as 别名]
 def test(self):
     Logger.init_logger(LoggingLevel.INFO)
     model = ModelParser.parse_model(
         os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__),
                                                    'resources', 'ExpressionTypeTest.nestml'))))
     Logger.set_current_neuron(model.get_neuron_list()[0])
     model.accept(ExpressionTestVisitor())
     # ExpressionTestVisitor().handle(model)
     Logger.set_current_neuron(None)
     self.assertEqual(len(Logger.get_all_messages_of_level_and_or_neuron(model.get_neuron_list()[0],
                                                                         LoggingLevel.ERROR)), 2)
开发者ID:Silmathoron,项目名称:nestml,代码行数:13,代码来源:expression_type_calculation_test.py

示例3: visitNeuron

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import set_current_neuron [as 别名]
 def visitNeuron(self, ctx):
     name = str(ctx.NAME()) if ctx.NAME() is not None else None
     body = self.visit(ctx.body()) if ctx.body() is not None else None
     # after we have constructed the meta_model of the neuron,
     # we can ensure some basic properties which should always hold
     # we have to check if each type of block is defined at most once (except for function), and that input,output
     # and update are defined once
     if hasattr(ctx.start.source[1], 'fileName'):
         artifact_name = ntpath.basename(ctx.start.source[1].fileName)
     else:
         artifact_name = 'parsed from string'
     neuron = ASTNodeFactory.create_ast_neuron(name=name, body=body, source_position=create_source_pos(ctx),
                                               artifact_name=artifact_name)
     # update the comments
     update_node_comments(neuron, self.__comments.visit(ctx))
     # in order to enable the logger to print correct messages set as the source the corresponding neuron
     Logger.set_current_neuron(neuron)
     CoCoEachBlockUniqueAndDefined.check_co_co(node=neuron)
     Logger.set_current_neuron(neuron)
     # now the meta_model seems to be correct, return it
     return neuron
开发者ID:Silmathoron,项目名称:nestml,代码行数:23,代码来源:ast_builder_visitor.py

示例4: endvisit_neuron

# 需要导入模块: from pynestml.utils.logger import Logger [as 别名]
# 或者: from pynestml.utils.logger.Logger import set_current_neuron [as 别名]
 def endvisit_neuron(self, node):
     # before following checks occur, we need to ensure several simple properties
     CoCosManager.post_symbol_table_builder_checks(node, skip_check_correct_usage_of_shapes=self.after_ast_rewrite_)
     # the following part is done in order to mark conductance based buffers as such.
     if node.get_input_blocks() is not None and node.get_equations_blocks() is not None and \
             len(node.get_equations_blocks().get_declarations()) > 0:
         # this case should be prevented, since several input blocks result in  a incorrect model
         if isinstance(node.get_input_blocks(), list):
             buffers = (buffer for bufferA in node.get_input_blocks() for buffer in bufferA.get_input_lines())
         else:
             buffers = (buffer for buffer in node.get_input_blocks().get_input_lines())
         from pynestml.meta_model.ast_ode_shape import ASTOdeShape
         # todo by KP: ode declarations are not used, is this correct?
         # ode_declarations = (decl for decl in node.get_equations_blocks().get_declarations() if
         #                    not isinstance(decl, ASTOdeShape))
         mark_conductance_based_buffers(input_lines=buffers)
     # now update the equations
     if node.get_equations_blocks() is not None and len(node.get_equations_blocks().get_declarations()) > 0:
         equation_block = node.get_equations_blocks()
         assign_ode_to_variables(equation_block)
     if not self.after_ast_rewrite_:
         CoCosManager.post_ode_specification_checks(node)
     Logger.set_current_neuron(None)
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:26,代码来源:ast_symbol_table_visitor.py


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