-
-
Notifications
You must be signed in to change notification settings - Fork 34
FIX: Respect Joblib context in config sync (Issue #76) #154
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,68 @@ | ||
| import os | ||
| import pytest | ||
| import networkx as nx | ||
| import nx_parallel as nxp | ||
|
|
||
|
|
||
| def test_default_should_run(): | ||
| @nxp._configure_if_nx_active() | ||
| def dummy_default(): | ||
| pass | ||
|
|
||
| with pytest.MonkeyPatch().context() as mp: | ||
| mp.delitem(os.environ, "PYTEST_CURRENT_TEST", raising=False) | ||
| with nx.config.backends.parallel(n_jobs=1): | ||
| assert ( | ||
| dummy_default.should_run() | ||
| == "Parallel backend requires `n_jobs` > 1 to run" | ||
| ) | ||
|
|
||
| assert dummy_default.should_run() | ||
|
|
||
|
|
||
| def test_skip_parallel_backend(): | ||
| @nxp._configure_if_nx_active(should_run=nxp.should_skip_parallel) | ||
| def dummy_skip_parallel(): | ||
| pass | ||
|
|
||
| assert dummy_skip_parallel.should_run() == "Fast algorithm; skip parallel execution" | ||
|
|
||
|
|
||
| def test_should_run_if_large(): | ||
| @nxp._configure_if_nx_active(should_run=nxp.should_run_if_large) | ||
| def dummy_if_large(G): | ||
| pass | ||
|
|
||
| smallG = nx.fast_gnp_random_graph(20, 0.6, seed=42) | ||
| largeG = nx.fast_gnp_random_graph(250, 0.6, seed=42) | ||
|
|
||
| assert dummy_if_large.should_run(smallG) == "Graph too small for parallel execution" | ||
| assert dummy_if_large.should_run(largeG) | ||
|
|
||
|
|
||
| def test_should_run_if_nodes_none(): | ||
| @nxp._configure_if_nx_active(should_run=nxp.should_run_if_nodes_none) | ||
| def dummy_nodes_none(G, nodes=None): | ||
| pass | ||
|
|
||
| G = nx.fast_gnp_random_graph(20, 0.6, seed=42) | ||
| assert ( | ||
| dummy_nodes_none.should_run(G, nodes=[1, 3]) | ||
| == "Parallel execution only supported when `nodes` is None" | ||
| ) | ||
| assert dummy_nodes_none.should_run(G) | ||
|
|
||
|
|
||
| def test_should_run_if_sparse(): | ||
| @nxp._configure_if_nx_active(should_run=nxp.should_run_if_sparse(threshold=0.4)) | ||
| def dummy_if_sparse(G): | ||
| pass | ||
|
|
||
| G_dense = nx.fast_gnp_random_graph(20, 0.6, seed=42) | ||
| assert ( | ||
| dummy_if_sparse.should_run(G_dense) | ||
| == "Graph too dense to benefit from parallel execution" | ||
| ) | ||
|
|
||
| G_sparse = nx.fast_gnp_random_graph(20, 0.2, seed=42) | ||
| assert dummy_if_sparse.should_run(G_sparse) |
Oops, something went wrong.
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.