-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lang] Support chained assignments #3062
Conversation
✔️ Deploy Preview for jovial-fermat-aa59dc ready! 🔨 Explore the source changes: 8b42b67 🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/615fe7734e0a8b00089a97bd 😎 Browse the preview: https://deploy-preview-3062--jovial-fermat-aa59dc.netlify.app |
/cc @k-ye Do we have the unit tests or integration tests for the Python code transformation logic? |
Yep, they're inside https://github.com/taichi-dev/taichi/tree/master/tests/python. See also https://docs.taichi.graphics/docs/lang/articles/contribution/write_test :-) |
Thanks. I will add more test cases for the feature. |
This comment has been minimized.
This comment has been minimized.
I added some test cases (unpack, chained, chained + unpack, assign) for the feature, and the PR is ready to review, I think. Please take a look, thanks for your time 😄 |
Signed-off-by: Ce Gao <ce.gao@outlook.com>
Signed-off-by: Ce Gao <ce.gao@outlook.com>
Signed-off-by: Ce Gao <ce.gao@outlook.com>
Signed-off-by: Ce Gao <ce.gao@outlook.com>
Please take a look, thanks for your time 😄 |
taichi/python/taichi/lang/stmt_builder.py Lines 118 to 145 in fe5b54d
Can we make this part a static method and use it in both tuple and non-tuple cases? |
Do you mean that we do not make tuple case a func call, we just wrap the detailed logic (assign and var creation) into one func, then use it in tuple and non-tuple? |
I just think the logic of assign and var creation is a bit duplicated. If you think the function is too long, you can also split it into small functions. (just my opinion) |
SGTM. It makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Fix #2659
This PR is to support chained assignments
Test case:
Python generated code
Result: