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


Python qt.GlueApplication类代码示例

本文整理汇总了Python中glue.app.qt.GlueApplication的典型用法代码示例。如果您正苦于以下问题:Python GlueApplication类的具体用法?Python GlueApplication怎么用?Python GlueApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _load_data

    def _load_data(self):
        """ Interactively loads data from a data set. Adds
        as new layer """
        from glue.app.qt import GlueApplication

        layers = data_wizard()
        GlueApplication.add_datasets(self.data_collection, layers)
开发者ID:sergiopasra,项目名称:glue,代码行数:7,代码来源:layer_tree_widget.py

示例2: test_table_widget_session_no_subset

def test_table_widget_session_no_subset(tmpdir):

    # Regression test for a bug that caused table viewers with no subsets to
    # not be restored correctly and instead raise an exception.

    app = get_qapp()  # noqa

    d = Data(a=[1, 2, 3, 4, 5],
             b=[3.2, 1.2, 4.5, 3.3, 2.2],
             c=['e', 'b', 'c', 'a', 'f'], label='test')

    dc = DataCollection([d])

    gapp = GlueApplication(dc)

    widget = gapp.new_data_viewer(TableViewer)
    widget.add_data(d)

    session_file = tmpdir.join('table.glu').strpath

    gapp.save_session(session_file)

    gapp2 = GlueApplication.restore_session(session_file)
    gapp2.show()

    gapp2.data_collection[0]
    gapp2.viewers[0][0]
开发者ID:glue-viz,项目名称:glue,代码行数:27,代码来源:test_data_viewer.py

示例3: _create_glue_app

def _create_glue_app(data_collection, hub):
    session = glue.core.Session(data_collection=data_collection, hub=hub)
    ga = GlueApplication(session=session)
    ga.setWindowTitle('cubeviz ({})'.format(cubeviz_version))
    qapp = QtWidgets.QApplication.instance()
    qapp.setWindowIcon(QtGui.QIcon(CUBEVIZ_ICON_PATH))
    ga.setWindowIcon(QtGui.QIcon(CUBEVIZ_ICON_PATH))
    return ga
开发者ID:spacetelescope,项目名称:cube-tools,代码行数:8,代码来源:cubeviz.py

示例4: _create_glue_app

def _create_glue_app(data_collection, hub):
    session = glue.core.Session(data_collection=data_collection, hub=hub)
    ga = GlueApplication(session=session)
    qapp = QtWidgets.QApplication.instance()
    ga.setWindowTitle('MOSViz v{0}'.format(__version__))
    qapp.setWindowIcon(QtGui.QIcon(MOSVIZ_ICON_PATH))
    ga.setWindowIcon(QtGui.QIcon(MOSVIZ_ICON_PATH))
    return ga
开发者ID:spacetelescope,项目名称:mosviz,代码行数:8,代码来源:cli.py

示例5: test_state_save_with_data_layers

def test_state_save_with_data_layers():
    app = GlueApplication()
    dc = app.data_collection
    d = Data(x=[1, 2, 3], label='test')
    dc.append(d)
    w = app.new_data_viewer(viewer._widget_cls)
    w.add_data(d)
    check_clone_app(app)
开发者ID:saimn,项目名称:glue,代码行数:8,代码来源:test_custom_viewer.py

示例6: qglue

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,代码行数:57,代码来源:qglue.py

示例7: test_save_load

 def test_save_load(self):
     app = GlueApplication(session=self.session)
     w = app.new_data_viewer(self.viewer._viewer_cls)
     v = w._coordinator
     roi = None
     s = CustomSubsetState(v, roi)
     app.data_collection.new_subset_group(subset_state=s, label='test')
     app2 = clone(app)
     s2 = app2.data_collection[0].subsets[0].subset_state
     assert_array_equal(s2.to_mask(self.data), [False, True, True])
开发者ID:sergiopasra,项目名称:glue,代码行数:10,代码来源:test_custom_viewer.py

