-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Adding @constants #1821
Adding @constants #1821
Conversation
…s of a system, collect the constants just prior to building the functions.
…o the function body. That way the constants are not undefined.
…nction doesn't work anyway...). Should improve codecov.
There's a bug in the CodeCov webpage for me: most of the time, when I go to the |
I'm working up some documentation & fixes for the codecov regression. Otherwise it's ready to go. One feature we'll want to add eventually is support for substituting the constants with their literal values at the beginning of |
Does this handle updating constants in events too? |
@isaacsas No, constants are immutable. If needs to be updated in an event, it should be a parameter, not a constant. |
Sorry, I meant does the event code need to be updated to work with constants similar to the updates you made across the various system types? |
🤣 Got it now. I'll sprinkle some constants in Edit: good catch, there were some |
… debugging statements.
@ChrisRackauckas @YingboMa The DataDrivenDiffEq failure is an upstream bug. I think the invalidations failure is also an intermittent bug with SnoopCompile. I think this is ready for review. |
Yes the DataDrivenDiffEq upstream issue is known. |
@ChrisRackauckas Is the Invalidation failure not also a known issue? Same thing happened to Yingbo's PR and another one. |
Yes it seems to be hyperactive. |
@ChrisRackauckas @YingboMa anything else you'd like to see prior to a review? |
Thanks a lot! I will review this tomorrow. |
Sorry for the late review. I just pushed some modifications to the PR. |
See #1802. The basic idea is:
@constants
that are like@parameters
but must have a default valueμ₀
for permeability of free space doesn't belong to any particular model).generate_function
& their definitions (equating the symbol to its default value) are injected into the preface of the function.So far only ODESystems have been equipped to use
@constants
. Failure to handle them properly will result in an UndefVar error when attempting to call a generated function.Initially I tried treating
constant
s similarly toparameter
s: adding acs
field to the system & renamespacing them when flattening systems. However, adding a new field was breaking lots of tests b/c of the constructor signature change. If it is decided that we should go back this way, maybe making an equivalent toNullParameters
so that there can be a default value forcs
and making that argument to the constructor optional would be the workaround.Other approaches I tried for replacing constants with their values:
structural_simplify
to knock them outsubstitute
to replace the constants with their values in the equations prior to building the function