本文整理汇总了Python中glue.app.qt.GlueApplication.new_data_viewer方法的典型用法代码示例。如果您正苦于以下问题:Python GlueApplication.new_data_viewer方法的具体用法?Python GlueApplication.new_data_viewer怎么用?Python GlueApplication.new_data_viewer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glue.app.qt.GlueApplication
的用法示例。
在下文中一共展示了GlueApplication.new_data_viewer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_table_widget_session_no_subset
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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]
示例2: test_state_save_with_data_layers
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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)
示例3: test_single_draw_call_on_create
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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
示例4: test_save_load
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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])
示例5: test_cube
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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
示例6: test_close_on_last_layer_remove
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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
示例7: test_two_custom_viewer_classes
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
def test_two_custom_viewer_classes():
class MyWidget1(CustomViewer):
text_box1_Widget1 = '_Hello'
def setup(self, text_box1_Widget1):
pass
class MyWidget2(CustomViewer):
text_box1_Widget2 = '_Hello'
text_box2_Widget2 = '_world'
def setup(self, text_box1_Widget2, text_box2_Widget2):
pass
app = GlueApplication()
dc = app.data_collection
d = Data(x=[1, 2, 3], label='test')
dc.append(d)
app.new_data_viewer(MyWidget1._widget_cls)
app.new_data_viewer(MyWidget2._widget_cls)
示例8: setup_class
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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)
示例9: TestDataTableModel
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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]
示例10: test_close_on_last_layer_remove
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
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)
w = app.new_data_viewer(self.widget_cls, data=d1)
w.add_data(d2)
process_events()
assert len(app.viewers[0]) == 1
dc.remove(d1)
process_events()
assert len(app.viewers[0]) == 1
dc.remove(d2)
process_events()
assert len(app.viewers[0]) == 0
app.close()
示例11: test_options_widget
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
def test_options_widget(self):
d1 = Data(x=np.random.random((2,) * self.ndim))
d2 = Data(x=np.random.random((2,) * self.ndim))
dc = DataCollection([d1, d2])
app = GlueApplication(dc)
w = app.new_data_viewer(self.widget_cls, data=d1)
w.state.x_stretch = 0.5
w.state.y_stretch = 1.0
w.state.z_stretch = 2.0
w.state.x_min = -0.1
w.state.x_max = 10.1
w.state.y_min = 0.1
w.state.y_max = 10.9
w.state.z_min = 0.2
w.state.z_max = 10.8
w.state.visible_axes = False
示例12: setup_method
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
def setup_method(self, method):
LinkSame = core.link_helpers.LinkSame
d = core.Data(label='im', x=[[1, 2], [2, 3]], y=[[2, 3], [4, 5]])
d2 = core.Data(label='cat',
x=[0, 1, 0, 1],
y=[0, 0, 1, 1],
z=[1, 2, 3, 4])
dc = core.DataCollection([d, d2])
dc.add_link(LinkSame(d.get_pixel_component_id(0), d2.id['x']))
dc.add_link(LinkSame(d.get_pixel_component_id(1), d2.id['y']))
app = GlueApplication(dc)
w = app.new_data_viewer(ImageWidget, data=d)
self.d = d
self.app = app
self.w = w
self.d2 = d2
self.dc = dc
示例13: test_add_viewer
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
def test_add_viewer(self, tmpdir):
d1 = Data(x=np.random.random((2,) * self.ndim))
d2 = Data(x=np.random.random((2,) * self.ndim))
dc = DataCollection([d1, d2])
app = GlueApplication(dc)
w = app.new_data_viewer(self.widget_cls, data=d1)
w.viewer_size = (300, 400)
filename = tmpdir.join('session.glu').strpath
app.save_session(filename, include_data=True)
app2 = GlueApplication.restore_session(filename)
# test session is restored correctly
for viewer in app2.viewers:
assert viewer[0].viewer_size == (300, 400)
app.close()
app2.close()
示例14: test_change_components
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
def test_change_components():
# Regression test for a bug that caused table viewers to not update when
# adding/removing components. For now, this does not work with Qt 5.7.
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)
viewer = gapp.new_data_viewer(TableViewer)
viewer.add_data(d)
data_changed = MagicMock()
viewer.model.dataChanged.connect(data_changed)
# layoutChanged needs to be emitted for the new/removed columns to be
# registered (dataChanged is not enough)
layout_changed = MagicMock()
viewer.model.layoutChanged.connect(layout_changed)
assert data_changed.call_count == 0
assert layout_changed.call_count == 0
viewer.model.columnCount() == 2
d.add_component([3, 4, 5, 6, 2], 'z')
assert data_changed.call_count == 1
assert layout_changed.call_count == 1
viewer.model.columnCount() == 3
d.remove_component(d.id['z'])
assert data_changed.call_count == 2
assert layout_changed.call_count == 2
viewer.model.columnCount() == 2
示例15: test_table_title
# 需要导入模块: from glue.app.qt import GlueApplication [as 别名]
# 或者: from glue.app.qt.GlueApplication import new_data_viewer [as 别名]
def test_table_title():
app = get_qapp() # noqa
data1 = Data(a=[1, 2, 3, 4, 5], label='test1')
data2 = Data(a=[1, 2, 3, 4, 5], label='test2')
dc = DataCollection([data1, data2])
gapp = GlueApplication(dc)
viewer = gapp.new_data_viewer(TableViewer)
assert viewer.windowTitle() == 'Table'
viewer.add_data(data1)
assert viewer.windowTitle() == 'Table: test1'
viewer.add_data(data2)
assert viewer.windowTitle() == 'Table: test2'