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


Python DataCollection.extend方法代码示例

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


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

示例1: qglue

# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import extend [as 别名]
def qglue(**kwargs):
    """
    Quickly send python variables to Glue for visualization.

    The generic calling sequence is::

      qglue(label1=data1, label2=data2, ..., [links=links])

    The kewyords label1, label2, ... can be named anything besides ``links``

    data1, data2, ... can be in many formats:
      * A pandas data frame
      * A path to a file
      * A numpy array, or python list
      * A numpy rec array
      * A dictionary of numpy arrays with the same shape
      * An astropy Table

    ``Links`` is an optional list of link descriptions, each of which has
    the format: ([left_ids], [right_ids], forward, backward)

    Each ``left_id``/``right_id`` is a string naming a component in a dataset
    (i.e., ``data1.x``). ``forward`` and ``backward`` are functions which
    map quantities on the left to quantities on the right, and vice
    versa. `backward` is optional

    Examples::

        balls = {'kg': [1, 2, 3], 'radius_cm': [10, 15, 30]}
        cones = {'lbs': [5, 3, 3, 1]}
        def lb2kg(lb):
            return lb / 2.2
        def kg2lb(kg):
            return kg * 2.2

        links = [(['balls.kg'], ['cones.lbs'], lb2kg, kg2lb)]
        qglue(balls=balls, cones=cones, links=links)

    :returns: A :class:`~glue.app.qt.application.GlueApplication` object
    """
    from glue.core import DataCollection
    from glue.app.qt import GlueApplication

    links = kwargs.pop('links', None)

    dc = DataCollection()
    for label, data in kwargs.items():
        dc.extend(parse_data(data, label))

    if links is not None:
        dc.add_link(parse_links(dc, links))

    with restore_io():
        ga = GlueApplication(dc)
        ga.start()

    return ga
开发者ID:glue-viz,项目名称:glue,代码行数:59,代码来源:qglue.py

示例2: LabeledDelegate

# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import extend [as 别名]
class LabeledDelegate(QtWidgets.QStyledItemDelegate):

    """ Add placeholder text to default delegate """

    def setEditorData(self, editor, index):
        super(LabeledDelegate, self).setEditorData(editor, index)
        label = index.model().data(index, role=Qt.DisplayRole)
        editor.selectAll()
        editor.setText(label)


if __name__ == "__main__":

    from glue.utils.qt import get_qapp
    from qtpy import QtWidgets
    from glue.core import Data, DataCollection

    app = get_qapp()

    dc = DataCollection()
    dc.append(Data(label='w'))

    view = DataCollectionView()
    view.set_data_collection(dc)
    view.show()
    view.raise_()
    dc.extend([Data(label='x', x=[1, 2, 3]),
               Data(label='y', y=[1, 2, 3]),
               Data(label='z', z=[1, 2, 3])])
    app.exec_()
开发者ID:glue-viz,项目名称:glue,代码行数:32,代码来源:data_collection_model.py


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