Open GabrielKS opened 4 months ago
Another surprising behavior of set_name!
is that if you set a component's name to that component's existing name, it's an error:
This one I think should be changed to a no-op.
I don't think we can do much here, besides adding in the documentation that every time you modify a component you should do:
for load_zone in collect(get_components(LoadZone, sys))
@show get_name(load_zone)
set_name!(sys, load_zone, get_name(load_zone)*"-renamed")
end
Regarding the second issue of renaming to same name, @GabrielKS can you open an issue on InfrastructureSystems?
Regarding the main issue here:
@kdayday If there is some funding for documentation, I think we should add a tutorial regarding modifying data in a existing system? We can show how to increase the load of the system, or change the operating points of the generators, and we can highlight the issue of updating the name using the get_components
, that you should always do collect
.
@rodrigomha yes, it is on my general to-do's to add a "manipulating data" tutorial to highlight the getters and setters, some of which was previously on other pages and is now orphaned. I'll take a note of this.
@rodrigomha Opened https://github.com/NREL-Sienna/InfrastructureSystems.jl/issues/397 for the second issue.
I don't think we can do much here, besides adding in the documentation that every time you modify a component you should do:
for load_zone in collect(get_components(LoadZone, sys)) @show get_name(load_zone) set_name!(sys, load_zone, get_name(load_zone)*"-renamed") end
Regarding the second issue of renaming to same name, @GabrielKS can you open an issue on InfrastructureSystems?
Regarding the main issue here: @kdayday If there is some funding for documentation, I think we should add a tutorial regarding modifying data in a existing system? We can show how to increase the load of the system, or change the operating points of the generators, and we can highlight the issue of updating the name using the
get_components
, that you should always docollect
.
@annacasavant See this whole thread, especially Rodrigo's note
If one renames components attached to a system in a loop over
get_components
:some components will be covered multiple times:
because the components are stored in a dictionary indexed by name. It's reasonable to expect people to know that when iterating over a container, they're not supposed to change the container (so no adding and removing components in this loop), but I don't think it's obvious to users that
set_name!
changes the container, not just a field within the component (like, if this were something likeset_peak_active_power!
, it would be safe). @daniel-thom and I agree that it's not at all worth changing the implementation to make this behavior safe, but that we should document more explicitly thatset_name!
changes the container.