Skip to content

Add support for Python 3.12 and networkx graphs#141

Merged
alihamdan merged 4 commits intodevelopfrom
networkx
Oct 30, 2023
Merged

Add support for Python 3.12 and networkx graphs#141
alihamdan merged 4 commits intodevelopfrom
networkx

Conversation

@alihamdan
Copy link
Member

Closes #137

  • Add support for Python 3.12
  • Add an ElectricalNetwork.to_graph method to get a networx.Graph object representing the network
  • Add an ElectricalNetwork.buses_clusters property to group buses on the same voltage levels (i.e. connected via lines or switches)
  • Add a Bus.find_neighbors() method to get an iterator of buses connected to this bus via a line or a switch
  • Fix sphinx builds failing with old autoapi extension version
  • Fix missing links to matplotlib in the docs
  • Fix missing plot extra to install matplotlib. It was misconfigured in pyproject.toml

I initially planned to remove support for Python 3.9 in this release. This will have to wait to the next release as some interested people I met are still using python 3.9 and this release fixes a lot of pandas warnings for them.

@alihamdan alihamdan added the enhancement New feature or request label Oct 30, 2023
@alihamdan alihamdan requested a review from Saelyos October 30, 2023 11:07
@alihamdan alihamdan self-assigned this Oct 30, 2023
Comment on lines 255 to +259

def find_neighbors(self) -> Iterator[Id]:
"""Find the buses connected to this bus via a line or switch recursively."""
from roseau.load_flow.models.lines import Line, Switch

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if "neighbors" is not a bit confusing. When I first saw this method, I thought it would only give the adjacent buses connected to that bus.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. I was going with get_connnected_buses at first but it suffers from the same ambiguity as find_neighbors in that it could mean buses connected with one line or switch. Do you have a better name? I can also clarify the docstring to say something like Find all buses connected to this bus via one or more lines or switches, stop at transformers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we've used the term galvanic component for this kind of stuff, but I'm not convinced that it would be understood easily. Between get_connected_buses and find_neighbors, I think I prefer the former as I find it less confusing, but I agree that there is still an ambiguity that has to be clarified in the docstring.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK I renamed it to get_connected_buses and clarified that we are talking about "galvanically connected" buses.

@alihamdan alihamdan merged commit dcbaa65 into develop Oct 30, 2023
@alihamdan alihamdan deleted the networkx branch October 30, 2023 15:58
@benoit9126 benoit9126 mentioned this pull request Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: NetworkX

3 participants