本文整理汇总了Python中glue.core.DataCollection.append方法的典型用法代码示例。如果您正苦于以下问题:Python DataCollection.append方法的具体用法?Python DataCollection.append怎么用?Python DataCollection.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glue.core.DataCollection
的用法示例。
在下文中一共展示了DataCollection.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_component_id_combo_helper_add
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
def test_component_id_combo_helper_add():
# Make sure that when adding a component, and if a data collection is not
# present, the choices still get updated
callback = MagicMock()
state = ExampleState()
state.add_callback('combo', callback)
dc = DataCollection([])
helper = ComponentIDComboHelper(state, 'combo')
assert selection_choices(state, 'combo') == ""
data1 = Data(x=[1, 2, 3], y=[2, 3, 4], label='data1')
callback.reset_mock()
dc.append(data1)
helper.append_data(data1)
callback.assert_called_once_with(0)
callback.reset_mock()
assert selection_choices(state, 'combo') == "x:y"
data1.add_component([7, 8, 9], 'z')
# Should get notification since choices have changed
callback.assert_called_once_with(0)
callback.reset_mock()
assert selection_choices(state, 'combo') == "x:y:z"
示例2: test_data_collection_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [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') == ""
示例3: test_component_id_combo_helper_init
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
def test_component_id_combo_helper_init():
# Regression test to make sure that the numeric and categorical options
# in the __init__ are taken into account properly
combo = QtWidgets.QComboBox()
dc = DataCollection([])
data = Data(a=[1,2,3], b=['a','b','c'], label='data2')
dc.append(data)
helper = ComponentIDComboHelper(combo, dc)
helper.append_data(data)
assert _items_as_string(combo) == "a:b"
helper = ComponentIDComboHelper(combo, dc, numeric=False)
helper.append_data(data)
assert _items_as_string(combo) == "b"
helper = ComponentIDComboHelper(combo, dc, categorical=False)
helper.append_data(data)
assert _items_as_string(combo) == "a"
helper = ComponentIDComboHelper(combo, dc, numeric=False, categorical=False)
helper.append_data(data)
assert _items_as_string(combo) == ""
示例4: test_component_id_combo_helper_init
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
def test_component_id_combo_helper_init():
# Regression test to make sure that the numeric and categorical options
# in the __init__ are taken into account properly
state = ExampleState()
dc = DataCollection([])
data = Data(a=[1, 2, 3], b=['a', 'b', 'c'], label='data2')
dc.append(data)
helper = ComponentIDComboHelper(state, 'combo', dc)
helper.append_data(data)
assert selection_choices(state, 'combo') == "a:b"
helper = ComponentIDComboHelper(state, 'combo', dc, numeric=False)
helper.append_data(data)
assert selection_choices(state, 'combo') == "b"
helper = ComponentIDComboHelper(state, 'combo', dc, categorical=False)
helper.append_data(data)
assert selection_choices(state, 'combo') == "a"
helper = ComponentIDComboHelper(state, 'combo', dc, numeric=False, categorical=False)
helper.append_data(data)
assert selection_choices(state, 'combo') == ""
示例5: test_component_id_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [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) == ""
示例6: main
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
def main():
import numpy as np
from glue.utils.qt import get_qapp
from glue.core import Data, DataCollection
app = get_qapp()
dc = DataCollection()
for i in range(10):
x = np.array([1, 2, 3])
d = Data(label='data_{0:02d}'.format(i), x=x, y=x * 2)
dc.append(d)
LinkEditor.update_links(dc)
示例7: glue_gui
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
def glue_gui():
d = data_factories.load_data(DEIMOSTABLE)
dc = DataCollection([])
dc.append(d)
# Creates glue instance
app = GlueApplication(dc)
app.setVisible(True)
# Adds data to the MosVizViewer
app.new_data_viewer(MOSVizViewer)
app.viewers[0][0].add_data_for_testing(app.data_collection[0])
return app
示例8: test_data_collection_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [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) == ""
示例9: test_manual_data_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [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
示例10: test_component_id_combo_helper_replaced
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
def test_component_id_combo_helper_replaced():
# Make sure that when components are replaced, the equivalent combo index
# remains selected and an event is broadcast so that any attached callback
# properties can be sure to pull the latest text/userData.
callback = MagicMock()
state = ExampleState()
state.add_callback('combo', callback)
dc = DataCollection([])
helper = ComponentIDComboHelper(state, 'combo', dc)
assert selection_choices(state, 'combo') == ""
data1 = Data(x=[1, 2, 3], y=[2, 3, 4], label='data1')
callback.reset_mock()
dc.append(data1)
helper.append_data(data1)
callback.assert_called_once_with(0)
callback.reset_mock()
assert selection_choices(state, 'combo') == "x:y"
new_id = ComponentID(label='new')
data1.update_id(data1.id['x'], new_id)
callback.assert_called_once_with(0)
callback.reset_mock()
assert selection_choices(state, 'combo') == "new:y"
示例11: test_component_id_combo_helper_replaced
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
def test_component_id_combo_helper_replaced():
# Make sure that when components are replaced, the equivalent combo index
# remains selected and an event is broadcast so that any attached callback
# properties can be sure to pull the latest text/userData.
callback = MagicMock()
combo = QtWidgets.QComboBox()
combo.currentIndexChanged.connect(callback)
dc = DataCollection([])
helper = ComponentIDComboHelper(combo, dc)
assert combo_as_string(combo) == ""
data1 = Data(x=[1, 2, 3], y=[2, 3, 4], label='data1')
callback.reset_mock()
dc.append(data1)
helper.append_data(data1)
callback.assert_called_once_with(0)
callback.reset_mock()
assert combo_as_string(combo) == "x:y"
new_id = ComponentID(label='new')
data1.update_id(data1.id['x'], new_id)
callback.assert_called_once_with(0)
callback.reset_mock()
assert combo_as_string(combo) == "new:y"
示例12: LabeledDelegate
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [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_()
示例13: DataCollection
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
column_name = 'cat_peak'
nc = Component.autotyped(cc, units=uu)
catalog.add_component(nc, column_name)
# if column_name != 'parent' else '_flarent_'
catalog.join_on_key(dendro, '_idx', dendro.pixel_component_ids[0])
dc = DataCollection(dendrogram)
#dc = DataCollection([cube, dendrogram, catalog])
#dc.merge(cube,sncube)
#sncube.join_on_key(dendro, 'structure', dendro.pixel_component_ids[0])
#dc.merge(catalog, dendro)
# UNCOMMENT THIS LINE TO BREAK THE VIEWER
dc.append(catalog)
app = GlueApplication(dc)
cube_viewer = app.new_data_viewer(ImageWidget)
cube_viewer.add_data(sncube)
# link positional information
dc.add_link(LinkSame(sncube.id['structure'], catalog.id['_idx']))
#dc.add_link(LinkSame(image.id['World y: DEC--TAN'], catalog.id['DEJ2000']))
dc.add_link(LinkSame(cube.id['Galactic Longitude'], catalog.id['x_cen']))
dc.add_link(LinkSame(cube.id['Galactic Latitude'], catalog.id['y_cen']))
def ms_to_kms(x): return x/1e3
def kms_to_ms(x): return x*1e3
示例14: load_dendro
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [as 别名]
dendrogram = load_dendro(hpath('DendroMask_H2CO303202.hdf5'))
dendro,dendcube = dendrogram
dendcube.label='Dendrogram Cube' # this label is redundant, it will be deleted upon merge
# cube contains real WCS information; dendcube does not
h2cocube = load_data(hpath('APEX_H2CO_303_202_bl.fits'))
h2cocube.label='H2CO 303202 Cube'
catalog = astropy_tabular_data(hpath('PPV_H2CO_Temperature.ipac'), format='ipac')
catalog.label='Fitted Catalog'
h2cocube.add_component(dendcube.get_component('structure'), 'structure')
dc = DataCollection(dendrogram)
dc.append(h2cocube)
dc.append(catalog)
dc.append(dendcube)
dc.merge(h2cocube,dendcube)
dc.merge(dendro, catalog)
app = GlueApplication(dc)
cube_viewer = app.new_data_viewer(ImageWidget)
cube_viewer.add_data(h2cocube)
h2cocube.join_on_key(dendro, 'structure', dendro.pixel_component_ids[0])
scatter = app.new_data_viewer(ScatterWidget)
scatter.add_data(dendro)
示例15: test_component_id_combo_helper
# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import append [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') == ""