def test_pad_arrays_axis(axis: int, is_right_pad: bool): arrays = [d["target"] for d in list(iter(get_dataset()))] if axis == 0: arrays = [x.T for x in arrays] padded_arrays = _pad_arrays(arrays, axis, is_right_pad=is_right_pad) assert all(a.shape[axis] == 8 for a in padded_arrays) assert all(a.shape[1 - axis] == 2 for a in padded_arrays)
def test_pad_arrays_axis(array_type, multi_processing, axis: int): arrays = [ d["target"] if array_type == "np" else mx.nd.array(d["target"]) for d in list(iter(get_dataset())) ] if axis == 0: arrays = [x.T for x in arrays] padded_arrays = _pad_arrays(arrays, axis) assert all(a.shape[axis] == 8 for a in padded_arrays) assert all(a.shape[1 - axis] == 2 for a in padded_arrays)
def test_pad_arrays_pad_left(): arrays = [d["target"] for d in list(iter(get_dataset()))] padded_arrays = _pad_arrays(arrays, 1, is_right_pad=False) for padded_array in padded_arrays[1:]: assert np.allclose(padded_array[:, 0], 0)