rm CondaPkg environment

This commit is contained in:
ton
2023-04-06 13:53:47 +07:00
parent 0a57ed7884
commit c43d949309
3329 changed files with 5725 additions and 447022 deletions

View File

@@ -7,57 +7,54 @@ Create a Dispatcher
To be a valid plugin, a package must register an entry_point
of `networkx.plugins` with a key pointing to the handler.
For example:
For example::
```
entry_points={'networkx.plugins': 'sparse = networkx_plugin_sparse'}
```
entry_points={'networkx.plugins': 'sparse = networkx_plugin_sparse'}
The plugin must create a Graph-like object which contains an attribute
`__networkx_plugin__` with a value of the entry point name.
``__networkx_plugin__`` with a value of the entry point name.
Continuing the example above:
Continuing the example above::
```
class WrappedSparse:
__networkx_plugin__ = "sparse"
...
```
class WrappedSparse:
__networkx_plugin__ = "sparse"
...
When a dispatchable NetworkX algorithm encounters a Graph-like object
with a `__networkx_plugin__` attribute, it will look for the associated
with a ``__networkx_plugin__`` attribute, it will look for the associated
dispatch object in the entry_points, load it, and dispatch the work to it.
Testing
-------
To assist in validating the backend algorithm implementations, if an
environment variable `NETWORKX_GRAPH_CONVERT` is set to a registered
environment variable ``NETWORKX_GRAPH_CONVERT`` is set to a registered
plugin keys, the dispatch machinery will automatically convert regular
networkx Graphs and DiGraphs to the backend equivalent by calling
`<backend dispatcher>.convert_from_nx(G, weight=weight, name=name)`.
``<backend dispatcher>.convert_from_nx(G, weight=weight, name=name)``.
The converted object is then passed to the backend implementation of
the algorithm. The result is then passed to
`<backend dispatcher>.convert_to_nx(result, name=name)` to convert back
``<backend dispatcher>.convert_to_nx(result, name=name)`` to convert back
to a form expected by the NetworkX tests.
By defining `convert_from_nx` and `convert_to_nx` methods and setting
By defining ``convert_from_nx`` and ``convert_to_nx`` methods and setting
the environment variable, NetworkX will automatically route tests on
dispatchable algorithms to the backend, allowing the full networkx test
suite to be run against the backend implementation.
Example pytest invocation:
NETWORKX_GRAPH_CONVERT=sparse pytest --pyargs networkx
Example pytest invocation::
NETWORKX_GRAPH_CONVERT=sparse pytest --pyargs networkx
Dispatchable algorithms which are not implemented by the backend
will cause a `pytest.xfail()`, giving some indication that not all
will cause a ``pytest.xfail()``, giving some indication that not all
tests are working, while avoiding causing an explicit failure.
A special `on_start_tests(items)` function may be defined by the backend.
A special ``on_start_tests(items)`` function may be defined by the backend.
It will be called with the list of NetworkX tests discovered. Each item
is a pytest.Node object. If the backend does not support the test, that
test can be marked as xfail.
is a test object that can be marked as xfail if the backend does not support
the test using `item.add_marker(pytest.mark.xfail(reason=...))`.
"""
import functools
import inspect
@@ -131,7 +128,13 @@ def _dispatch(func=None, *, name=None):
@functools.wraps(func)
def wrapper(*args, **kwds):
graph = args[0]
if args:
graph = args[0]
else:
try:
graph = kwds["G"]
except KeyError:
raise TypeError(f"{name}() missing positional argument: 'G'") from None
if hasattr(graph, "__networkx_plugin__") and plugins:
plugin_name = graph.__networkx_plugin__
if plugin_name in plugins:
@@ -144,6 +147,10 @@ def _dispatch(func=None, *, name=None):
)
return func(*args, **kwds)
# Keep a handle to the original function to use when testing
# the dispatch mechanism internally
wrapper._orig_func = func
_register_algo(name, wrapper)
return wrapper
@@ -168,10 +175,20 @@ def test_override_dispatch(func=None, *, name=None):
def wrapper(*args, **kwds):
backend = plugins[plugin_name].load()
if not hasattr(backend, name):
if plugin_name == "nx-loopback":
raise NetworkXNotImplemented(
f"'{name}' not found in {backend.__class__.__name__}"
)
pytest.xfail(f"'{name}' not implemented by {plugin_name}")
bound = sig.bind(*args, **kwds)
bound.apply_defaults()
graph, *args = args
if args:
graph, *args = args
else:
try:
graph = kwds.pop("G")
except KeyError:
raise TypeError(f"{name}() missing positional argument: 'G'") from None
# Convert graph into backend graph-like object
# Include the weight label, if provided to the algorithm
weight = None
@@ -187,6 +204,7 @@ def test_override_dispatch(func=None, *, name=None):
result = getattr(backend, name).__call__(graph, *args, **kwds)
return backend.convert_to_nx(result, name=name)
wrapper._orig_func = func
_register_algo(name, wrapper)
return wrapper

View File

@@ -134,7 +134,7 @@ class UnionAtlas(Mapping):
self._pred = pred
def __len__(self):
return len(self._succ) + len(self._pred)
return len(self._succ.keys() | self._pred.keys())
def __iter__(self):
return iter(set(self._succ.keys()) | set(self._pred.keys()))

View File

@@ -3,7 +3,7 @@ from copy import deepcopy
from functools import cached_property
import networkx as nx
import networkx.convert as convert
from networkx import convert
from networkx.classes.coreviews import AdjacencyView
from networkx.classes.graph import Graph
from networkx.classes.reportviews import (
@@ -309,8 +309,8 @@ class DiGraph(Graph):
True
"""
_adj = _CachedPropertyResetterAdjAndSucc() # type: ignore
_succ = _adj # type: ignore
_adj = _CachedPropertyResetterAdjAndSucc() # type: ignore[assignment]
_succ = _adj # type: ignore[has-type]
_pred = _CachedPropertyResetterPred()
def __init__(self, incoming_graph_data=None, **attr):

