當前位置: 首頁>>代碼示例>>Python>>正文


Python ComponentIDComboHelper.append_data方法代碼示例

本文整理匯總了Python中glue.core.data_combo_helper.ComponentIDComboHelper.append_data方法的典型用法代碼示例。如果您正苦於以下問題:Python ComponentIDComboHelper.append_data方法的具體用法?Python ComponentIDComboHelper.append_data怎麽用?Python ComponentIDComboHelper.append_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在glue.core.data_combo_helper.ComponentIDComboHelper的用法示例。


在下文中一共展示了ComponentIDComboHelper.append_data方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from glue.core.data_combo_helper import ComponentIDComboHelper [as 別名]
# 或者: from glue.core.data_combo_helper.ComponentIDComboHelper import append_data [as 別名]
    def __init__(self, function, data_in=None, data_out=None, cids_in=None,
                 cids_out=None, input_names=None, output_names=None,
                 display=None, description=None):

        super(EditableLinkFunctionState, self).__init__()

        if isinstance(function, ComponentLink):
            self._function = function.get_using()
            self._inverse = function.get_inverse()
            self._helper_class = None
            cids_in = function.get_from_ids()
            cids_out = function.get_to_ids()
            data_in = cids_in[0].parent
            data_out = cids_out[0].parent
            self.display = self._function.__name__
            self.description = function.description
        elif isinstance(function, LinkCollection):
            self._function = None
            self._helper_class = function.__class__
            cids_in = function.cids1
            cids_out = function.cids2
            data_in = cids_in[0].parent

            # To be backward-compatible with cases where @link_helper doesn't
            # include output labels, we need to assume cids_out can be empty
            # in which case we look for the second dataset inside cids_in
            if len(cids_out) > 0:
                data_out = cids_out[0].parent
            else:
                for cid in cids_in[1:]:
                    if cid.parent is not data_in:
                        data_out = cid.parent
                        break
                else:
                    raise ValueError("Could not determine second dataset in link")

            self.display = function.display
            self.description = function.description
            self._mode = 'helper'
        elif type(function) is type and issubclass(function, LinkCollection):
            self._function = None
            self._helper_class = function
            self.display = function.display
            self.description = function.description
        elif isinstance(function, (FunctionType, MethodType)):
            self._function = function
            self._inverse = None
            self._helper_class = None
            self.inverse = None
            self.display = display
            self.description = description
        else:
            raise TypeError("Unexpected type for 'function': {0}".format(type(function)))

        self.data_in = data_in
        self.data_out = data_out

        for name in self.input_names:
            helper = ComponentIDComboHelper(self, name,
                                            pixel_coord=True, world_coord=True)
            helper.append_data(data_in)
            helper.append_data(data_out)

            setattr(self, '_' + name + '_helper', helper)

        for name in self.output_names:
            helper = ComponentIDComboHelper(self, name,
                                            pixel_coord=True, world_coord=True)
            helper.append_data(data_out)
            helper.append_data(data_in)
            setattr(self, '_' + name + '_helper', helper)

        if cids_in is not None:
            for name, cid in zip(self.input_names, cids_in):
                setattr(self, name, cid)

        if cids_out is not None:
            for name, cid in zip(self.output_names, cids_out):
                setattr(self, name, cid)
開發者ID:glue-viz,項目名稱:glue,代碼行數:81,代碼來源:state.py


注:本文中的glue.core.data_combo_helper.ComponentIDComboHelper.append_data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。