def set_integrator(self, **data): session_stored_simulator = common.get_from_session( common.KEY_SIMULATOR_CONFIG) is_simulator_copy = common.get_from_session( common.KEY_IS_SIMULATOR_COPY) is_simulator_load = common.get_from_session( common.KEY_IS_SIMULATOR_LOAD) if cherrypy.request.method == 'POST': is_simulator_copy = False fragment = SimulatorIntegratorFragment() fragment.fill_from_post(data) session_stored_simulator.integrator = fragment.integrator.value() form = get_form_for_integrator( type(session_stored_simulator.integrator))() form.fill_from_trait(session_stored_simulator.integrator) dict_to_render = copy.deepcopy(self.dict_to_render) dict_to_render[self.FORM_KEY] = form dict_to_render[self.ACTION_KEY] = '/burst/set_integrator_params' dict_to_render[self.PREVIOUS_ACTION_KEY] = '/burst/set_integrator' dict_to_render[self.IS_COPY] = is_simulator_copy dict_to_render[self.IS_LOAD] = is_simulator_load return dict_to_render
def __init__(self): super(SimulatorIntegratorFragment, self).__init__() self.integrator = SelectField(EnumAttr( default=IntegratorViewModelsEnum.HEUN, label=SimulatorAdapterModel.integrator.label, doc=SimulatorAdapterModel.integrator.doc), name='integrator', subform=get_form_for_integrator( IntegratorViewModelsEnum.HEUN.value), ui_values=get_integrator_name_list())
def __init__(self, prefix='', project_id=None): super(SimulatorIntegratorFragment, self).__init__(prefix, project_id) self.integrator_choices = get_ui_name_to_integrator_dict() default_integrator = list(self.integrator_choices.values())[0] self.integrator = SelectField( Attr(Integrator, default=default_integrator, label=Simulator.integrator.label, doc=Simulator.integrator.doc), self, name='integrator', choices=self.integrator_choices, subform=get_form_for_integrator(default_integrator))
def __init__(self): super(SimulatorIntegratorFragment, self).__init__() self.integrator_choices = get_ui_name_to_integrator_dict() default_integrator = list(self.integrator_choices.values())[0] self.integrator = SelectField( Attr(IntegratorViewModel, default=default_integrator, label=SimulatorAdapterModel.integrator.label, doc=SimulatorAdapterModel.integrator.doc), name='integrator', choices=self.integrator_choices, subform=get_form_for_integrator(default_integrator), ui_values=get_integrator_name_list())
def set_integrator_params(self, **data): session_stored_simulator = common.get_from_session( common.KEY_SIMULATOR_CONFIG) is_simulator_copy = common.get_from_session( common.KEY_IS_SIMULATOR_COPY) is_simulator_load = common.get_from_session( common.KEY_IS_SIMULATOR_LOAD) if cherrypy.request.method == 'POST': is_simulator_copy = False form = get_form_for_integrator( type(session_stored_simulator.integrator))() form.fill_from_post(data) form.fill_trait(session_stored_simulator.integrator) if isinstance(session_stored_simulator.integrator, IntegratorStochastic): integrator_noise_fragment = get_form_for_noise( type(session_stored_simulator.integrator.noise))() self.range_parameters.integrator_noise_parameters = integrator_noise_fragment.get_range_parameters( ) integrator_noise_fragment.fill_from_trait( session_stored_simulator.integrator.noise) dict_to_render = copy.deepcopy(self.dict_to_render) dict_to_render[self.FORM_KEY] = integrator_noise_fragment dict_to_render[self.ACTION_KEY] = '/burst/set_noise_params' dict_to_render[ self.PREVIOUS_ACTION_KEY] = '/burst/set_integrator_params' dict_to_render[self.IS_COPY] = is_simulator_copy dict_to_render[self.IS_LOAD] = is_simulator_load return dict_to_render monitor_fragment = SimulatorMonitorFragment( '', common.get_current_project().id) monitor_fragment.fill_from_trait(session_stored_simulator) dict_to_render = copy.deepcopy(self.dict_to_render) dict_to_render[self.FORM_KEY] = monitor_fragment dict_to_render[self.ACTION_KEY] = '/burst/set_monitors' dict_to_render[ self.PREVIOUS_ACTION_KEY] = '/burst/set_integrator_params' dict_to_render[self.IS_COPY] = is_simulator_copy dict_to_render[self.IS_LOAD] = is_simulator_load return dict_to_render
def integrator_parameters_changed(self, dynamic_gid, type, **param): dynamic = self.get_cached_dynamic(dynamic_gid) integrator = dynamic.integrator changed_params = list(param.keys()) if type == SubformHelper.FormToConfigEnum.INTEGRATOR.name: integrator_form_class = get_form_for_integrator(integrator.__class__) integrator_form = integrator_form_class() integrator_form.fill_from_post(param) integrator_form.fill_trait_partially(integrator, changed_params) if type == SubformHelper.FormToConfigEnum.NOISE.name: noise_form_class = get_form_for_noise(integrator.noise.__class__) noise_form = noise_form_class() noise_form.fill_from_post(param) noise_form.fill_trait_partially(integrator.noise, changed_params) if type == SubformHelper.FormToConfigEnum.EQUATION.name: eq_form_class = get_form_for_equation(integrator.noise.b.__class__) eq_form = eq_form_class() eq_form.fill_from_post(param) eq_form.fill_trait_partially(integrator.noise.b, changed_params) self._update_integrator(dynamic, integrator)