View File

@@ -1253,10 +1253,7 @@ def is_path(G, path):
True if `path` is a valid path in `G`
"""
for node, nbr in nx.utils.pairwise(path):
if (node not in G) or (nbr not in G[node]):
return False
return True
return all((node in G and nbr in G[node]) for node, nbr in nx.utils.pairwise(path))
def path_weight(G, path, weight):

View File

@@ -11,7 +11,7 @@ from copy import deepcopy
from functools import cached_property
import networkx as nx
import networkx.convert as convert
from networkx import convert
from networkx.classes.coreviews import AdjacencyView
from networkx.classes.reportviews import DegreeView, EdgeView, NodeView
from networkx.exception import NetworkXError

View File

@@ -3,7 +3,7 @@ from copy import deepcopy
from functools import cached_property
import networkx as nx
import networkx.convert as convert
from networkx import convert
from networkx.classes.coreviews import MultiAdjacencyView
from networkx.classes.digraph import DiGraph
from networkx.classes.multigraph import MultiGraph

View File

@@ -3,8 +3,7 @@ from copy import deepcopy
from functools import cached_property
import networkx as nx
import networkx.convert as convert
from networkx import NetworkXError
from networkx import NetworkXError, convert
from networkx.classes.coreviews import MultiAdjacencyView
from networkx.classes.graph import Graph
from networkx.classes.reportviews import MultiDegreeView, MultiEdgeView

View File

@@ -966,10 +966,7 @@ class OutMultiEdgeDataView(OutEdgeDataView):
except KeyError:
return False
return e == self._report(u, v, k, dd)
for k, dd in kdict.items():
if e == self._report(u, v, k, dd):
return True
return False
return any(e == self._report(u, v, k, dd) for k, dd in kdict.items())
class MultiEdgeDataView(OutMultiEdgeDataView):
@@ -1005,10 +1002,7 @@ class MultiEdgeDataView(OutMultiEdgeDataView):
except KeyError:
return False
return e == self._report(u, v, k, dd)
for k, dd in kdict.items():
if e == self._report(u, v, k, dd):
return True
return False
return any(e == self._report(u, v, k, dd) for k, dd in kdict.items())
class InMultiEdgeDataView(OutMultiEdgeDataView):
@@ -1036,10 +1030,7 @@ class InMultiEdgeDataView(OutMultiEdgeDataView):
k = e[2]
dd = kdict[k]
return e == self._report(u, v, k, dd)
for k, dd in kdict.items():
if e == self._report(u, v, k, dd):
return True
return False
return any(e == self._report(u, v, k, dd) for k, dd in kdict.items())
# EdgeViews have set operations and no data reported

View File

@@ -0,0 +1,83 @@
# This file contains utilities for testing the dispatching feature
# A full test of all dispatchable algorithms is performed by
# modifying the pytest invocation and setting an environment variable
# NETWORKX_GRAPH_CONVERT=nx-loopback pytest
# This is comprehensive, but only tests the `test_override_dispatch`
# function in networkx.classes.backends.
# To test the `_dispatch` function directly, several tests scattered throughout
# NetworkX have been augmented to test normal and dispatch mode.
# Searching for `dispatch_interface` should locate the specific tests.
import networkx as nx
from networkx import DiGraph, Graph, MultiDiGraph, MultiGraph, PlanarEmbedding
class LoopbackGraph(Graph):
__networkx_plugin__ = "nx-loopback"
class LoopbackDiGraph(DiGraph):
__networkx_plugin__ = "nx-loopback"
class LoopbackMultiGraph(MultiGraph):
__networkx_plugin__ = "nx-loopback"
class LoopbackMultiDiGraph(MultiDiGraph):
__networkx_plugin__ = "nx-loopback"
class LoopbackPlanarEmbedding(PlanarEmbedding):
__networkx_plugin__ = "nx-loopback"
def convert(graph):
if isinstance(graph, PlanarEmbedding):
return LoopbackPlanarEmbedding(graph)
if isinstance(graph, MultiDiGraph):
return LoopbackMultiDiGraph(graph)
if isinstance(graph, MultiGraph):
return LoopbackMultiGraph(graph)
if isinstance(graph, DiGraph):
return LoopbackDiGraph(graph)
if isinstance(graph, Graph):
return LoopbackGraph(graph)
raise TypeError(f"Unsupported type of graph: {type(graph)}")
class LoopbackDispatcher:
non_toplevel = {
"inter_community_edges": nx.community.quality.inter_community_edges,
"is_tournament": nx.algorithms.tournament.is_tournament,
"mutual_weight": nx.algorithms.structuralholes.mutual_weight,
"score_sequence": nx.algorithms.tournament.score_sequence,
"tournament_matrix": nx.algorithms.tournament.tournament_matrix,
}
def __getattr__(self, item):
# Return the original, undecorated NetworkX algorithm
if hasattr(nx, item):
return getattr(nx, item)._orig_func
if item in self.non_toplevel:
return self.non_toplevel[item]._orig_func
raise AttributeError(item)
@staticmethod
def convert_from_nx(graph, weight=None, *, name=None):
return graph
@staticmethod
def convert_to_nx(obj, *, name=None):
return obj
@staticmethod
def on_start_tests(items):
# Verify that items can be xfailed
for item in items:
assert hasattr(item, "add_marker")
dispatcher = LoopbackDispatcher()

View File

@@ -70,8 +70,8 @@ class HistoricalTests:
G = self.G()
G.add_node("A")
assert "A" in G
assert not [] in G # never raise a Key or TypeError in this test
assert not {1: 1} in G
assert [] not in G # never raise a Key or TypeError in this test
assert {1: 1} not in G
def test_add_remove(self):
# Test add_node and remove_node acting for various nbunch

View File

@@ -0,0 +1,14 @@
import pytest
import networkx as nx
pytest.importorskip("scipy")
pytest.importorskip("numpy")
def test_dispatch_kwds_vs_args():
G = nx.path_graph(4)
nx.pagerank(G)
nx.pagerank(G=G)
with pytest.raises(TypeError):
nx.pagerank()

View File

@@ -155,7 +155,7 @@ class TestUnionAtlas:
assert view.__slots__ == pview.__slots__
def test_len(self):
assert len(self.av) == len(self.s) + len(self.p)
assert len(self.av) == len(self.s.keys() | self.p.keys()) == 5
def test_iter(self):
assert set(self.av) == set(self.s) | set(self.p)
@@ -257,7 +257,7 @@ class TestUnionMultiInner(TestUnionAdjacency):
self.adjview = nx.classes.coreviews.UnionMultiInner(self.s, self.p)
def test_len(self):
assert len(self.adjview) == len(self.s) + len(self.p)
assert len(self.adjview) == len(self.s.keys() | self.p.keys()) == 4
def test_getitem(self):
assert self.adjview[1] is not self.s[1]

View File

@@ -330,13 +330,13 @@ class TestFunction:
graph = nx.path_graph(4)
expected = [(0, 2), (0, 3), (1, 3)]
nedges = list(nx.non_edges(graph))
for (u, v) in expected:
for u, v in expected:
assert (u, v) in nedges or (v, u) in nedges
graph = nx.star_graph(4)
expected = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
nedges = list(nx.non_edges(graph))
for (u, v) in expected:
for u, v in expected:
assert (u, v) in nedges or (v, u) in nedges
# Directed graphs
@@ -738,9 +738,9 @@ def test_pathweight():
invalid_path = [1, 3, 2]
graphs = [nx.Graph(), nx.DiGraph(), nx.MultiGraph(), nx.MultiDiGraph()]
edges = [
(1, 2, dict(cost=5, dist=6)),
(2, 3, dict(cost=3, dist=4)),
(1, 2, dict(cost=1, dist=2)),
(1, 2, {"cost": 5, "dist": 6}),
(2, 3, {"cost": 3, "dist": 4}),
(1, 2, {"cost": 1, "dist": 2}),
]
for graph in graphs:
graph.add_edges_from(edges)

View File

@@ -1,6 +1,7 @@
import gc
import pickle
import platform
import weakref
import pytest
@@ -71,7 +72,19 @@ class BaseGraphTester:
G = self.Graph()
def count_objects_of_type(_type):
return sum(1 for obj in gc.get_objects() if isinstance(obj, _type))
# Iterating over all objects tracked by gc can include weak references
# whose weakly-referenced objects may no longer exist. Calling `isinstance`
# on such a weak reference will raise ReferenceError. There are at least
# three workarounds for this: one is to compare type names instead of using
# `isinstance` such as `type(obj).__name__ == typename`, another is to use
# `type(obj) == _type`, and the last is to ignore ProxyTypes as we do below.
# NOTE: even if this safeguard is deemed unnecessary to pass NetworkX tests,
# we should still keep it for maximum safety for other NetworkX backends.
return sum(
1
for obj in gc.get_objects()
if not isinstance(obj, weakref.ProxyTypes) and isinstance(obj, _type)
)
gc.collect()
before = count_objects_of_type(self.Graph)

View File

@@ -349,4 +349,4 @@ class TestChainsOfViews:
H = SG.copy()
assert SG.my_method() == "me"
assert H.my_method() == "me"
assert not 3 in H or 3 in SG
assert 3 not in H or 3 in SG

View File

@@ -421,13 +421,13 @@ class CustomDictClass(UserDict):
class MultiDiGraphSubClass(nx.MultiDiGraph):
node_dict_factory = CustomDictClass # type: ignore
node_attr_dict_factory = CustomDictClass # type: ignore
adjlist_outer_dict_factory = CustomDictClass # type: ignore
adjlist_inner_dict_factory = CustomDictClass # type: ignore
edge_key_dict_factory = CustomDictClass # type: ignore
edge_attr_dict_factory = CustomDictClass # type: ignore
graph_attr_dict_factory = CustomDictClass # type: ignore
node_dict_factory = CustomDictClass # type: ignore[assignment]
node_attr_dict_factory = CustomDictClass # type: ignore[assignment]
adjlist_outer_dict_factory = CustomDictClass # type: ignore[assignment]
adjlist_inner_dict_factory = CustomDictClass # type: ignore[assignment]
edge_key_dict_factory = CustomDictClass # type: ignore[assignment]
edge_attr_dict_factory = CustomDictClass # type: ignore[assignment]
graph_attr_dict_factory = CustomDictClass # type: ignore[assignment]
class TestMultiDiGraphSubclass(TestMultiDiGraph):

View File

@@ -202,8 +202,8 @@ class TestMultiGraph(BaseMultiGraphTester, _TestGraph):
def test_data_multigraph_input(self):
# standard case with edge keys and edge data
edata0 = dict(w=200, s="foo")
edata1 = dict(w=201, s="bar")
edata0 = {"w": 200, "s": "foo"}
edata1 = {"w": 201, "s": "bar"}
keydict = {0: edata0, 1: edata1}
dododod = {"a": {"b": keydict}}
@@ -235,7 +235,7 @@ class TestMultiGraph(BaseMultiGraphTester, _TestGraph):
dol = {"a": ["b"]}
multiple_edge = [("a", "b", "traits", etraits), ("a", "b", "graphics", egraphics)]
single_edge = [("a", "b", 0, {})] # type: ignore
single_edge = [("a", "b", 0, {})] # type: ignore[var-annotated]
single_edge1 = [("a", "b", 0, edata)]
single_edge2 = [("a", "b", 0, etraits)]
single_edge3 = [("a", "b", 0, {"traits": etraits, "s": "foo"})]
@@ -492,13 +492,13 @@ class CustomDictClass(UserDict):
class MultiGraphSubClass(nx.MultiGraph):
node_dict_factory = CustomDictClass # type: ignore
node_attr_dict_factory = CustomDictClass # type: ignore
adjlist_outer_dict_factory = CustomDictClass # type: ignore
adjlist_inner_dict_factory = CustomDictClass # type: ignore
edge_key_dict_factory = CustomDictClass # type: ignore
edge_attr_dict_factory = CustomDictClass # type: ignore
graph_attr_dict_factory = CustomDictClass # type: ignore
node_dict_factory = CustomDictClass # type: ignore[assignment]
node_attr_dict_factory = CustomDictClass # type: ignore[assignment]
adjlist_outer_dict_factory = CustomDictClass # type: ignore[assignment]
adjlist_inner_dict_factory = CustomDictClass # type: ignore[assignment]
edge_key_dict_factory = CustomDictClass # type: ignore[assignment]
edge_attr_dict_factory = CustomDictClass # type: ignore[assignment]
graph_attr_dict_factory = CustomDictClass # type: ignore[assignment]
class TestMultiGraphSubclass(TestMultiGraph):

View File

@@ -205,7 +205,7 @@ class TestNodeViewSetOps:
cls.nv = cls.G.nodes
def n_its(self, nodes):
return {node for node in nodes}
return set(nodes)
def test_len(self):
G = self.G.copy()
@@ -351,26 +351,26 @@ class TestEdgeDataView:
assert (1, 2) in ev and (2, 1) not in ev
else:
assert (1, 2) in ev and (2, 1) in ev
assert not (1, 4) in ev
assert not (1, 90) in ev
assert not (90, 1) in ev
assert (1, 4) not in ev
assert (1, 90) not in ev
assert (90, 1) not in ev
def test_contains_with_nbunch(self):
evr = self.eview(self.G)
ev = evr(nbunch=[0, 2])
if self.G.is_directed():
assert (0, 1) in ev
assert not (1, 2) in ev
assert (1, 2) not in ev
assert (2, 3) in ev
else:
assert (0, 1) in ev
assert (1, 2) in ev
assert (2, 3) in ev
assert not (3, 4) in ev
assert not (4, 5) in ev
assert not (5, 6) in ev
assert not (7, 8) in ev
assert not (8, 9) in ev
assert (3, 4) not in ev
assert (4, 5) not in ev
assert (5, 6) not in ev
assert (7, 8) not in ev
assert (8, 9) not in ev
def test_len(self):
evr = self.eview(self.G)
@@ -427,13 +427,13 @@ class TestOutEdgeDataView(TestEdgeDataView):
evr = self.eview(self.G)
ev = evr(nbunch=[0, 2])
assert (0, 1) in ev
assert not (1, 2) in ev
assert (1, 2) not in ev
assert (2, 3) in ev
assert not (3, 4) in ev
assert not (4, 5) in ev
assert not (5, 6) in ev
assert not (7, 8) in ev
assert not (8, 9) in ev
assert (3, 4) not in ev
assert (4, 5) not in ev
assert (5, 6) not in ev
assert (7, 8) not in ev
assert (8, 9) not in ev
class TestInEdgeDataView(TestOutEdgeDataView):
@@ -455,14 +455,14 @@ class TestInEdgeDataView(TestOutEdgeDataView):
def test_contains_with_nbunch(self):
evr = self.eview(self.G)
ev = evr(nbunch=[0, 2])
assert not (0, 1) in ev
assert (0, 1) not in ev
assert (1, 2) in ev
assert not (2, 3) in ev
assert not (3, 4) in ev
assert not (4, 5) in ev
assert not (5, 6) in ev
assert not (7, 8) in ev
assert not (8, 9) in ev
assert (2, 3) not in ev
assert (3, 4) not in ev
assert (4, 5) not in ev
assert (5, 6) not in ev
assert (7, 8) not in ev
assert (8, 9) not in ev
class TestMultiEdgeDataView(TestEdgeDataView):
@@ -490,11 +490,11 @@ class TestMultiEdgeDataView(TestEdgeDataView):
assert (0, 1) in ev
assert (1, 2) in ev
assert (2, 3) in ev
assert not (3, 4) in ev
assert not (4, 5) in ev
assert not (5, 6) in ev
assert not (7, 8) in ev
assert not (8, 9) in ev
assert (3, 4) not in ev
assert (4, 5) not in ev
assert (5, 6) not in ev
assert (7, 8) not in ev
assert (8, 9) not in ev
class TestOutMultiEdgeDataView(TestOutEdgeDataView):
@@ -520,13 +520,13 @@ class TestOutMultiEdgeDataView(TestOutEdgeDataView):
evr = self.eview(self.G)
ev = evr(nbunch=[0, 2])
assert (0, 1) in ev
assert not (1, 2) in ev
assert (1, 2) not in ev
assert (2, 3) in ev
assert not (3, 4) in ev
assert not (4, 5) in ev
assert not (5, 6) in ev
assert not (7, 8) in ev
assert not (8, 9) in ev
assert (3, 4) not in ev
assert (4, 5) not in ev
assert (5, 6) not in ev
assert (7, 8) not in ev
assert (8, 9) not in ev
class TestInMultiEdgeDataView(TestOutMultiEdgeDataView):
@@ -548,14 +548,14 @@ class TestInMultiEdgeDataView(TestOutMultiEdgeDataView):
def test_contains_with_nbunch(self):
evr = self.eview(self.G)
ev = evr(nbunch=[0, 2])
assert not (0, 1) in ev
assert (0, 1) not in ev
assert (1, 2) in ev
assert not (2, 3) in ev
assert not (3, 4) in ev
assert not (4, 5) in ev
assert not (5, 6) in ev
assert not (7, 8) in ev
assert not (8, 9) in ev
assert (2, 3) not in ev
assert (3, 4) not in ev
assert (4, 5) not in ev
assert (5, 6) not in ev
assert (7, 8) not in ev
assert (8, 9) not in ev
# Edge Views
@@ -631,13 +631,13 @@ class TestEdgeView:
else:
assert (1, 2) in ev and (2, 1) in ev
assert (1, 2) in edv and (2, 1) in edv
assert not (1, 4) in ev
assert not (1, 4) in edv
assert (1, 4) not in ev
assert (1, 4) not in edv
# edge not in graph
assert not (1, 90) in ev
assert not (90, 1) in ev
assert not (1, 90) in edv
assert not (90, 1) in edv
assert (1, 90) not in ev
assert (90, 1) not in ev
assert (1, 90) not in edv
assert (90, 1) not in edv
def test_contains_with_nbunch(self):
ev = self.eview(self.G)
@@ -645,11 +645,11 @@ class TestEdgeView:
assert (0, 1) in evn
assert (1, 2) in evn
assert (2, 3) in evn
assert not (3, 4) in evn
assert not (4, 5) in evn
assert not (5, 6) in evn
assert not (7, 8) in evn
assert not (8, 9) in evn
assert (3, 4) not in evn
assert (4, 5) not in evn
assert (5, 6) not in evn
assert (7, 8) not in evn
assert (8, 9) not in evn
def test_len(self):
ev = self.eview(self.G)
@@ -726,13 +726,13 @@ class TestOutEdgeView(TestEdgeView):
ev = self.eview(self.G)
evn = ev(nbunch=[0, 2])
assert (0, 1) in evn
assert not (1, 2) in evn
assert (1, 2) not in evn
assert (2, 3) in evn
assert not (3, 4) in evn
assert not (4, 5) in evn
assert not (5, 6) in evn
assert not (7, 8) in evn
assert not (8, 9) in evn
assert (3, 4) not in evn
assert (4, 5) not in evn
assert (5, 6) not in evn
assert (7, 8) not in evn
assert (8, 9) not in evn
class TestInEdgeView(TestEdgeView):
@@ -752,14 +752,14 @@ class TestInEdgeView(TestEdgeView):
def test_contains_with_nbunch(self):
ev = self.eview(self.G)
evn = ev(nbunch=[0, 2])
assert not (0, 1) in evn
assert (0, 1) not in evn
assert (1, 2) in evn
assert not (2, 3) in evn
assert not (3, 4) in evn
assert not (4, 5) in evn
assert not (5, 6) in evn
assert not (7, 8) in evn
assert not (8, 9) in evn
assert (2, 3) not in evn
assert (3, 4) not in evn
assert (4, 5) not in evn
assert (5, 6) not in evn
assert (7, 8) not in evn
assert (8, 9) not in evn
class TestMultiEdgeView(TestEdgeView):
@@ -871,7 +871,7 @@ class TestMultiEdgeView(TestEdgeView):
for e in ev:
assert len(e) == 3
elist = sorted([(i, i + 1, 0) for i in range(8)] + [(1, 2, 3)])
assert sorted(list(ev)) == elist
assert sorted(ev) == elist
# test order of arguments:graph, nbunch, data, keys, default
ev = evr((1, 2), "foo", True, 1)
for e in ev:
@@ -938,11 +938,11 @@ class TestMultiEdgeView(TestEdgeView):
assert (0, 1) in evn
assert (1, 2) in evn
assert (2, 3) in evn
assert not (3, 4) in evn
assert not (4, 5) in evn
assert not (5, 6) in evn
assert not (7, 8) in evn
assert not (8, 9) in evn
assert (3, 4) not in evn
assert (4, 5) not in evn
assert (5, 6) not in evn
assert (7, 8) not in evn
assert (8, 9) not in evn
class TestOutMultiEdgeView(TestMultiEdgeView):
@@ -969,13 +969,13 @@ class TestOutMultiEdgeView(TestMultiEdgeView):
ev = self.eview(self.G)
evn = ev(nbunch=[0, 2])
assert (0, 1) in evn
assert not (1, 2) in evn
assert (1, 2) not in evn
assert (2, 3) in evn
assert not (3, 4) in evn
assert not (4, 5) in evn
assert not (5, 6) in evn
assert not (7, 8) in evn
assert not (8, 9) in evn
assert (3, 4) not in evn
assert (4, 5) not in evn
assert (5, 6) not in evn
assert (7, 8) not in evn
assert (8, 9) not in evn
class TestInMultiEdgeView(TestMultiEdgeView):
@@ -1001,14 +1001,14 @@ class TestInMultiEdgeView(TestMultiEdgeView):
def test_contains_with_nbunch(self):
ev = self.eview(self.G)
evn = ev(nbunch=[0, 2])
assert not (0, 1) in evn
assert (0, 1) not in evn
assert (1, 2) in evn
assert not (2, 3) in evn
assert not (3, 4) in evn
assert not (4, 5) in evn
assert not (5, 6) in evn
assert not (7, 8) in evn
assert not (8, 9) in evn
assert (2, 3) not in evn
assert (3, 4) not in evn
assert (4, 5) not in evn
assert (5, 6) not in evn
assert (7, 8) not in evn
assert (8, 9) not in evn
# Degrees