def test_expand(input, size, axis, method): t = transforms.Expand(size=size, axis=axis, method=method) if method == 'pad': assert np.array_equal(t(input), F.pad( input, (0, size - input.shape[axis]), axis=axis)) else: assert np.array_equal(t(input), F.crop(F.replicate( input, repetitions=size // input.shape[axis] + 1, axis=axis), (0, size), axis=axis))
def test_replicate(input, repetitions, axis): expected_output = np.concatenate(tuple([input] * repetitions), axis) output = F.replicate(input, repetitions, axis=axis) assert np.array_equal(output, expected_output)