-
Notifications
You must be signed in to change notification settings - Fork 35
change replace_comp!
to replace!
#715
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #715 +/- ##
==========================================
+ Coverage 79.73% 79.81% +0.07%
==========================================
Files 38 38
Lines 2877 2888 +11
==========================================
+ Hits 2294 2305 +11
Misses 583 583
Continue to review full report at Codecov.
|
So this is a bit embarassing, but I don't know what the difference between I think we should just flat out disable replacement within composite components for now. We can revisit in later version, but for 1.0 I think we really don't need it. I think for a first version we can also not have the option to rename things. Actually, maybe we don't need that at all, I would say :) I'm wondering whether the third method in your list should actually be a distinct function that is more of an internal function, and not part of the public API? |
@davidanthoff The I think I agree with your proposed solution: only allow using a |
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.
Great!
issue #712
I changed the functionality from:
to:
as discussed in order to follow Julia conventions for Base.replace!
One question for now:
There are three methods of
replace!
in Mimi:Users can call either of the first two methods on a model, using either the ComponentId or the ComponentDef of the new component, and then Mimi calls the third method on the model definition, using the ComponentId. The third method also supports the ability to replace a subcomponent within a composite component definition if called directly, although we don't have any use cases of this yet. My question is whether we should add an additional method, so that someone can use the ComponentDef instead of the ComponentId in this case if desired:
Replacing composite components?
I believe you cannot currently use
replace!
to replace a composite component (it only works on ComponentDefs, not AbstractComponentDefs). I'm not sure how trivial this would be to implement, since we might need to add additional checks about behavior of subcomponents, or it might just work out nicely with our new parameter/variable definitions in composites. Maybe this can be added in a later version, although there are not currently helpful error messages if someone tried to use this. I'd just like input on whether I should spend more time thinking about this now or not.Another question that can probably be for a later version:
Do we want to add an optional keyword argument for changing the name of the added component in the model's list of component names? It currently gets added under the replaced component's name. This would be slightly non-trivial change, because I think you would have to also change any instances of the name that's stored in parameter connections etc.