Skip to content
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

Breaking on function with docstring #104

Closed
fccoelho opened this issue Nov 14, 2022 · 6 comments
Closed

Breaking on function with docstring #104

fccoelho opened this issue Nov 14, 2022 · 6 comments
Assignees
Milestone

Comments

@fccoelho
Copy link

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

@odashi odashi added this to the v0.3 milestone Nov 14, 2022
@odashi
Copy link
Collaborator

odashi commented Nov 14, 2022

@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".

@soosub
Copy link

soosub commented Nov 15, 2022

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!

@Casper-Guo
Copy link
Contributor

cc:@LakeBlair

Maybe you can investigate this issue

@LakeBlair
Copy link
Contributor

@odashi Hi! I can take a look at this issue and see if I can find a solution to it.

@odashi
Copy link
Collaborator

odashi commented Nov 17, 2022

Hi @LakeBlair , feel free to propose a pull request for this issue.

@odashi
Copy link
Collaborator

odashi commented Nov 20, 2022

Resolved by #126.

@odashi odashi closed this as completed Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants