Skip to content

Commit

Permalink
[bug] MatrixType bug fix: Fix test_ad_gdar_diffmpm (#6786)
Browse files Browse the repository at this point in the history
Issue: #5819

### Brief Summary

This PR fixes invalid syntax in the test.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
strongoier and pre-commit-ci[bot] authored Dec 2, 2022
1 parent e9e374a commit cb53290
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tests/python/test_ad_gdar_diffmpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from tests import test_utils


@test_utils.test(require=ti.extension.assertion, debug=True, exclude=[ti.cc])
def test_gdar_mpm():
def _test_gdar_mpm():
real = ti.f32

dim = 2
Expand Down Expand Up @@ -85,7 +84,7 @@ def p2g(f: ti.i32):
for j in ti.static(range(3)):
offset = ti.Vector([i, j])
dpos = (ti.cast(ti.Vector([i, j]), real) - fx) * dx
weight = w[i](0) * w[j](1)
weight = w[i][0] * w[j][1]
grid_v_in[f, base + offset] += weight * (p_mass * v[f, p] +
affine @ dpos)
grid_m_in[f, base + offset] += weight * p_mass
Expand Down Expand Up @@ -122,8 +121,8 @@ def g2p(f: ti.i32):
for i in ti.static(range(3)):
for j in ti.static(range(3)):
dpos = ti.cast(ti.Vector([i, j]), real) - fx
g_v = grid_v_out[f, base(0) + i, base(1) + j]
weight = w[i](0) * w[j](1)
g_v = grid_v_out[f, base[0] + i, base[1] + j]
weight = w[i][0] * w[j][1]
new_v += weight * g_v
new_C += 4 * weight * g_v.outer_product(dpos) * inv_dx

Expand Down Expand Up @@ -183,3 +182,17 @@ def substep(s):
learning_rate = 10
init_v[None][0] -= learning_rate * grad[0]
init_v[None][1] -= learning_rate * grad[1]


@test_utils.test(require=ti.extension.assertion, debug=True, exclude=[ti.cc])
def test_gdar_mpm():
_test_gdar_mpm()


@test_utils.test(require=ti.extension.assertion,
debug=True,
exclude=[ti.cc],
real_matrix=True,
real_matrix_scalarize=True)
def test_gdar_mpm_real_matrix_scalarize():
_test_gdar_mpm()

0 comments on commit cb53290

Please sign in to comment.