You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you used latexify on the browser, fill the following items.
Browser: Google Chrome Version 118.0.5993.96
Frontend:Google Colaboratory
Description
If you try to latexify a function that contains an if/elif statement, it will terminate with an error message of "LatexifySyntaxError: Multiple statements are not supported in If nodes." unless there is an else statement. This is awkward, because there are many things that someone would want to express with if/elif statements that look awkward when rendered using a else statement instead of an elif. Here's an example:
Reproduction
Here's that code:
@latexify.function(use_math_symbol=True)
def fn(x):
if x < 0:
return -1
elif x == 0:
return 0
elif x > 0:
return 1
fn
Expected behavior
I'd like to be able to do something like
but without that placeholder "else: return None" bit at the end, which is currently necessary.
The text was updated successfully, but these errors were encountered:
I think this should be a part of fall-through supports. Related issue: #100
The current implementation expects that every if clause has a corresponding else, i.e., every condition should be dispatched to exactly one descendant of the if-elif-else tree. This would be natural in terms of math writing, but yeah it is also a bit frustrating in Python.
Environment
If you used latexify on the browser, fill the following items.
Description
If you try to latexify a function that contains an
if
/elif
statement, it will terminate with an error message of "LatexifySyntaxError: Multiple statements are not supported in If nodes." unless there is anelse
statement. This is awkward, because there are many things that someone would want to express withif
/elif
statements that look awkward when rendered using aelse
statement instead of anelif
. Here's an example:Reproduction
Here's that code:
Expected behavior
I'd like to be able to do something like
but without that placeholder "else: return None" bit at the end, which is currently necessary.
The text was updated successfully, but these errors were encountered: