diff options
author | Erik Welch <erik.n.welch@gmail.com> | 2023-05-13 07:27:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-13 14:27:50 +0200 |
commit | 797638345d3a31cd4fff8570a8df07d31e90022e (patch) | |
tree | 0ca5cb6e7df7757bb64e08feb6982011d60094f5 | |
parent | 90bb1f0705f34c6570fe9fa537f672f9ddb3372c (diff) | |
download | networkx-797638345d3a31cd4fff8570a8df07d31e90022e.tar.gz |
Handle weights as `distance=` in testing dispatch (#6671)
* Handle weights as `distance=` in testing dispatch
* fix `test_intersection`
This change was suggested here:
https://github.com/python-graphblas/graphblas-algorithms/pull/62#issuecomment-1531810715
-rw-r--r-- | networkx/algorithms/operators/tests/test_binary.py | 3 | ||||
-rw-r--r-- | networkx/classes/backends.py | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/networkx/algorithms/operators/tests/test_binary.py b/networkx/algorithms/operators/tests/test_binary.py index d358265e..59423c88 100644 --- a/networkx/algorithms/operators/tests/test_binary.py +++ b/networkx/algorithms/operators/tests/test_binary.py @@ -52,7 +52,8 @@ def test_intersection(): I2 = nx.intersection(G2, H2) assert set(I2.nodes()) == {1, 2, 3, 4} assert sorted(I2.edges()) == [(2, 3)] - if os.environ.get("NETWORKX_GRAPH_CONVERT", None) != "nx-loopback": + # Only test if not performing auto convert testing of backend implementations + if os.environ.get("NETWORKX_GRAPH_CONVERT", None) is None: with pytest.raises(TypeError): nx.intersection(G2, H) with pytest.raises(TypeError): diff --git a/networkx/classes/backends.py b/networkx/classes/backends.py index 06af4231..135fa76c 100644 --- a/networkx/classes/backends.py +++ b/networkx/classes/backends.py @@ -233,6 +233,9 @@ def test_override_dispatch(func=None, *, name=None, graphs="G"): weight = bound.arguments["data"] elif bound.arguments["data"]: weight = "weight" + elif "distance" in bound.arguments: + # For ego_graph + weight = bound.arguments["distance"] for gname in graph_list: bound.arguments[gname] = backend.convert_from_nx( bound.arguments[gname], weight=weight, name=name |