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


Python PredefinedTypes.get_type方法代码示例

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


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

示例1: endvisit_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def endvisit_function(self, node):
     symbol = self.symbol_stack.pop()
     scope = self.scope_stack.pop()
     assert isinstance(symbol, FunctionSymbol), 'Not a function symbol'
     for arg in node.get_parameters():
         # given the fact that the name is not directly equivalent to the one as stated in the model,
         # we have to get it by the sub-visitor
         data_type_visitor = ASTDataTypeVisitor()
         arg.get_data_type().accept(data_type_visitor)
         type_name = data_type_visitor.result
         # first collect the types for the parameters of the function symbol
         symbol.add_parameter_type(PredefinedTypes.get_type(type_name))
         # update the scope of the arg
         arg.update_scope(scope)
         # create the corresponding variable symbol representing the parameter
         var_symbol = VariableSymbol(element_reference=arg, scope=scope, name=arg.get_name(),
                                     block_type=BlockType.LOCAL, is_predefined=False, is_function=False,
                                     is_recordable=False,
                                     type_symbol=PredefinedTypes.get_type(type_name),
                                     variable_type=VariableType.VARIABLE)
         assert isinstance(scope, Scope)
         scope.add_symbol(var_symbol)
     if node.has_return_type():
         data_type_visitor = ASTDataTypeVisitor()
         node.get_return_type().accept(data_type_visitor)
         symbol.set_return_type(PredefinedTypes.get_type(data_type_visitor.result))
     else:
         symbol.set_return_type(PredefinedTypes.get_void_type())
     self.block_type_stack.pop()  # before leaving update the type
开发者ID:Silmathoron,项目名称:nestml,代码行数:31,代码来源:ast_symbol_table_visitor.py

示例2: __register_cond_sum_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def __register_cond_sum_function(cls):
     """
     Registers the cond_sum function into scope.
     """
     params = list()
     params.append(PredefinedTypes.get_type('nS'))
     params.append(PredefinedTypes.get_real_type())
     symbol = FunctionSymbol(name=cls.COND_SUM, param_types=params,
                             return_type=PredefinedTypes.get_type('nS'),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.COND_SUM] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:13,代码来源:predefined_functions.py

示例3: __register_delta_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def __register_delta_function(cls):
     """
     Registers the delta function.
     """
     params = list()
     params.append(PredefinedTypes.get_type('ms'))
     params.append(PredefinedTypes.get_type('ms'))
     symbol = FunctionSymbol(name=cls.DELTA, param_types=params,
                             return_type=PredefinedTypes.get_real_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.DELTA] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:13,代码来源:predefined_functions.py

示例4: endvisit_input_line

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def endvisit_input_line(self, node):
     buffer_type = BlockType.INPUT_BUFFER_SPIKE if node.is_spike() else BlockType.INPUT_BUFFER_CURRENT
     if node.is_spike() and node.has_datatype():
         type_symbol = node.get_datatype().get_type_symbol()
     elif node.is_spike():
         type_symbol = PredefinedTypes.get_type('nS')
     else:
         type_symbol = PredefinedTypes.get_type('pA')
     type_symbol.is_buffer = True  # set it as a buffer
     symbol = VariableSymbol(element_reference=node, scope=node.get_scope(), name=node.get_name(),
                             block_type=buffer_type, vector_parameter=node.get_index_parameter(),
                             is_predefined=False, is_function=False, is_recordable=False,
                             type_symbol=type_symbol, variable_type=VariableType.BUFFER)
     symbol.set_comment(node.get_comment())
     node.get_scope().add_symbol(symbol)
开发者ID:Silmathoron,项目名称:nestml,代码行数:17,代码来源:ast_symbol_table_visitor.py

示例5: __register_time_resolution_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def __register_time_resolution_function(cls):
     """
     Registers the time resolution function.
     """
     symbol = FunctionSymbol(name=cls.TIME_RESOLUTION, param_types=list(),
                             return_type=PredefinedTypes.get_type('ms'),
                             element_reference=None, is_predefined=True, scope=None)
     cls.name2function[cls.TIME_RESOLUTION] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:10,代码来源:predefined_functions.py

