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


Python DVIDNodeService.inflate_labelarray_blocks3D_from_raw方法代码示例

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


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

示例1: test_labelarray_get_volumes

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import inflate_labelarray_blocks3D_from_raw [as 别名]
    def test_labelarray_get_volumes(self):
        node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_labelarray_get_volumes")
        node_service.create_labelarray("test_labelarray64_get", 64)
        data = numpy.random.randint(0, 10, (128,128,128)).astype(numpy.uint64)
        assert data.flags['C_CONTIGUOUS']

        # Try reading from empty data (before anything is loaded in the instance)
        # Should be all zeros
        retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (64,128,128), (0,0,0) )
        assert (retrieved_data == 0).all()
    
        # Now populate the instance with some data
        node_service.put_labelblocks3D( "test_labelarray64_get", data, (0,0,0) )
        retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (30,31,32), (20,20,20) )
        assert (retrieved_data == data[20:50, 20:51, 20:52]).all()
    
        # First with the ordinary GET
        retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (64,64,64), (0,0,0) )
        assert (retrieved_data == data[:64,:64,:64]).all()
    
        retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (128,128,128), (0,0,0) )
        assert (retrieved_data == data).all()

        # Again with the blockwise GET
        retrieved_data = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (64,64,64), (0,0,0) )
        assert (retrieved_data == data[:64,:64,:64]).all()
    
        retrieved_data = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (128,128,128), (0,0,0) )
        assert (retrieved_data == data).all()

        # Try the requests-based alternative (request raw via requests.get, then inflate afterwards)
        r = requests.get(f'http://{TEST_DVID_SERVER}/api/node/{self.uuid}/test_labelarray64_get/blocks/128_128_128/0_0_0?compression=blocks')
        r.raise_for_status()
        inflated_data = DVIDNodeService.inflate_labelarray_blocks3D_from_raw(r.content, (128, 128, 128), (0,0,0))
        assert (inflated_data == data).all()

        # What happens if we request a block that doesn't exist on the server?
        missing = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (128,128,128), (1024, 1024, 1024), scale=6 )
        assert missing.shape == (128,128,128)
        assert (missing == 0).all()
开发者ID:janelia-flyem,项目名称:libdvid-cpp,代码行数:42,代码来源:test_node_service.py


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