Skip to content

Commit

Permalink
[bug] Fixes for numpy 2.0 (unblocking python 3.12 release build on ma…
Browse files Browse the repository at this point in the history
…c) (#8552)

Numpy 2.0 has removed deprecated implicit cast behavior of overflow
casting to smaller dtypes. And it has removed .product in favor of .prod
  • Loading branch information
bobcao3 committed Jun 24, 2024
1 parent f3ac30f commit d86e69f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions python/taichi/examples/simulation/implicit_fem.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
use_sparse = args.use_sparse

n_cube = np.array([5] * 3)
n_verts = np.product(n_cube)
n_cells = 5 * np.product(n_cube - 1)
n_verts = np.prod(n_cube)
n_cells = 5 * np.prod(n_cube - 1)
dx = 1 / (n_cube.max() - 1)

F_vertices = ti.Vector.field(4, dtype=ti.i32, shape=n_cells)
Expand Down
4 changes: 2 additions & 2 deletions tests/python/test_implicit_fem.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def test_implicit_fem():
use_sparse = 0

n_cube = np.array([5] * 3)
n_verts = np.product(n_cube)
n_cells = 5 * np.product(n_cube - 1)
n_verts = np.prod(n_cube)
n_cells = 5 * np.prod(n_cube - 1)
dx = 1 / (n_cube.max() - 1)

F_vertices = ti.Vector.field(4, dtype=ti.i32, shape=n_cells)
Expand Down
8 changes: 4 additions & 4 deletions tests/python/test_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def reduce_tmp() -> dtype:
@pytest.mark.parametrize("op", [OP_ADD, OP_MIN, OP_MAX, OP_AND, OP_OR, OP_XOR])
@test_utils.test()
def test_reduction_single_i32(op):
_test_reduction_single(ti.i32, lambda x, y: x % 2**32 == y % 2**32, op)
_test_reduction_single(ti.i32, lambda x, y: int(x) % 2**32 == int(y) % 2**32, op)


@pytest.mark.parametrize("op", [OP_ADD])
@test_utils.test(exclude=[ti.opengl, ti.gles])
def test_reduction_single_u32(op):
_test_reduction_single(ti.u32, lambda x, y: x % 2**32 == y % 2**32, op)
_test_reduction_single(ti.u32, lambda x, y: int(x) % 2**32 == int(y) % 2**32, op)


@pytest.mark.parametrize("op", [OP_ADD, OP_MIN, OP_MAX])
Expand All @@ -107,13 +107,13 @@ def test_reduction_single_f32(op):
@pytest.mark.parametrize("op", [OP_ADD])
@test_utils.test(require=ti.extension.data64)
def test_reduction_single_i64(op):
_test_reduction_single(ti.i64, lambda x, y: x % 2**64 == y % 2**64, op)
_test_reduction_single(ti.i64, lambda x, y: int(x) % 2**64 == int(y) % 2**64, op)


@pytest.mark.parametrize("op", [OP_ADD])
@test_utils.test(exclude=[ti.opengl, ti.gles], require=ti.extension.data64)
def test_reduction_single_u64(op):
_test_reduction_single(ti.u64, lambda x, y: x % 2**64 == y % 2**64, op)
_test_reduction_single(ti.u64, lambda x, y: int(x) % 2**64 == int(y) % 2**64, op)


@pytest.mark.parametrize("op", [OP_ADD])
Expand Down

0 comments on commit d86e69f

Please sign in to comment.