示例6: inverse_of_unit

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def inverse_of_unit(cls, other):
     """
     :param other: the unit to invert
     :type other: unit_type_symbol
     :return: UnitTypeSymbol
     """
     from pynestml.symbols.predefined_types import PredefinedTypes
     result = PredefinedTypes.get_type(1 / other.astropy_unit)
     return result
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:type_symbol.py

示例7: __register_time_constant

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def __register_time_constant(cls):
     """
     Adds the time constant t.
     """
     symbol = VariableSymbol(name='t', block_type=BlockType.STATE,
                             is_predefined=True, type_symbol=PredefinedTypes.get_type('ms'),
                             variable_type=VariableType.VARIABLE)
     cls.name2variable[cls.TIME_CONSTANT] = symbol
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_variables.py

示例8: __register_time_steps_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def __register_time_steps_function(cls):
     """
     Registers the time-resolution.
     """
     params = list()
     params.append(PredefinedTypes.get_type('ms'))
     symbol = FunctionSymbol(name=cls.TIME_STEPS, param_types=params,
                             return_type=PredefinedTypes.get_integer_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.TIME_STEPS] = symbol
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:13,代码来源:predefined_functions.py

示例9: __register_predefined_type_variables

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def __register_predefined_type_variables(cls):
     """
     Registers all predefined type variables, e.g., mV and integer.
     """
     for name in PredefinedTypes.get_types().keys():
         symbol = VariableSymbol(name=name, block_type=BlockType.PREDEFINED,
                                 is_predefined=True,
                                 type_symbol=PredefinedTypes.get_type(name),
                                 variable_type=VariableType.TYPE)
         cls.name2variable[name] = symbol
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:13,代码来源:predefined_variables.py

示例10: get_buffer_type_not_defined

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def get_buffer_type_not_defined(cls, buffer_name):
     """
     Returns a message indicating that a buffer type has not been defined, thus nS is assumed.
     :param buffer_name: a buffer name
     :type buffer_name: str
     :return: a message
     :rtype: (MessageCode,str)
     """
     assert (buffer_name is not None and isinstance(buffer_name, str)), \
         '(PyNestML.Utils.Message) Not a string provided (%s)!' % type(buffer_name)
     from pynestml.symbols.predefined_types import PredefinedTypes
     message = 'No buffer type declared of \'%s\', \'%s\' is assumed!' \
               % (buffer_name, PredefinedTypes.get_type('nS').print_symbol())
     return MessageCode.SPIKE_BUFFER_TYPE_NOT_DEFINED, message
开发者ID:Silmathoron,项目名称:nestml,代码行数:16,代码来源:messages.py

示例11: handle_unit

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
def handle_unit(unit_type):
    """
    Handles a handed over unit by creating the corresponding unit-type, storing it in the list of predefined
    units, creating a type symbol and returning it.
    :param unit_type: astropy unit object
    :type unit_type: astropy.units.core.Unit
    :return: a new type symbol
    :rtype: TypeSymbol
    """
    # first ensure that it does not already exists, if not create it and register it in the set of predefined units
    # first clean up the unit of not required components, here it is the 1.0 in front of the unit
    # e.g., 1.0 * 1 / ms. This step is not mandatory for correctness, but makes  reporting easier
    if isinstance(unit_type, units.Quantity) and unit_type.value == 1.0:
        to_process = unit_type.unit
    else:
        to_process = unit_type
    if str(to_process) not in PredefinedUnits.get_units().keys():
        unit_type_t = UnitType(name=str(to_process), unit=to_process)
        PredefinedUnits.register_unit(unit_type_t)
    # now create the corresponding type symbol if it does not exists
    if PredefinedTypes.get_type(str(to_process)) is None:
        type_symbol = UnitTypeSymbol(unit=PredefinedUnits.get_unit(str(to_process)))
        PredefinedTypes.register_type(type_symbol)
    return PredefinedTypes.get_type(name=str(to_process))
