本文整理汇总了Python中thunder.rdds.fileio.imagesloader.ImagesLoader._toBlocksBySplits方法的典型用法代码示例。如果您正苦于以下问题:Python ImagesLoader._toBlocksBySplits方法的具体用法?Python ImagesLoader._toBlocksBySplits怎么用?Python ImagesLoader._toBlocksBySplits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thunder.rdds.fileio.imagesloader.ImagesLoader
的用法示例。
在下文中一共展示了ImagesLoader._toBlocksBySplits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_toBlocksBySlices
# 需要导入模块: from thunder.rdds.fileio.imagesloader import ImagesLoader [as 别名]
# 或者: from thunder.rdds.fileio.imagesloader.ImagesLoader import _toBlocksBySplits [as 别名]
def test_toBlocksBySlices(self):
narys = 3
arys, sh, sz = _generate_test_arrays(narys)
imagedata = ImagesLoader(self.sc).fromArrays(arys)
test_params = [
(1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 2, 1), (1, 2, 2), (1, 2, 3),
(1, 3, 1), (1, 3, 2), (1, 3, 3),
(2, 1, 1), (2, 1, 2), (2, 1, 3), (2, 2, 1), (2, 2, 2), (2, 2, 3),
(2, 3, 1), (2, 3, 2), (2, 3, 3)]
for bpd in test_params:
blocks = imagedata._toBlocksBySplits(bpd).collect()
expectednuniquekeys = reduce(mul, bpd)
expectedvalsperkey = narys
keystocounts = Counter([kv[0] for kv in blocks])
assert_equals(expectednuniquekeys, len(keystocounts))
assert_equals([expectedvalsperkey] * expectednuniquekeys, keystocounts.values())
gatheredary = None
for _, block in blocks:
if gatheredary is None:
gatheredary = zeros(block.origshape, dtype='int16')
gatheredary[block.origslices] = block.values
for i in xrange(narys):
assert_true(array_equal(arys[i], gatheredary[i]))