示例8: test_cube

    def test_cube(self):
        d = core.Data(label='cube',
                      x=np.zeros((2, 2, 2)))
        dc = core.DataCollection([d])
        app = GlueApplication(dc)
        w = app.new_data_viewer(ImageWidget, d)
        w.slice = ('x', 'y', 1)
        assert w.slice == ('x', 'y', 1)

        c = self.check_clone(app)
        w2 = c.viewers[0][0]
        assert w2.ui.slice.slice == w.slice
开发者ID:bmorris3,项目名称:glue,代码行数:12,代码来源:test_viewer_widget.py

示例9: start_glue

def start_glue(gluefile=None, config=None, datafiles=None, maximized=True):
    """Run a glue session and exit

    Parameters
    ----------
    gluefile : str
        An optional ``.glu`` file to restore.

    config : str
        An optional configuration file to use.

    datafiles : str
        An optional list of data files to load.

    maximized : bool
        Maximize screen on startup. Otherwise, use default size.

    """
    import glue
    from glue.app.qt import GlueApplication

    # Start off by loading plugins. We need to do this before restoring
    # the session or loading the configuration since these may use existing
    # plugins.
    load_plugins()

    datafiles = datafiles or []

    hub = None

    if gluefile is not None:
        app = restore_session(gluefile)
        return app.start()

    if config is not None:
        glue.env = glue.config.load_configuration(search_path=[config])

    data_collection = glue.core.DataCollection()
    hub = data_collection.hub

    session = glue.core.Session(data_collection=data_collection, hub=hub)
    ga = GlueApplication(session=session, maximized=maximized)

    if datafiles:
        datasets = load_data_files(datafiles)
        ga.add_datasets(data_collection, datasets)

    # ga.show()
    # splash.close()
    # ga.raise_()
    # QApplication.instance().processEvents()
    return ga.start()
开发者ID:astrofrog,项目名称:glue,代码行数:52,代码来源:main.py

示例10: test_close_on_last_layer_remove

    def test_close_on_last_layer_remove(self):
        # regression test for 391

        d1 = Data(x=np.random.random((2,) * self.ndim))
        d2 = Data(y=np.random.random((2,) * self.ndim))
        dc = DataCollection([d1, d2])
        app = GlueApplication(dc)
        with patch.object(self.widget_cls, 'close') as close:
            w = app.new_data_viewer(self.widget_cls, data=d1)
            w.add_data(d2)
            dc.remove(d1)
            dc.remove(d2)
        assert close.call_count >= 1
开发者ID:astrofrog,项目名称:glue,代码行数:13,代码来源:test_data_viewer.py

示例11: setup_class

    def setup_class(self):

        data = Data(x=[1, 2, 3], y=[2, 3, 4], label='data')
        dc = DataCollection([data])
        app = GlueApplication(dc)

        data.style.color = '#000000'
        v = app.new_data_viewer(HistogramWidget, data=data)
        v.component = data.id['y']
        v.xmin = 0
        v.xmax = 10
        v.bins = 20

        self.args, self.kwargs = build_plotly_call(app)
开发者ID:astrofrog,项目名称:glue,代码行数:14,代码来源:test_exporter.py

示例12: TestDataTableModel