开发者ID:Silmathoron,项目名称:nestml,代码行数:26,代码来源:ast_data_type_visitor.py

示例12: visit_unit_type

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def visit_unit_type(self, node):
     """
     Visits a single unit type element, checks for correct usage of units and builds the corresponding combined 
     unit.
     :param node: a single unit type meta_model.
     :type node: ASTUnitType
     :return: a new type symbol representing this unit type.
     :rtype: type_symbol
     """
     if node.is_simple_unit():
         type_s = PredefinedTypes.get_type(node.unit)
         if type_s is None:
             raise RuntimeError('Unknown atomic unit %s.' % node.unit)
         else:
             node.set_type_symbol(type_s)
             self.symbol = type_s
开发者ID:Silmathoron,项目名称:nestml,代码行数:18,代码来源:ast_data_type_visitor.py

示例13: visit_declaration

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def visit_declaration(self, node):
     """
     Private method: Used to visit a single declaration, update its scope and return the corresponding set of
     symbols
     :param node: a declaration object.
     :type node: ast_declaration
     :return: the scope is update without a return value.
     :rtype: void
     """
     expression = node.get_expression() if node.has_expression() else None
     visitor = ASTDataTypeVisitor()
     node.get_data_type().accept(visitor)
     type_name = visitor.result
     # all declarations in the state block are recordable
     is_recordable = (node.is_recordable or
                      self.block_type_stack.top() == BlockType.STATE or
                      self.block_type_stack.top() == BlockType.INITIAL_VALUES)
     init_value = node.get_expression() if self.block_type_stack.top() == BlockType.INITIAL_VALUES else None
     vector_parameter = node.get_size_parameter()
     # now for each variable create a symbol and update the scope
     for var in node.get_variables():  # for all variables declared create a new symbol
         var.update_scope(node.get_scope())
         type_symbol = PredefinedTypes.get_type(type_name)
         symbol = VariableSymbol(element_reference=node,
                                 scope=node.get_scope(),
                                 name=var.get_complete_name(),
                                 block_type=self.block_type_stack.top(),
                                 declaring_expression=expression, is_predefined=False,
                                 is_function=node.is_function,
                                 is_recordable=is_recordable,
                                 type_symbol=type_symbol,
                                 initial_value=init_value,
                                 vector_parameter=vector_parameter,
                                 variable_type=VariableType.VARIABLE
                                 )
         symbol.set_comment(node.get_comment())
         node.get_scope().add_symbol(symbol)
         var.set_type_symbol(Either.value(type_symbol))
     # the data type
     node.get_data_type().update_scope(node.get_scope())
     # the rhs update
     if node.has_expression():
         node.get_expression().update_scope(node.get_scope())
     # the invariant update
     if node.has_invariant():
         node.get_invariant().update_scope(node.get_scope())
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:49,代码来源:ast_symbol_table_visitor.py

示例14: visit_ode_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_type [as 别名]
 def visit_ode_function(self, node):
     """
     Private method: Used to visit a single ode-function, create the corresponding symbol and update the scope.
     :param node: a single ode-function.
     :type node: ast_ode_function
     """
     data_type_visitor = ASTDataTypeVisitor()
     node.get_data_type().accept(data_type_visitor)
     type_symbol = PredefinedTypes.get_type(data_type_visitor.result)
     # now a new symbol
     symbol = VariableSymbol(element_reference=node, scope=node.get_scope(),
                             name=node.get_variable_name(),
                             block_type=BlockType.EQUATION,
                             declaring_expression=node.get_expression(),
                             is_predefined=False, is_function=True,
                             is_recordable=node.is_recordable,
                             type_symbol=type_symbol,
                             variable_type=VariableType.VARIABLE)
     symbol.set_comment(node.get_comment())
     # now update the scopes
     node.get_scope().add_symbol(symbol)
     node.get_data_type().update_scope(node.get_scope())
     node.get_expression().update_scope(node.get_scope())
开发者ID:Silmathoron,项目名称:nestml,代码行数:25,代码来源:ast_symbol_table_visitor.py


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