diff --git a/python/taichi/_kernels.py b/python/taichi/_kernels.py index e6f7c116dfeab..03f3383c8bf00 100644 --- a/python/taichi/_kernels.py +++ b/python/taichi/_kernels.py @@ -142,7 +142,7 @@ def tensor_to_tensor(tensor: template(), other: template()): other_offset_new = static([0] * len(other_shape) if len(other_offset) == 0 else other_offset) for I in grouped(ndrange(*tensor_shape)): - print('index ', I) + print("index ", I) tensor[I + tensor_offset_new] = other[I + other_offset_new] diff --git a/tests/python/test_field.py b/tests/python/test_field.py index 2d36d7b284ecc..9077027f2aa29 100644 --- a/tests/python/test_field.py +++ b/tests/python/test_field.py @@ -85,7 +85,10 @@ def test_scalr_field_from_numpy(dtype, shape): @pytest.mark.parametrize("dtype", data_types) -@pytest.mark.parametrize("shape, offset", [((), ()), (8, 0), (8, 8), (8, -4), ((6, 12), (-4, -4)), ((6, 12), (-4, 4)), ((6, 12), (4, -4)), ((6, 12), (8, 8))]) +@pytest.mark.parametrize( + "shape, offset", + [((), ()), (8, 0), (8, 8), (8, -4), ((6, 12), (-4, -4)), ((6, 12), (-4, 4)), ((6, 12), (4, -4)), ((6, 12), (8, 8))], +) @test_utils.test(arch=get_host_arch_list()) def test_scalr_field_from_numpy_with_offset(dtype, shape, offset): import numpy as np @@ -273,7 +276,19 @@ def test_field_copy_from_with_mismatch_shape(): @test_utils.test() -@pytest.mark.parametrize("shape, x_offset, other_offset", [((), (), ()), (8, 4, 0), (8, 0, -4), (8, -4, -4), (8, 8, -4), ((6, 12), (0, 0), (-6, -6)), ((6, 12), (-6, -6), (0, 0)), ((6, 12), (-6, -6), (-6, -6))]) +@pytest.mark.parametrize( + "shape, x_offset, other_offset", + [ + ((), (), ()), + (8, 4, 0), + (8, 0, -4), + (8, -4, -4), + (8, 8, -4), + ((6, 12), (0, 0), (-6, -6)), + ((6, 12), (-6, -6), (0, 0)), + ((6, 12), (-6, -6), (-6, -6)), + ], +) @pytest.mark.parametrize("dtype", [ti.i32, ti.f32]) def test_field_copy_from_with_offset(shape, dtype, x_offset, other_offset): x = ti.field(dtype=ti.f32, shape=shape, offset=x_offset) diff --git a/tests/python/test_gui.py b/tests/python/test_gui.py index 82c69ab4b8500..6f3f5fda00219 100644 --- a/tests/python/test_gui.py +++ b/tests/python/test_gui.py @@ -39,11 +39,11 @@ def test_set_image_with_offset(fast_gui, offset, dtype, color): n = 300 shape = (n, n) if fast_gui is True or dtype is ti.f64: - img = ti.Vector.field(dtype=dtype, n = 3, shape=shape, offset=offset) + img = ti.Vector.field(dtype=dtype, n=3, shape=shape, offset=offset) else: img = ti.field(dtype=dtype, shape=shape, offset=offset) - img.fill(color); + img.fill(color) - gui = ti.GUI(name='test', res=shape, show_gui=False, fast_gui=fast_gui) + gui = ti.GUI(name="test", res=shape, show_gui=False, fast_gui=fast_gui) gui.set_image(img) gui.show() diff --git a/tests/python/test_matrix.py b/tests/python/test_matrix.py index 15128e45e10c6..18931a1146daa 100644 --- a/tests/python/test_matrix.py +++ b/tests/python/test_matrix.py @@ -1306,13 +1306,17 @@ def access_mat(i: ti.i32, j: ti.i32): @pytest.mark.parametrize("dtype", [ti.i32, ti.f32, ti.i64, ti.f64]) -@pytest.mark.parametrize("shape, offset", [((), ()), (8, 0), (8, 8), (8, -4), ((6, 12), (-4, -4)), ((6, 12), (-4, 4)), ((6, 12), (4, -4)), ((6, 12), (8, 8))]) +@pytest.mark.parametrize( + "shape, offset", + [((), ()), (8, 0), (8, 8), (8, -4), ((6, 12), (-4, -4)), ((6, 12), (-4, 4)), ((6, 12), (4, -4)), ((6, 12), (8, 8))], +) @test_utils.test(arch=get_host_arch_list()) def test_matrix_from_numpy_with_offset(dtype, shape, offset): import numpy as np + m = 3 n = 4 - x = ti.Matrix.field(dtype=dtype,m=m,n=n, shape=shape, offset=offset) + x = ti.Matrix.field(dtype=dtype, m=m, n=n, shape=shape, offset=offset) # use the corresponding dtype for the numpy array. numpy_dtypes = { ti.i32: np.int32, diff --git a/tests/python/test_offset.py b/tests/python/test_offset.py index f59f815d2d0b1..93dc30d52c90b 100644 --- a/tests/python/test_offset.py +++ b/tests/python/test_offset.py @@ -149,14 +149,14 @@ def test_offset_must_throw_matrix(): @test_utils.test(arch=get_host_arch_list()) def test_field_offset_print(): - val = ti.field(dtype=ti.f32, shape=(3,3), offset=(-1, -1)) + val = ti.field(dtype=ti.f32, shape=(3, 3), offset=(-1, -1)) val.fill(1.0) print(val) @test_utils.test(arch=get_host_arch_list()) def test_field_offset_to_numpy(): - shape = (3,3) - val = ti.field(dtype=ti.f32, shape=shape, offset=(-1, -1)) + shape = (3, 3) + val = ti.field(dtype=ti.f32, shape=shape, offset=(-1, -1)) val.fill(1.0) assert np.allclose(val.to_numpy(), np.ones(shape, dtype=np.float32))