MCPcopy
hub / github.com/networkx/networkx / test_mixing_backend_graphs

Function test_mixing_backend_graphs

networkx/utils/tests/test_backends.py:136–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

134
135@pytest.mark.skipif("not nx.utils.backends.backends")
136def test_mixing_backend_graphs():
137 from networkx.classes.tests import dispatch_interface
138
139 G = nx.Graph()
140 G.add_edge(1, 2)
141 G.add_edge(2, 3)
142 H = nx.Graph()
143 H.add_edge(2, 3)
144 rv = nx.intersection(G, H)
145 assert set(nx.intersection(G, H)) == {2, 3}
146 G2 = dispatch_interface.convert(G)
147 H2 = dispatch_interface.convert(H)
148 if "nx_loopback" in nx.config.backend_priority:
149 # Auto-convert
150 assert set(nx.intersection(G2, H)) == {2, 3}
151 assert set(nx.intersection(G, H2)) == {2, 3}
152 elif not nx.config.backend_priority and "nx_loopback" not in nx.config.backends:
153 # G2 and H2 are backend objects for a backend that is not registered!
154 with pytest.raises(ImportError, match="backend is not installed"):
155 nx.intersection(G2, H)
156 with pytest.raises(ImportError, match="backend is not installed"):
157 nx.intersection(G, H2)
158 # It would be nice to test passing graphs from *different* backends,
159 # but we are not set up to do this yet.
160
161
162def test_bad_backend_name():

Callers

nothing calls this directly

Calls 1

add_edgeMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…