diff --git a/python/taichi/lang/impl.py b/python/taichi/lang/impl.py index 520c512f762589..02beaf8a683b59 100644 --- a/python/taichi/lang/impl.py +++ b/python/taichi/lang/impl.py @@ -97,7 +97,8 @@ def subscript(value, *indices): if is_taichi_class(value): return value.subscript(*indices) else: - if isinstance(indices, tuple) and len(indices) == 1 and indices[0] is None: + if isinstance(indices, + tuple) and len(indices) == 1 and indices[0] is None: indices = [] indices_expr_group = make_expr_group(*indices) tensor_dim = int(value.ptr.get_attribute("dim")) diff --git a/taichi/transforms/type_check.cpp b/taichi/transforms/type_check.cpp index a9fc1b0b34253b..6caec81c8359b4 100644 --- a/taichi/transforms/type_check.cpp +++ b/taichi/transforms/type_check.cpp @@ -128,9 +128,12 @@ class TypeCheck : public IRVisitor { } for (int i = 0; i < stmt->indices.size(); i++) { if (!is_integral(stmt->indices[i]->ret_type.data_type)) { - TI_WARN("[{}] Tensor accessed with non-integral indices (e.g., " - "i32/i64), casting into i32 by default...", stmt->name()); - stmt->indices[i] = insert_type_cast_before(stmt, stmt->indices[i], DataType::i32); + TI_WARN( + "[{}] Tensor accessed with non-integral indices (e.g., " + "i32/i64), casting into i32 by default...", + stmt->name()); + stmt->indices[i] = + insert_type_cast_before(stmt, stmt->indices[i], DataType::i32); } TI_ASSERT(stmt->indices[i]->ret_type.width == stmt->snodes.size()); } diff --git a/tests/python/test_indices.py b/tests/python/test_indices.py index d2e7cd9e7ecb73..44afff73181f00 100644 --- a/tests/python/test_indices.py +++ b/tests/python/test_indices.py @@ -21,7 +21,6 @@ def test_indices(): # the virtual first index exposed to the user comes second in memory layout. - @ti.host_arch_only def test_float_as_index(): a = ti.var(ti.f32, (8, 5)) @@ -37,5 +36,5 @@ def func(): func() - assert a[6, 3] == 233 + assert a[6, 3] == 233 assert a[3, 4] == 666