本文整理汇总了Python中thunder.rdds.fileio.imagesloader.ImagesLoader.subsample方法的典型用法代码示例。如果您正苦于以下问题:Python ImagesLoader.subsample方法的具体用法?Python ImagesLoader.subsample怎么用?Python ImagesLoader.subsample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thunder.rdds.fileio.imagesloader.ImagesLoader
的用法示例。
在下文中一共展示了ImagesLoader.subsample方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subsample
# 需要导入模块: from thunder.rdds.fileio.imagesloader import ImagesLoader [as 别名]
# 或者: from thunder.rdds.fileio.imagesloader.ImagesLoader import subsample [as 别名]
def test_subsample(self):
narys = 3
arys, sh, sz = _generateTestArrays(narys)
sampFactors = [2, (2, 3, 3)]
def subsamp(ary, factor):
if not hasattr(factor, "__len__"):
factor = [factor] * ary.ndim
slices = [slice(0, ary.shape[i], factor[i]) for i in xrange(ary.ndim)]
return ary[slices]
imageData = ImagesLoader(self.sc).fromArrays(arys)
for sampFactor in sampFactors:
subsampData = imageData.subsample(sampFactor)
expectedArys = map(lambda ary: subsamp(ary, sampFactor), arys)
subsampled = subsampData.collect()
for actual, expected in zip(subsampled, expectedArys):
assert_true(array_equal(expected, actual[1]))
assert_equals(tuple(expectedArys[0].shape), subsampled[0][1].shape)
assert_equals(tuple(expectedArys[0].shape), subsampData._dims.count)
assert_equals(str(arys[0].dtype), str(subsampled[0][1].dtype))
assert_equals(str(subsampled[0][1].dtype), subsampData._dtype)