Skip to content

Improve handling of expression in metadata #2501

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

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

ven-k
Copy link
Member

@ven-k ven-k commented Feb 27, 2024

Instead of evaluating expression while defining the model, keep it as is and execute while creating an instance of it.

This now works:

@mtkmodel Model begin
    @parameters begin
        ρ₀
        p′
        β
    end
    @variables begin
        r(t), [guess = ρ₀*(1 + p′/β)]
    end
end

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

The variables in mtkmodel can have complicated expressions as `guess` and other
metadata. Instead of evaluating them while defining the mtk-model, make those exprs
part of the the definition.

Along with this, the metadata (in structure dict) is kept in expr form.
@ven-k ven-k force-pushed the vkb/fix-expr-in-metadata branch 2 times, most recently from fdfa6df to ae94153 Compare April 25, 2024 09:31
@ven-k ven-k force-pushed the vkb/fix-expr-in-metadata branch from b558089 to 35013c8 Compare April 25, 2024 12:23
@ven-k
Copy link
Member Author

ven-k commented Apr 25, 2024

New tests are added to "Model Parsing" and they pass here.

Test failures are unrelated to this PR.

Documentation had passed for the first commit here.
The current failure is CI related and not this PR.

@ven-k ven-k marked this pull request as ready for review April 25, 2024 13:19
@ven-k
Copy link
Member Author

ven-k commented Apr 29, 2024

This PR is ready for review.

@ChrisRackauckas ChrisRackauckas merged commit a119d82 into SciML:master Apr 29, 2024
@@ -0,0 +1,582 @@
27,28d26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't have been added?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member Author

@ven-k ven-k May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the file with this commit: 27e2699

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants