taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.56k stars 2.29k forks source link

[Example] Cast index to int in comet.py to resolve TaichiWarning #8597

Open bluevisor opened 2 weeks ago

bluevisor commented 2 weeks ago

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

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

CLAassistant commented 2 weeks ago

CLA assistant check
All committers have signed the CLA.