class TestDataTableModel():

    def setup_method(self, method):
        self.gapp = GlueApplication()
        self.viewer = self.gapp.new_data_viewer(TableViewer)
        self.data = Data(x=[1, 2, 3, 4], y=[2, 3, 4, 5])
        self.gapp.data_collection.append(self.data)
        self.viewer.add_data(self.data)
        self.model = DataTableModel(self.viewer)

    def teardown_method(self, method):
        self.gapp.close()
        self.gapp = None

    def test_column_count(self):
        assert self.model.columnCount() == 2

    def test_column_count_hidden(self):
        self.model.show_coords = True
        assert self.model.columnCount() == 4

    def test_header_data(self):
        for i, c in enumerate(self.data.main_components):
            result = self.model.headerData(i, Qt.Horizontal, Qt.DisplayRole)
            assert result == c.label

        for i in range(self.data.size):
            result = self.model.headerData(i, Qt.Vertical, Qt.DisplayRole)
            assert result == str(i)

    def test_row_count(self):
        assert self.model.rowCount() == 4

    def test_data(self):
        for i, c in enumerate(self.data.main_components):
            for j in range(self.data.size):
                idx = self.model.index(j, i)
                result = self.model.data(idx, Qt.DisplayRole)
                assert float(result) == self.data[c, j]

    @pytest.mark.xfail
    def test_data_2d(self):
        self.data = Data(x=[[1, 2], [3, 4]], y=[[2, 3], [4, 5]])
        self.model = DataTableModel(self.data)
        for i, c in enumerate(self.data.main_components):
            for j in range(self.data.size):
                idx = self.model.index(j, i)
                result = self.model.data(idx, Qt.DisplayRole)
                assert float(result) == self.data[c].ravel()[j]
开发者ID:glue-viz,项目名称:glue,代码行数:49,代码来源:test_data_viewer.py

示例13: setup_method

 def setup_method(self, method):
     self.gapp = GlueApplication()
     self.viewer = self.gapp.new_data_viewer(TableViewer)
     self.data = Data(x=[1, 2, 3, 4], y=[2, 3, 4, 5])
     self.gapp.data_collection.append(self.data)
     self.viewer.add_data(self.data)
     self.model = DataTableModel(self.viewer)
开发者ID:glue-viz,项目名称:glue,代码行数:7,代码来源:test_data_viewer.py

示例14: setup_method

    def setup_method(self, method):

        self.coords = MyCoords()
        self.image1 = Data(label='image1', x=[[1, 2], [3, 4]], y=[[4, 5], [2, 3]])
        self.image2 = Data(label='image2', a=[[3, 3], [2, 2]], b=[[4, 4], [3, 2]],
                           coords=self.coords)
        self.catalog = Data(label='catalog', c=[1, 3, 2], d=[4, 3, 3])
        self.hypercube = Data(label='hypercube', x=np.arange(120).reshape((2, 3, 4, 5)))

        # Create data versions with WCS coordinates
        self.image1_wcs = Data(label='image1_wcs', x=self.image1['x'],
                               coords=WCSCoordinates(wcs=WCS(naxis=2)))
        self.hypercube_wcs = Data(label='hypercube_wcs', x=self.hypercube['x'],
                                  coords=WCSCoordinates(wcs=WCS(naxis=4)))

        self.application = GlueApplication()

        self.session = self.application.session

        self.hub = self.session.hub

        self.data_collection = self.session.data_collection
        self.data_collection.append(self.image1)
        self.data_collection.append(self.image2)
        self.data_collection.append(self.catalog)
        self.data_collection.append(self.hypercube)
        self.data_collection.append(self.image1_wcs)
        self.data_collection.append(self.hypercube_wcs)

        self.viewer = self.application.new_data_viewer(ImageViewer)

        self.data_collection.register_to_hub(self.hub)
        self.viewer.register_to_hub(self.hub)

        self.options_widget = self.viewer.options_widget()
开发者ID:jzuhone,项目名称:glue,代码行数:35,代码来源:test_data_viewer.py

示例15: test_single_draw_call_on_create

    def test_single_draw_call_on_create(self):
        d = Data(x=np.random.random((2,) * self.ndim))
        dc = DataCollection([d])
        app = GlueApplication(dc)

        try:
            from glue.viewers.common.qt.mpl_widget import MplCanvas
            draw = MplCanvas.draw
            MplCanvas.draw = MagicMock()

            app.new_data_viewer(self.widget_cls, data=d)

            # each Canvas instance gives at most 1 draw call
            selfs = [c[0][0] for c in MplCanvas.draw.call_arg_list]
            assert len(set(selfs)) == len(selfs)
        finally:
            MplCanvas.draw = draw
开发者ID:astrofrog,项目名称:glue,代码行数:17,代码来源:test_data_viewer.py


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