-
Notifications
You must be signed in to change notification settings - Fork 2
Use adjacencylists and pure numpy for arrays. #18
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
Open
jorgensd
wants to merge
8
commits into
main
Choose a base branch
from
dokken/in_out_bifurcation_edges
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
517dffc
Use adjacencylists and pure numpy for arrays. no more mixture of list…
jorgensd 431d0b4
Add sanity check
jorgensd 9c7765d
Apply suggestions from code review
jorgensd 2d05d8c
Merge branch 'main' into dokken/in_out_bifurcation_edges
schnellerhase 7d043ca
Merge branch 'main' into dokken/in_out_bifurcation_edges
jorgensd 83d41b6
Remove duplicate definition
jorgensd 4da86aa
Remove config
jorgensd 691b2b0
Deactivate output
schnellerhase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import networkx as nx | ||
| import numpy as np | ||
| import pytest | ||
|
|
||
| from networks_fenicsx import NetworkMesh | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("N", [10, 50]) | ||
| def test_edge_info(N: int): | ||
| # Create manual graph where we have five bifurcations. | ||
| # One inlet (0) -> (1) -> (7). | ||
| G = nx.DiGraph() | ||
| G.add_node(0, pos=np.zeros(3)) | ||
| G.add_node(1, pos=np.array([0.0, 0.0, 1.0])) | ||
| G.add_node(2, pos=np.array([0.2, 0.2, 2.0])) | ||
| G.add_node(3, pos=np.array([-0.2, 0.3, 2.0])) | ||
| G.add_node(4, pos=np.array([0.0, 0.1, 2.1])) | ||
| G.add_node(5, pos=np.array([0.1, -0.1, 3.0])) | ||
| G.add_node(6, pos=np.array([-0.3, 0.4, 4.0])) | ||
| G.add_node(7, pos=1.1 * G.nodes[1]["pos"]) | ||
| G.add_edge(0, 1) | ||
| G.add_edge(1, 7) | ||
| # Split into three bifurcations (7)->(2), (7)->(3), (7)->(4) | ||
| G.add_edge(7, 2) | ||
| # First branch goes right to gathering | ||
| G.add_edge(2, 5) | ||
| # Second branch goes through an extra point(3), before meeting at point (4) | ||
| G.add_edge(7, 3) | ||
| G.add_edge(3, 4) | ||
| G.add_edge(4, 5) | ||
| # Last branch goes directly to gathering | ||
| G.add_edge(7, 4) | ||
| G.add_edge(5, 6) | ||
|
|
||
| network_mesh = NetworkMesh(G, N=N) | ||
| assert len(network_mesh.bifurcation_values) == 6 | ||
| # Bifurcation values are sorted in increasing order | ||
| np.testing.assert_allclose([1, 2, 3, 4, 5, 7], network_mesh.bifurcation_values) | ||
| assert len(network_mesh.in_edges(0)) == 1 | ||
| assert len(network_mesh.out_edges(0)) == 1 | ||
|
|
||
| assert len(network_mesh.in_edges(1)) == 1 | ||
| assert len(network_mesh.out_edges(1)) == 1 | ||
|
|
||
| assert len(network_mesh.in_edges(2)) == 1 | ||
| assert len(network_mesh.out_edges(2)) == 1 | ||
|
|
||
| assert len(network_mesh.in_edges(3)) == 2 | ||
| assert len(network_mesh.out_edges(3)) == 1 | ||
|
|
||
| assert len(network_mesh.in_edges(4)) == 2 | ||
| assert len(network_mesh.out_edges(4)) == 1 | ||
|
|
||
| assert len(network_mesh.in_edges(5)) == 1 | ||
| assert len(network_mesh.out_edges(5)) == 3 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.