From 797638345d3a31cd4fff8570a8df07d31e90022e Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sat, 13 May 2023 07:27:50 -0500 Subject: 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 --- networkx/algorithms/operators/tests/test_binary.py | 3 ++- networkx/classes/backends.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1