def test_simpleBlockExtraction(self): for params in TestBlockExtraction.PARAMS: strategy = SimpleBlockingStrategy([1] * len(params.aryshape)) # dummy splits; not used here n = reduce(lambda x, y: x * y, params.aryshape) ary = arange(n, dtype="int16").reshape(params.aryshape) key, val = strategy.extractBlockFromImage(ary, params.blockslices, params.timepoint, params.ntimepoints) expectedSlices = [slice(params.timepoint, params.timepoint + 1, 1)] + list(params.blockslices) expectedAry = expand_dims(ary[params.blockslices], axis=0) assert_equals(params.timepoint, key.temporalKey) assert_equals(params.ntimepoints, key.origShape[0]) assert_equals(tuple(params.aryshape), tuple(key.origShape[1:])) assert_equals(tuple(expectedSlices), tuple(key.imgSlices)) assert_true(array_equal(expectedAry, val))
def test_simpleBlockExtraction(self): for params in TestBlockExtraction.PARAMS: strategy = SimpleBlockingStrategy([1]*len(params.aryshape)) # dummy splits; not used here n = reduce(lambda x, y: x*y, params.aryshape) ary = arange(n, dtype='int16').reshape(params.aryshape) key, val = strategy.extractBlockFromImage(ary, params.blockslices, params.timepoint, params.ntimepoints) expectedSlices = [slice(params.timepoint, params.timepoint+1, 1)] + list(params.blockslices) expectedAry = expand_dims(ary[params.blockslices], axis=0) assert_equals(params.timepoint, key.temporalKey) assert_equals(params.ntimepoints, key.origShape[0]) assert_equals(tuple(params.aryshape), tuple(key.origShape[1:])) assert_equals(tuple(expectedSlices), tuple(key.imgSlices)) assert_true(array_equal(expectedAry, val))