taichi
taichi copied to clipboard
[Example] Cast index to int in comet.py to resolve TaichiWarning
Issue: #
This PR addresses a Taichi warning in comet.py by explicitly casting i to an integer in the ti.deactivate function. The warning appeared as follows:
TaichiWarning While compiling substep_c76_0, File “taichi/examples/simulation/comet.py”, line 55, in substep: ti.deactivate(x.snode.parent(), [i]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Field index 0 not int32, casting into int32 implicitly
Changes Made
- Updated
ti.deactivate(x.snode.parent(), [i])toti.deactivate(x.snode.parent(), [int(i)])incomet.py.
Rationale
Explicitly casting i to int prevents Taichi from implicitly casting and suppresses the TaichiWarning. This change improves code clarity and ensures compatibility with the expected data type for the function.
Testing
- Confirmed that the warning is no longer displayed when running
comet.py. - Functionality of
comet.pyremains intact after this change.