-
Notifications
You must be signed in to change notification settings - Fork 393
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
Add support for ast.IfExp #111
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Hi, this is really good! Could you prepare some unit tests in function_codegen_test.py
as well?
latex = r"\left\{ \begin{array}{ll} " | ||
cond_latex = self.visit(node.test) | ||
true_latex = self.visit(node.body) | ||
false_latex = self.visit(node.orelse) |
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.
Note: I can make some follow-up pull requests for this comment.
I think this line does not process the recursion. e.g.:
if a:
return x
elif b:
return y
else:
return z
and
return x if a else (y if b else z)
should express the same logic, but this impl may generate a different result.
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.
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.
In visit_If
the current implementation processes only the orelse
subtree. I think we could choose the same behavior at this point.
Great work, thanks! |
Btw, CIs (Black and flake8) are still failing, I will merge this PR after resolving these issues. |
Overview
Add support for
a if x else b
(ast.IfExp) statements.Details
References
Blocked by
NA