Minor fixes: from_grid for custom graph container, create_grid_from_input_data clears exsiting grid. - #311
Minor fixes: from_grid for custom graph container, create_grid_from_input_data clears exsiting grid.#311nitbharambe wants to merge 5 commits into
Conversation
nitbharambe
commented
Aug 12, 2026
- Allow empty to re-recreate custom graphs
- create_grid_from_input_data clears exsiting grid
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <78108900+nitbharambe@users.noreply.github.com>
vincentkoppen
left a comment
There was a problem hiding this comment.
Looks good to me, let's see if the others agree.
| self.grid.check_ids() | ||
| new_grid.check_ids() | ||
|
|
||
| self.grid = new_grid |
There was a problem hiding this comment.
I agree that this is the intended behaviour of this method. It could cause problems for existing users of the function, but this is not really likely. The only case I could think of is:
- A user has a grid with an additional array/object on the grid
- Initializes the interface
- Already adds the extra array/object on the
interface.grid - Now calls create_grid_from_input_data
- This change now clears the Grid
So I'm fine with changing this, what do you think @Thijss and @jaapschoutenalliander ?
There was a problem hiding this comment.
- Might be nice to adjust the docstring to clearly state that this will overwrite and (re-)initialize the grid based on input_data.
- We could build in a check that crashes/gives a warning if
self.gridis not empty at the start of this function? Or even a deprecation warning?
There was a problem hiding this comment.
Added docstring and warning. Better than silently changing behaviour. Fine with crashing as well if we decide on it.
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
|
| cls._validate_branches(arrays=grid) | ||
|
|
||
| new_container = cls.empty() | ||
| graph_model_type = type(grid.graphs.active_graph) |
There was a problem hiding this comment.
Could you elaborate what the new code makes possible? I don't see yet why the change is necessary.
What was going wrong before?


