def update_abstract_code(self, run_namespace=None, level=0): # Update the not_refractory variable for the refractory period mechanism self.abstract_code = self._get_refractory_code(run_namespace=run_namespace, level=level+1) # Get the names used in the refractory code _, used_known, unknown = analyse_identifiers(self.abstract_code, self.group.variables, recursive=True) # Get all names used in the equations (and always get "dt") names = self.group.equations.names external_names = self.group.equations.identifiers | {'dt'} variables = self.group.resolve_all(used_known | unknown | names | external_names, # we don't need to raise any warnings # for the user here, warnings will # be raised in create_runner_codeobj set(), run_namespace=run_namespace, level=level+1) # Since we did not necessarily no all the functions at creation time, # we might want to reconsider our numerical integration method self.method = StateUpdateMethod.determine_stateupdater(self.group.equations, variables, self.method_choice) self.abstract_code += self.method(self.group.equations, variables) user_code = '\n'.join(['{var} = {expr}'.format(var=var, expr=expr) for var, expr in self.group.equations.substituted_expressions]) self.user_code = user_code
def update_abstract_code(self, run_namespace=None, level=0): # Update the not_refractory variable for the refractory period mechanism self.abstract_code = self._get_refractory_code( run_namespace=run_namespace, level=level + 1) # Get the names used in the refractory code _, used_known, unknown = analyse_identifiers(self.abstract_code, self.group.variables, recursive=True) # Get all names used in the equations (and always get "dt") names = self.group.equations.names external_names = self.group.equations.identifiers | {'dt'} variables = self.group.resolve_all( used_known | unknown | names | external_names, # we don't need to raise any warnings # for the user here, warnings will # be raised in create_runner_codeobj set(), run_namespace=run_namespace, level=level + 1) # Since we did not necessarily no all the functions at creation time, # we might want to reconsider our numerical integration method self.method = StateUpdateMethod.determine_stateupdater( self.group.equations, variables, self.method_choice) self.abstract_code += self.method(self.group.equations, variables) user_code = '\n'.join([ '{var} = {expr}'.format(var=var, expr=expr) for var, expr in self.group.equations.substituted_expressions ]) self.user_code = user_code
def update_abstract_code(self, run_namespace=None, level=0): self.method = StateUpdateMethod.determine_stateupdater( self.group.equations, self.group.variables, self.method_choice) self.abstract_code = self.method(self.group.equations, self.group.variables)
def update_abstract_code(self, run_namespace=None, level=0): # Update the not_refractory variable for the refractory period mechanism self.abstract_code = self._get_refractory_code( run_namespace=run_namespace, level=level + 1) # Get the names used in the refractory code _, used_known, unknown = analyse_identifiers(self.abstract_code, self.group.variables, recursive=True) # Get all names used in the equations (and always get "dt") names = self.group.equations.names external_names = self.group.equations.identifiers | set(['dt']) variables = self.group.resolve_all(used_known | unknown | names | external_names, run_namespace=run_namespace, level=level + 1) # Since we did not necessarily no all the functions at creation time, # we might want to reconsider our numerical integration method self.method = StateUpdateMethod.determine_stateupdater( self.group.equations, variables, self.method_choice) self.abstract_code += self.method(self.group.equations, variables)
def update_abstract_code(self): self.method = StateUpdateMethod.determine_stateupdater( self.group.equations, self.group.variables, self.method_choice) self.abstract_code = self.method(self.group.equations, self.group.variables)
def update_abstract_code(self): self.method = StateUpdateMethod.determine_stateupdater(self.group.equations, self.group.variables, self.method_choice) self.abstract_code = self.method(self.group.equations, self.group.variables)
def update_abstract_code(self, run_namespace=None, level=0): self.method = StateUpdateMethod.determine_stateupdater(self.group.equations, self.group.variables, self.method_choice) self.abstract_code = self.method(self.group.equations, self.group.variables)
def __init__(self, group, method): self.method_choice = method GroupCodeRunner.__init__(self, group, 'stateupdate', when=(group.clock, 'groups'), name=group.name + '_stateupdater', check_units=False) self.method = StateUpdateMethod.determine_stateupdater(self.group.equations, self.group.variables, method)
def __init__(self, group, method): self.method_choice = method CodeRunner.__init__(self, group, 'stateupdate', when=(group.clock, 'groups'), name=group.name + '_stateupdater', check_units=False) self.method = StateUpdateMethod.determine_stateupdater( self.group.equations, self.group.variables, method)
def __init__(self, group, method): self.method_choice = method GroupCodeRunner.__init__(self, group, 'stateupdate', when=(group.clock, 'groups'), name=group.name + '_stateupdater*', check_units=False) self.method = StateUpdateMethod.determine_stateupdater(self.group.equations, self.group.variables, method) # Generate the full abstract code to catch errors in the refractoriness # formulation. However, do not fail on KeyErrors since the # refractoriness might refer to variables that don't exist yet try: self.update_abstract_code() except KeyError as ex: logger.debug('Namespace not complete (yet), ignoring: %s ' % str(ex), 'StateUpdater')
def __init__(self, group, method): self.method_choice = method GroupCodeRunner.__init__(self, group, 'stateupdate', when=(group.clock, 'groups'), name=group.name + '_stateupdater*', check_units=False) self.method = StateUpdateMethod.determine_stateupdater( self.group.equations, self.group.variables, method) # Generate the full abstract code to catch errors in the refractoriness # formulation. However, do not fail on KeyErrors since the # refractoriness might refer to variables that don't exist yet try: self.update_abstract_code() except KeyError as ex: logger.debug( 'Namespace not complete (yet), ignoring: %s ' % str(ex), 'StateUpdater')
def update_abstract_code(self, run_namespace=None, level=0): # Update the not_refractory variable for the refractory period mechanism self.abstract_code = self._get_refractory_code(run_namespace=run_namespace, level=level+1) # Get the names used in the refractory code _, used_known, unknown = analyse_identifiers(self.abstract_code, self.group.variables, recursive=True) # Get all names used in the equations (and always get "dt") names = self.group.equations.names external_names = self.group.equations.identifiers | set(['dt']) variables = self.group.resolve_all(used_known | unknown | names | external_names, run_namespace=run_namespace, level=level+1) # Since we did not necessarily no all the functions at creation time, # we might want to reconsider our numerical integration method self.method = StateUpdateMethod.determine_stateupdater(self.group.equations, variables, self.method_choice) self.abstract_code += self.method(self.group.equations, variables)