def test_zero_origin(self): kwargs = dict(shape=5, resolution=1, origin="zero") correct_output = [ np.arange(dim_size) * dim_res for dim_size, dim_res in zip((5,), (1,)) ] for dim, coord in enumerate(_compute_axes(**kwargs)): assert np.array_equal(coord, correct_output[dim])
def test_anisotropic_resolution(self): kwargs = dict(shape=(2, 3, 4), resolution=[1, 1.5, 2], origin="center") correct_output = [ np.arange(dim_size) * dim_res - np.mean(np.arange(dim_size) * dim_res) for dim_size, dim_res in zip((2, 3, 4), (1, 1.5, 2)) ] for dim, coord in enumerate(_compute_axes(**kwargs)): assert np.array_equal(coord, correct_output[dim])
def test_zero_and_one_in_shape(self): kwargs = dict(shape=(0, 1, 2), resolution=1, origin="center") correct_output = [ np.arange(dim_size) * dim_res - np.mean(np.arange(dim_size) * dim_res) for dim_size, dim_res in zip((0, 1, 2), (1, 1, 1)) ] for dim, coord in enumerate(_compute_axes(**kwargs)): assert np.array_equal(coord, correct_output[dim])