本文整理汇总了Python中glue.core.DataCollection.remove方法的典型用法代码示例。如果您正苦于以下问题:Python DataCollection.remove方法的具体用法?Python DataCollection.remove怎么用?Python DataCollection.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glue.core.DataCollection
的用法示例。
在下文中一共展示了DataCollection.remove方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_data_collection_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [as 别名]
def test_data_collection_combo_helper():
callback = MagicMock()
state = ExampleState()
state.add_callback('combo', callback)
dc = DataCollection([])
helper = DataCollectionComboHelper(state, 'combo', dc) # noqa
data1 = Data(x=[1, 2, 3], y=[2, 3, 4], label='data1')
assert callback.call_count == 0
dc.append(data1)
assert callback.call_count == 1
assert selection_choices(state, 'combo') == "data1"
data1.label = 'mydata1'
assert selection_choices(state, 'combo') == "mydata1"
assert callback.call_count == 2
dc.remove(data1)
assert callback.call_count == 3
assert selection_choices(state, 'combo') == ""
示例2: test_close_on_last_layer_remove
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [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
示例3: test_component_id_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [as 别名]
def test_component_id_combo_helper():
combo = QtWidgets.QComboBox()
dc = DataCollection([])
helper = ComponentIDComboHelper(combo, dc)
assert _items_as_string(combo) == ""
data1 = Data(x=[1,2,3], y=[2,3,4], label='data1')
dc.append(data1)
helper.append_data(data1)
assert _items_as_string(combo) == "x:y"
data2 = Data(a=[1,2,3], b=['a','b','c'], label='data2')
dc.append(data2)
helper.append_data(data2)
assert _items_as_string(combo) == "data1:x:y:data2:a:b"
helper.categorical = False
assert _items_as_string(combo) == "data1:x:y:data2:a"
helper.numeric = False
assert _items_as_string(combo) == "data1:data2"
helper.categorical = True
helper.numeric = True
helper.visible = False
assert _items_as_string(combo) == "data1:Pixel Axis 0 [x]:World 0:x:y:data2:Pixel Axis 0 [x]:World 0:a:b"
helper.visible = True
dc.remove(data2)
assert _items_as_string(combo) == "x:y"
# TODO: check that renaming a component updates the combo
# data1.id['x'].label = 'z'
# assert _items_as_string(combo) == "z:y"
helper.remove_data(data1)
assert _items_as_string(combo) == ""
示例4: test_close_on_last_layer_remove
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [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()
示例5: test_data_collection_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [as 别名]
def test_data_collection_combo_helper():
combo = QtWidgets.QComboBox()
dc = DataCollection([])
helper = DataCollectionComboHelper(combo, dc)
data1 = Data(x=[1,2,3], y=[2,3,4], label='data1')
dc.append(data1)
assert _items_as_string(combo) == "data1"
data1.label = 'mydata1'
assert _items_as_string(combo) == "mydata1"
dc.remove(data1)
assert _items_as_string(combo) == ""
示例6: test_manual_data_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [as 别名]
def test_manual_data_combo_helper(initialize_data_collection):
# The case with initialize_data_collection=False is a regression test for a
# bug which meant that when a ManualDataComboHelper was initialized without
# a data collection, it did not change when a data object added later has a
# label changed.
callback = MagicMock()
state = ExampleState()
state.add_callback('combo', callback)
dc = DataCollection([])
if initialize_data_collection:
helper = ManualDataComboHelper(state, 'combo', dc)
else:
helper = ManualDataComboHelper(state, 'combo')
data1 = Data(x=[1, 2, 3], y=[2, 3, 4], label='data1')
dc.append(data1)
assert callback.call_count == 0
assert selection_choices(state, 'combo') == ""
helper.append_data(data1)
assert callback.call_count == 1
assert selection_choices(state, 'combo') == "data1"
data1.label = 'mydata1'
assert selection_choices(state, 'combo') == "mydata1"
assert callback.call_count == 2
if initialize_data_collection:
dc.remove(data1)
assert selection_choices(state, 'combo') == ""
assert callback.call_count == 3
示例7: test_close_on_last_layer_remove
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [as 别名]
def test_close_on_last_layer_remove(self):
# regression test for 391
# Note: processEvents is needed for things to work correctly with PySide2
qtapp = get_qapp()
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)
qtapp.processEvents()
assert len(app.viewers[0]) == 1
dc.remove(d1)
qtapp.processEvents()
assert len(app.viewers[0]) == 1
dc.remove(d2)
qtapp.processEvents()
assert len(app.viewers[0]) == 0
app.close()
示例8: test_component_id_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [as 别名]
def test_component_id_combo_helper():
state = ExampleState()
dc = DataCollection([])
helper = ComponentIDComboHelper(state, 'combo', dc)
assert selection_choices(state, 'combo') == ""
data1 = Data(x=[1, 2, 3], y=[2, 3, 4], label='data1')
dc.append(data1)
helper.append_data(data1)
assert selection_choices(state, 'combo') == "x:y"
data2 = Data(a=[1, 2, 3], b=['a', 'b', 'c'], label='data2')
dc.append(data2)
helper.append_data(data2)
assert selection_choices(state, 'combo') == "data1:x:y:data2:a:b"
helper.categorical = False
assert selection_choices(state, 'combo') == "data1:x:y:data2:a"
helper.numeric = False
assert selection_choices(state, 'combo') == "data1:data2"
helper.categorical = True
helper.numeric = True
helper.pixel_coord = True
assert selection_choices(state, 'combo') == "data1:main:x:y:coord:Pixel Axis 0 [x]:data2:main:a:b:coord:Pixel Axis 0 [x]"
helper.world_coord = True
assert selection_choices(state, 'combo') == "data1:main:x:y:coord:Pixel Axis 0 [x]:World 0:data2:main:a:b:coord:Pixel Axis 0 [x]:World 0"
helper.pixel_coord = False
assert selection_choices(state, 'combo') == "data1:main:x:y:coord:World 0:data2:main:a:b:coord:World 0"
helper.world_coord = False
dc.remove(data2)
assert selection_choices(state, 'combo') == "x:y"
data1['z'] = data1.id['x'] + 1
assert selection_choices(state, 'combo') == "main:x:y:derived:z"
helper.derived = False
assert selection_choices(state, 'combo') == "x:y"
data1.id['x'].label = 'z'
assert selection_choices(state, 'combo') == "z:y"
helper.remove_data(data1)
assert selection_choices(state, 'combo') == ""
示例9: TestDendroClient
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [as 别名]
class TestDendroClient():
def setup_method(self, method):
self.data = Data(parent=[4, 4, 5, 5, 5, -1],
height=[5, 4, 3, 2, 1, 0],
label='dendro')
self.dc = DataCollection([self.data])
self.hub = self.dc.hub
self.client = DendroClient(self.dc, figure=FIGURE)
EditSubsetMode().data_collection = self.dc
def add_subset_via_hub(self):
self.connect()
self.client.add_layer(self.data)
s = self.data.new_subset()
return s
def connect(self):
self.client.register_to_hub(self.hub)
self.dc.register_to_hub(self.hub)
def click(self, x, y):
roi = PointROI(x=x, y=y)
self.client.apply_roi(roi)
def test_data_present_after_adding(self):
assert self.data not in self.client
self.client.add_layer(self.data)
assert self.data in self.client
def test_add_data_adds_subsets(self):
s1 = self.data.new_subset()
self.client.add_layer(self.data)
assert s1 in self.client
def test_remove_data(self):
self.client.add_layer(self.data)
self.client.remove_layer(self.data)
assert self.data not in self.client
def test_remove_data_removes_subsets(self):
s = self.data.new_subset()
self.client.add_layer(self.data)
self.client.remove_layer(self.data)
assert s not in self.client
def test_add_subset_hub(self):
s = self.add_subset_via_hub()
assert s in self.client
def test_new_subset_autoadd(self):
self.connect()
self.client.add_layer(self.data)
s = self.data.new_subset()
assert s in self.client
def test_remove_subset_hub(self):
s = self.add_subset_via_hub()
s.delete()
assert s not in self.client
def test_subset_sync(self):
s = self.add_subset_via_hub()
self.client._update_layer = MagicMock()
s.style.color = 'blue'
self.client._update_layer.assert_called_once_with(s)
def test_data_sync(self):
self.connect()
self.client.add_layer(self.data)
self.client._update_layer = MagicMock()
self.data.style.color = 'blue'
self.client._update_layer.assert_called_once_with(self.data)
def test_data_remove(self):
s = self.add_subset_via_hub()
self.dc.remove(self.data)
assert self.data not in self.dc
assert self.data not in self.client
assert s not in self.client
def test_log(self):
self.client.ylog = True
assert self.client.axes.get_yscale() == 'log'
def test_1d_data_required(self):
d = Data(x=[[1, 2], [2, 3]])
self.dc.append(d)
self.client.add_layer(d)
assert d not in self.client
#.........这里部分代码省略.........
示例10: setup_method
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import remove [as 别名]
class TestLinkEditor:
def setup_method(self, method):
self.data1 = Data(x=[1, 2, 3], y=[2, 3, 4], z=[6, 5, 4], label='data1')
self.data2 = Data(a=[2, 3, 4], b=[4, 5, 4], c=[3, 4, 1], label='data2')
self.data3 = Data(i=[5, 4, 3], j=[2, 2, 1], label='data3')
self.data_collection = DataCollection([self.data1, self.data2, self.data3])
def test_defaults(self):
# Make sure the dialog opens and closes and check default settings.
dialog = LinkEditor(self.data_collection)
dialog.show()
link_widget = dialog.link_widget
assert link_widget.state.data1 is None
assert link_widget.state.data2 is None
assert not link_widget.button_add_link.isEnabled()
assert not link_widget.button_remove_link.isEnabled()
link_widget.state.data1 = self.data2
assert not link_widget.button_add_link.isEnabled()
assert not link_widget.button_remove_link.isEnabled()
link_widget.state.data2 = self.data1
assert link_widget.button_add_link.isEnabled()
assert link_widget.button_remove_link.isEnabled()
dialog.accept()
assert len(self.data_collection.external_links) == 0
def test_defaults_two(self):
# Make sure the dialog opens and closes and check default settings. With
# two datasets, the datasets should be selected by default.
self.data_collection.remove(self.data3)
dialog = LinkEditor(self.data_collection)
dialog.show()
link_widget = dialog.link_widget
assert link_widget.state.data1 is self.data1
assert link_widget.state.data2 is self.data2
assert link_widget.button_add_link.isEnabled()
assert link_widget.button_remove_link.isEnabled()
dialog.accept()
assert len(self.data_collection.external_links) == 0
def test_ui_behavior(self):
# This is a bit more detailed test that checks that things update
# correctly as we change various settings
dialog = LinkEditor(self.data_collection)
dialog.show()
link_widget = dialog.link_widget
link_widget.state.data1 = self.data1
link_widget.state.data2 = self.data2
add_identity_link = get_action(link_widget, 'identity')
add_lengths_volume_link = get_action(link_widget, 'lengths_to_volume')
# At this point, there should be no links in the main list widget
# and nothing on the right.
assert link_widget.listsel_current_link.count() == 0
assert link_widget.link_details.text() == ''
assert link_widget.link_io.itemAt(0) is None
# Let's add an identity link
add_identity_link.trigger()
# Ensure that all events get processed
process_events()
# Now there should be one link in the main list and content in the
# right hand panel.
assert link_widget.listsel_current_link.count() == 1
assert link_widget.link_details.text() == 'Link conceptually identical components'
assert non_empty_rows_count(get_link_io(link_widget)) == 5
assert get_link_io(link_widget).itemAtPosition(1, 1).widget().currentText() == 'x'
assert get_link_io(link_widget).itemAtPosition(4, 1).widget().currentText() == 'a'
# Let's change the current components for the link
link_widget.state.current_link.x = self.data1.id['y']
link_widget.state.current_link.y = self.data2.id['b']
# and make sure the UI gets updated
assert get_link_io(link_widget).itemAtPosition(1, 1).widget().currentText() == 'y'
assert get_link_io(link_widget).itemAtPosition(4, 1).widget().currentText() == 'b'
# We now add another link of a different type
add_lengths_volume_link.trigger()
# Ensure that all events get processed
process_events()
# and make sure the UI has updated
assert link_widget.listsel_current_link.count() == 2
#.........这里部分代码省略.........