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


Python DataCollection.register_to_hub方法代码示例

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


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

示例1: TestDendroClient

# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import register_to_hub [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

#.........这里部分代码省略.........
开发者ID:antonl,项目名称:glue,代码行数:103,代码来源:test_dendro_client.py

示例2: receive_message

# 需要导入模块: from glue.core import DataCollection [as 别名]
# 或者: from glue.core.DataCollection import register_to_hub [as 别名]
    def receive_message(self, message):
        """ Receives each DataMessage relay """
        print "    MyClient received a message \n"


# create objects
hub = Hub()
client = MyClient()
data = Data()
subset = data.new_subset()
data_collection = DataCollection()

# connect them to each other
data_collection.append(data)
data_collection.register_to_hub(hub)
client.register_to_hub(hub)

# manually send a DataMessage. Relayed to MyClient
print 'Manually sending DataMessage'
message = DataMessage(data)
hub.broadcast(message)

#modify the data object. Automatically generates a DataMessage
print 'Automatically triggering DataMessage'
data.label = "New label"

#send a SubsetMessage to the Hub.
print 'Manually sending SubsetMessage'
message = SubsetMessage(subset)
hub.broadcast(message) # nothing is printed
开发者ID:ChrisBeaumont,项目名称:glue,代码行数:32,代码来源:simple_glue.py


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