示例#1
0
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))
示例#2
0
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)