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


Python InputTreeManager.prepare_param_names方法代码示例

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


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

示例1: get_surface_model_parameters_data

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import prepare_param_names [as 别名]
    def get_surface_model_parameters_data(self, default_selected_model_param=None):
        """
        Returns a dictionary which contains all the data needed for drawing the
        model parameters.
        """
        context_model_parameters = common.get_from_session(KEY_CONTEXT_MPS)
        if default_selected_model_param is None:
            default_selected_model_param = context_model_parameters.prepared_model_parameter_names.values()[0]

        equation_displayer = EquationDisplayer()
        equation_displayer.trait.bound = interface.INTERFACE_ATTRIBUTES_ONLY
        input_list = equation_displayer.interface[interface.INTERFACE_ATTRIBUTES]
        input_list[0] = self._lock_midpoints(input_list[0])

        options = []
        for original_param, modified_param in context_model_parameters.prepared_model_parameter_names.items():
            attributes = deepcopy(input_list)
            self._fill_default_values(attributes, modified_param)
            option = {'name': original_param, 'value': modified_param, 'attributes': attributes}
            options.append(option)

        input_list = [{'name': 'model_param', 'type': 'select', 'default': default_selected_model_param,
                       'label': 'Model param', 'required': True, 'options': options}]
        input_list = InputTreeManager.prepare_param_names(input_list)
        return {common.KEY_PARAMETERS_CONFIG: False, 'inputList': input_list,
                'applied_equations': context_model_parameters.get_configure_info()}
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:28,代码来源:surface_model_parameters_controller.py

示例2: build_portlet_interface

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import prepare_param_names [as 别名]
    def build_portlet_interface(self, portlet_configuration, project_id):
        """
        From a portlet_id and a project_id, first build the portlet
        entity then get it's configurable interface. 
        
        :param portlet_configuration: a portlet configuration entity. It holds at the
            least the portlet_id, and in case any default parameters were saved
            they can be rebuilt from the analyzers // visualizer parameters
        :param project_id: the id of the current project   
            
        :returns: the portlet interface will be of the following form::
            [{'interface': adapter_interface, 
            'prefix': prefix_for_parameter_names, 
            'subalg': {algorithm_field_name: default_algorithm_value},
            'algo_group': algorithm_group,
            'alg_ui_name': displayname},
            ......]
            A list of dictionaries for each adapter that makes up the portlet.
            
        """
        portlet_configurer = self._get_portlet_configurer(portlet_configuration.portlet_id)
        portlet_interface = portlet_configurer.get_configurable_interface()

        for adapter_conf in portlet_interface:
            interface = adapter_conf.interface
            itree_mngr = InputTreeManager()
            interface = itree_mngr.fill_input_tree_with_options(interface, project_id,
                                                                adapter_conf.stored_adapter.fk_category)
            adapter_conf.interface = itree_mngr.prepare_param_names(interface)

        portlet_configurer.update_default_values(portlet_interface, portlet_configuration)
        portlet_configurer.prefix_adapters_parameters(portlet_interface)

        return portlet_interface
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:36,代码来源:burst_service.py

示例3: prepare_param_names

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import prepare_param_names [as 别名]
 def prepare_param_names(attributes_list, prefix=None, add_option_prefix=False):
     """
     For a given attribute list, change the name of the attributes where needed.
     Changes refer to adding a prefix, to identify groups.
     Will be used on parameters page GET.
     """
     return InputTreeManager.prepare_param_names(attributes_list, prefix, add_option_prefix)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:9,代码来源:abcadapter.py

示例4: prepare_ui_inputs

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import prepare_param_names [as 别名]
 def prepare_ui_inputs(self, kwargs, validation_required=True):
     """
     Prepare the inputs received from a HTTP Post in a form that will be
     used by the Python adapter.
     """
     algorithm_inputs = self.get_input_tree()
     algorithm_inputs = InputTreeManager.prepare_param_names(algorithm_inputs)
     self.tree_manager.append_required_defaults(kwargs, algorithm_inputs)
     return self.convert_ui_inputs(kwargs, validation_required=validation_required)
开发者ID:transpersonify,项目名称:tvb-framework,代码行数:11,代码来源:abcadapter.py

