Breaking on function with docstring
I am getting the error below for the following function:
@latexify.function(use_math_symbols=True)
def model(t: float, y: list, params: dict) -> list:
"""
SIR Model.
:param t: time step
:param y: state of the model at time t
:param params: parameter dictionary
:return:
"""
S, I, R = y
beta, gamma, N = params['beta'], params['gamma'], params['N']
return [
-beta * S * I / N,
beta * S * I / N - gamma * I,
gamma * I
]
LatexifyNotSupportedError: Codegen supports only Assign nodes in multiline functions, but got: Expr
If I remove the docstring, it works as expected
@fccoelho Thank you for reporting the issue!
Yes this is somewhat expected: the Expr represents the docstring and we should ignore the first Expr statement with string values in the codegen. Let me raise the bug level to "major".
I encountered the same issue and removing the docstring resolved it. Thanks for raising the issue @fccoelho! Indeed, it would be nice to keep docstrings and latexify functionality all at once😌
PS cheers for maintaining this package @odashi et al., it's awesome!
cc:@lakeblair
Maybe you can investigate this issue
@odashi Hi! I can take a look at this issue and see if I can find a solution to it.
Hi @LakeBlair , feel free to propose a pull request for this issue.
Resolved by #126.