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


Python InputTreeManager.select_simulator_inputs方法代码示例

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


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

示例1: test_select_simulator_inputs

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import select_simulator_inputs [as 别名]
 def test_select_simulator_inputs(self):
     """
     Test that given a dictionary of selected inputs as it would arrive from UI, only
     the selected simulator inputs are kept.
     """
     simulator_input_tree = self.flow_service.prepare_adapter(self.test_project.id, self.sim_algorithm)
     child_parameter = ''
     checked_parameters = {simulator_input_tree[0][ABCAdapter.KEY_NAME]: {model.KEY_PARAMETER_CHECKED: True,
                                                                          model.KEY_SAVED_VALUE: 'new_value'},
                           simulator_input_tree[1][ABCAdapter.KEY_NAME]: {model.KEY_PARAMETER_CHECKED: True,
                                                                          model.KEY_SAVED_VALUE: 'new_value'}}
     #Look for a entry from a subtree to add to the selected simulator inputs
     for idx, entry in enumerate(simulator_input_tree):
         found_it = False
         if idx not in (0, 1) and entry.get(ABCAdapter.KEY_OPTIONS, False):
             for option in entry[ABCAdapter.KEY_OPTIONS]:
                 if option[ABCAdapter.KEY_VALUE] == entry[ABCAdapter.KEY_DEFAULT]:
                     if option[ABCAdapter.KEY_ATTRIBUTES]:
                         child_parameter = option[ABCAdapter.KEY_ATTRIBUTES][0][ABCAdapter.KEY_NAME]
                         checked_parameters[entry[ABCAdapter.KEY_NAME]] = {model.KEY_PARAMETER_CHECKED: False,
                                                                           model.KEY_SAVED_VALUE: entry[
                                                                               ABCAdapter.KEY_DEFAULT]}
                         checked_parameters[child_parameter] = {model.KEY_PARAMETER_CHECKED: True,
                                                                model.KEY_SAVED_VALUE: 'new_value'}
                         found_it = True
                         break
         if found_it:
             break
     self.assertTrue(child_parameter != '', "Could not find any sub-tree entry in simulator interface.")
     subtree = InputTreeManager.select_simulator_inputs(simulator_input_tree, checked_parameters)
     #After the select method we expect only the checked parameters entries to remain with
     #the new values updated accordingly.
     expected_outputs = [{ABCAdapter.KEY_NAME: simulator_input_tree[0][ABCAdapter.KEY_NAME],
                          ABCAdapter.KEY_DEFAULT: 'new_value'},
                         {ABCAdapter.KEY_NAME: simulator_input_tree[1][ABCAdapter.KEY_NAME],
                          ABCAdapter.KEY_DEFAULT: 'new_value'},
                         {ABCAdapter.KEY_NAME: child_parameter,
                          ABCAdapter.KEY_DEFAULT: 'new_value'}]
     self.assertEqual(len(expected_outputs), len(subtree),
                      "Some entries that should not have been displayed still are.")
     for idx, entry in enumerate(expected_outputs):
         self.assertEqual(expected_outputs[idx][ABCAdapter.KEY_NAME], subtree[idx][ABCAdapter.KEY_NAME])
         self.assertEqual(expected_outputs[idx][ABCAdapter.KEY_DEFAULT], subtree[idx][ABCAdapter.KEY_DEFAULT],
                          'Default value not update properly.')
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:46,代码来源:burst_service_test.py

示例2: get_reduced_simulator_interface

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import select_simulator_inputs [as 别名]
    def get_reduced_simulator_interface(self):
        """
        Get a simulator interface that only contains the inputs that are marked
        as KEY_PARAMETER_CHECKED in the current session.
        """
        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
        simulator_config = burst_config.simulator_configuration
        ## Fill with stored defaults, and see if any parameter was checked by user ##
        default_values, any_checked = burst_config.get_all_simulator_values()
        simulator_input_tree = self.cached_simulator_input_tree
        simulator_input_tree = InputTreeManager.fill_defaults(simulator_input_tree, default_values)
        ## In case no values were checked just skip tree-cut part and show entire simulator tree ##
        if any_checked:
            simulator_input_tree = InputTreeManager.select_simulator_inputs(simulator_input_tree, simulator_config)

        ### Add simulator tree to session to be available in filters
        self.context.add_adapter_to_session(self.cached_simulator_algorithm, simulator_input_tree, default_values)

        template_specification = {"inputList": simulator_input_tree,
                                  common.KEY_PARAMETERS_CONFIG: False,
                                  'draw_hidden_ranges': True}
        return self.fill_default_attributes(template_specification)
开发者ID:maedoc,项目名称:tvb-framework,代码行数:24,代码来源:burst_controller.py


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