Skip to content

Minor fixes: from_grid for custom graph container, create_grid_from_input_data clears exsiting grid. - #311

Open
nitbharambe wants to merge 5 commits into
mainfrom
fix/create-grid-and-custom-graphs
Open

Minor fixes: from_grid for custom graph container, create_grid_from_input_data clears exsiting grid.#311
nitbharambe wants to merge 5 commits into
mainfrom
fix/create-grid-and-custom-graphs

Conversation

@nitbharambe

Copy link
Copy Markdown
Member
  • Allow empty to re-recreate custom graphs
  • create_grid_from_input_data clears exsiting grid

nitbharambe and others added 3 commits August 11, 2026 12:55
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 vincentkoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, let's see if the others agree.

self.grid.check_ids()
new_grid.check_ids()

self.grid = new_grid

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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.grid is not empty at the start of this function? Or even a deprecation warning?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@sonarqubecloud

Copy link
Copy Markdown

cls._validate_branches(arrays=grid)

new_container = cls.empty()
graph_model_type = type(grid.graphs.active_graph)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate what the new code makes possible? I don't see yet why the change is necessary.
What was going wrong before?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants