本文整理汇总了Python中libdvid.DVIDNodeService.get_labelarray_blocks3D方法的典型用法代码示例。如果您正苦于以下问题:Python DVIDNodeService.get_labelarray_blocks3D方法的具体用法?Python DVIDNodeService.get_labelarray_blocks3D怎么用?Python DVIDNodeService.get_labelarray_blocks3D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libdvid.DVIDNodeService
的用法示例。
在下文中一共展示了DVIDNodeService.get_labelarray_blocks3D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_labelarray_get_volumes
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labelarray_blocks3D [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()