- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 233
add toplevel arguments to various getters #3462
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
add toplevel arguments to various getters #3462
Conversation
|  | ||
| systems = get_systems(sys) | ||
| cbs = [obs; | ||
| cbs = [cbs; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a leftover from the code being copied from the observed getter (?), in which case it would make sense to use cbs and not obs throughout the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the system is flattened (or completed), this approach won't work since e.g. get_unknowns contains all the unknowns of the system. This can be handled by doing e.g.
function top_level_unknowns(sys::AbstractSystem)
    if has_parent(sys) && (p = get_parent(sys)) !== nothing
        return top_level_unknowns(p)
    end
    return get_unknowns(sys)
end| Was mostly really thinking of an modified accessor of the actual field. However, handling flattened systems like this does make lots of sense (as I think otherwise the §toplevel§ argument would be irrelevant anyway). Will modify, thanks for the code snippet! | 
| @AayushSabharwal For systems where I have thrown a structural simplify I am a bit unsure how to adapt your approach. I.e. if you want to do  | 
| Yes. As we discussed in an earlier thread,  | 
| So would it make sense to just disable  There is a slightly similar phenomenon for  (generally, I do think support for some form of non-ss observables is important, as the current approach kind of skrew up jump simulations hard, but that is a discussion for another place) | 
| 
 Yes. And yeah equations basically suffer the same fate. They don't "belong" to a subsystem anymore. | 
| Got it, I will remove the  It would make it possible to still use these when constructing things of MTK. I.e. a problem with a lot of things now being considered extra MTK internal is that while this makes sense for direct users, packages like Catalyst that builds on MTK kind of need these kind of things to construct the models we do. | 
| @ChrisRackauckas should we allow passing  @TorkelE In general with simplification we can't allow user-provided observed equations. At best during simplification we club them together with the rest of the equations but this won't guarantee they're re-eliminated, so there really isn't a benefit to not putting them with the rest of the equations. | 
| 
 For  | 
| Makes sense. Maybe at some point we try to get as many of us as possible together and discuss through what things Catalyst needs/don't need and the best way to get it from MTK. This one is finished sans: 
 | 
| 
 The reason that I ideally would like to keep it as a kwarg is that it means that I don't have to copy lots of code over, and if someone does something to the main function (i.e. exception for a new MTK-added parameter), those changes will automatically get incorporated without someone having to keep track of these extra functions. | 
| 
 It only makes sense for un-flattened systems. But whether the function itself is useful depends on what you need it for. MTK itself (and other uses I'm aware of) don't really need this functionality. 
 Then shouldn't we wait before merging this PR? Adding features we later might deem unnecessary only adds to the maintenance burden and restricts semver. 
 I'm not sure what you mean by "copy code over"? What code needs to be copied? The snippet I sent above handles everything, since it extracts information from the user-provided unsimplified model and thus doesn't have any extra parameters MTK adds. | 
| 
 Right now we use  
 I was talking in regards to  
 So your code uses  | 
| 
 That's exactly what I'm referring to. These initialization parameters are added to the simplified/completed system and not to the user-provided system. In general, all operations on systems are out-of-place. This is why the approach in my snippet won't have any extra parameters. | 
| 
 Why? And do you do it on completed systems or unmodified ones? | 
| 
 Ok, got it, will try this out and see if it works. Does that mean that  
 Different in different cases. | 
| 
 Yep, it's a field accessor. Works on all systems. We use it in a bunch of places. | 
| 
 Got it. | 
| Ok, this one should be ready now. | 
| I have checked the spell check, and its marked errors are not related to this PR. The other errors also seem to also occur on other branches. It would be good if @AayushSabharwal could have a look to check that things looks sound though. | 
        
          
                test/accessor_functions.jl
              
                Outdated
          
        
      | @test all_sets_equal( | ||
| parameters_toplevel.([sys_mid2, sys_mid2_comp, sys_mid2_ss])..., | ||
| [d, p_mid2]) | ||
| @test_broken all_sets_equal( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because #3464 makes parameters return an internal parameter DEF.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix for that just got merged and tagged. Could you rebase and try?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
Co-authored-by: Aayush Sabharwal <[email protected]>
Co-authored-by: Aayush Sabharwal <[email protected]>
| Ok, this is ready now, again, the errors is things which seems to error on other branches (or at least they error on #3466 as well) | 
| Add the docstrings to the doc? | 
| Do you have a suggestion on where to put them? There is not dedicated API list in MTK right? Right now I just added mentions of these, but am happy to insert the docstrings if there are some appropriate positions for them. | 
| Forgot we hadn't updated this repo yet for the newer Documenter features. | 
| Right! Looking forwards to checking those out! | 
Needs tests and docs, and to check if there are any other getters that should have a similar arguments.
But figured I'd upload this first in case people had input/opinions about the approach.