示例5: index

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import prepare_param_names [as 别名]
    def index(self):
        dynamic_gid = utils.generate_guid()
        adapter = _LeftFragmentAdapter(self.available_models)
        input_tree = adapter.get_input_tree()
        #WARN: If this input tree will contain data type references then to render it correctly we have to use fill_input_tree_with_options
        input_tree = InputTreeManager.prepare_param_names(input_tree)

        integrator_adapter = _IntegratorFragmentAdapter()
        integrator_input_tree = integrator_adapter.get_input_tree()
        integrator_input_tree  = InputTreeManager.prepare_param_names(integrator_input_tree)

        params = {
            'title': "Dynamic model",
            'mainContent': 'burst/dynamic',
            'input_tree': input_tree,
            'integrator_input_tree': integrator_input_tree,
            'dynamic_gid': dynamic_gid
        }
        self.fill_default_attributes(params)

        dynamic = self.get_cached_dynamic(dynamic_gid)
        self._configure_integrator_noise(dynamic.integrator, dynamic.model)
        return params
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:25,代码来源:dynamic_model_controller.py

示例6: test_multidimensional_array

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import prepare_param_names [as 别名]
 def test_multidimensional_array(self):
     """
     Test the generation of a multi-dimensional array.
     """
     input_tree = TraitAdapter().get_input_tree()
     input_tree = InputTreeManager.prepare_param_names(input_tree)
     self.template_specification['inputList'] = input_tree
     resulted_html = _template2string(self.template_specification)
     soup = BeautifulSoup(resulted_html)
     #Find dictionary div which should be dict_+${dict_var_name}
     dict_div = soup.find_all('div', attrs=dict(id="dict_test_dict"))
     assert len(dict_div) == 1, 'Dictionary div not found'
     dict_entries = soup.find_all('input', attrs=dict(name=re.compile('^test_dict_parameters*')))
     assert len(dict_entries) == 2, 'Not all entries found'
     for i in range(2):
         if dict_entries[i]['name'] == "test_dict_parameters_W":
             assert dict_entries[0]['value'] == "-6.0", "Incorrect values"
         if dict_entries[i]['name'] == "test_dict_parameters_V":
             assert dict_entries[1]['value'] == "-3.0", "Incorrect values"
     array_entry = soup.find_all('input', attrs=dict(name='test_array'))
     assert len(array_entry) == 1, 'Array entry not found'
     assert array_entry[0]['value'] == "[[-3.0, -6.0], [3.0, 6.0]]", "Wrong value stored"
开发者ID:the-virtual-brain,项目名称:tvb-framework,代码行数:24,代码来源:genshi_test.py

示例7: __init__

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import prepare_param_names [as 别名]
class FlowService:
    """
    Service Layer for all TVB generic Work-Flow operations.
    """

    def __init__(self):
        self.logger = get_logger(self.__class__.__module__)
        self.file_helper = FilesHelper()
        self.input_tree_manager = InputTreeManager()
    
    def get_category_by_id(self, identifier):
        """ Pass to DAO the retrieve of category by ID operation."""
        return dao.get_category_by_id(identifier)
    
    @staticmethod
    def get_raw_categories():
        """:returns: AlgorithmCategory list of entities that have results in RAW state (Creators/Uploaders)"""
        return dao.get_raw_categories()
    
    @staticmethod
    def get_visualisers_category():
        """Retrieve all Algorithm categories, with display capability"""
        result = dao.get_visualisers_categories()
        if not result:
            raise ValueError("View Category not found!!!")
        return result[0]
    
    @staticmethod
    def get_algorithm_by_identifier(ident):
        """
        Retrieve Algorithm entity by ID.
        Return None, if ID is not found in DB.
        """
        return dao.get_algorithm_by_id(ident)

    
    @staticmethod
    def load_operation(operation_id):
        """ Retrieve previously stored Operation from DB, and load operation.burst attribute"""
        operation = dao.get_operation_by_id(operation_id)
        operation.burst = dao.get_burst_for_operation_id(operation_id)
        return operation


    @staticmethod
    def get_operation_numbers(proj_id):
        """ Count total number of operations started for current project. """
        return dao.get_operation_numbers(proj_id)
              

    def prepare_adapter(self, project_id, stored_adapter):
        """
        Having a  StoredAdapter, return the Tree Adapter Interface object, populated with datatypes from 'project_id'.
        """
        adapter_module = stored_adapter.module
        adapter_name = stored_adapter.classname
        try:
            # Prepare Adapter Interface, by populating with existent data,
            # in case of a parameter of type DataType.
            adapter_instance = ABCAdapter.build_adapter(stored_adapter)
            interface = adapter_instance.get_input_tree()
            interface = self.input_tree_manager.fill_input_tree_with_options(interface, project_id, stored_adapter.fk_category)
            interface = self.input_tree_manager.prepare_param_names(interface)
            return interface
        except Exception:
            self.logger.exception('Not found:' + adapter_name + ' in:' + adapter_module)
            raise OperationException("Could not prepare " + adapter_name)
    
    
    @staticmethod
    def get_algorithm_by_module_and_class(module, classname):
        """
        Get the db entry from the algorithm table for the given module and 
        class.
        """
        return dao.get_algorithm_by_module(module, classname)
    
    
    @staticmethod
    def get_available_datatypes(project_id, data_type_cls, filters=None):
        """
        Return all dataTypes that match a given name and some filters.
        :param data_type_cls: either a fully qualified class name or a class object
        """
        return get_filtered_datatypes(project_id, data_type_cls, filters)


    @staticmethod
    def create_link(data_ids, project_id):
        """
        For a list of dataType IDs and a project id create all the required links.
        """
        for data in data_ids:
            link = model.Links(data, project_id)
            dao.store_entity(link)


    @staticmethod
    def remove_link(dt_id, project_id):
        """
#.........这里部分代码省略.........
开发者ID:the-virtual-brain,项目名称:tvb-framework,代码行数:103,代码来源:flow_service.py

示例8: __init__

# 需要导入模块: from tvb.core.adapters.input_tree import InputTreeManager [as 别名]
# 或者: from tvb.core.adapters.input_tree.InputTreeManager import prepare_param_names [as 别名]
class FlowService:
    """
    Service Layer for all TVB generic Work-Flow operations.
    """

    def __init__(self):
        self.logger = get_logger(self.__class__.__module__)
        self.file_helper = FilesHelper()
        self.input_tree_manager = InputTreeManager()
    
    def get_category_by_id(self, identifier):
        """ Pass to DAO the retrieve of category by ID operation."""
        return dao.get_category_by_id(identifier)
    
    @staticmethod
    def get_raw_categories():
        """:returns: AlgorithmCategory list of entities that have results in RAW state (Creators/Uploaders)"""
        return dao.get_raw_categories()
    
    @staticmethod
    def get_visualisers_category():
        """Retrieve all Algorithm categories, with display capability"""
        result = dao.get_visualisers_categories()
        if not result:
            raise ValueError("View Category not found!!!")
        return result[0]
    
    @staticmethod
    def get_algorithm_by_identifier(ident):
        """
        Retrieve Algorithm entity by ID.
        Return None, if ID is not found in DB.
        """
        return dao.get_algorithm_by_id(ident)

    
    @staticmethod
    def load_operation(operation_id):
        """ Retrieve previously stored Operation from DB, and load operation.burst attribute"""
        operation = dao.get_operation_by_id(operation_id)
        operation.burst = dao.get_burst_for_operation_id(operation_id)
        return operation


    @staticmethod
    def get_operation_numbers(proj_id):
        """ Count total number of operations started for current project. """
        return dao.get_operation_numbers(proj_id)
              

    def prepare_adapter(self, project_id, stored_adapter):
        """
        Having a  StoredAdapter, return the Tree Adapter Interface object, populated with datatypes from 'project_id'.
        """
        adapter_module = stored_adapter.module
        adapter_name = stored_adapter.classname
        try:
            # Prepare Adapter Interface, by populating with existent data,
            # in case of a parameter of type DataType.
            adapter_instance = ABCAdapter.build_adapter(stored_adapter)
            interface = adapter_instance.get_input_tree()
            interface = self.input_tree_manager.fill_input_tree_with_options(interface, project_id, stored_adapter.fk_category)
            interface = self.input_tree_manager.prepare_param_names(interface)
            return interface
        except Exception:
            self.logger.exception('Not found:' + adapter_name + ' in:' + adapter_module)
            raise OperationException("Could not prepare " + adapter_name)
    
    
    @staticmethod
    def get_algorithm_by_module_and_class(module, classname):
        """
        Get the db entry from the algorithm table for the given module and 
        class.
        """
        return dao.get_algorithm_by_module(module, classname)
    
    
    @staticmethod
    def get_available_datatypes(project_id, data_type_cls, filters=None):
        """
        Return all dataTypes that match a given name and some filters.
        :param data_type_cls: either a fully qualified class name or a class object
        """
        return get_filtered_datatypes(project_id, data_type_cls, filters)


    @staticmethod
    def create_link(data_ids, project_id):
        """
        For a list of dataType IDs and a project id create all the required links.
        """
        for data in data_ids:
            link = model.Links(data, project_id)
            dao.store_entity(link)


    @staticmethod
    def remove_link(dt_id, project_id):
        """
#.........这里部分代码省略.........
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:103,代码来源:flow_service.py


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