summaryrefslogtreecommitdiff
path: root/networkx/classes
diff options
context:
space:
mode:
authorRoss Barnowski <rossbar@berkeley.edu>2021-03-04 09:55:49 -0800
committerGitHub <noreply@github.com>2021-03-04 12:55:49 -0500
commite8fbdcb90391673132bae043c7e3c45b2cdedeba (patch)
tree083e1584dd7df0029dacc6ae624c9a7b23bee073 /networkx/classes
parent0ad939428a2eb1768103b634ed2b67386a2e7d48 (diff)
downloadnetworkx-e8fbdcb90391673132bae043c7e3c45b2cdedeba.tar.gz
Deprecate Ordered graph classes (#4629)
* Add deprecation warning + docstrings to Ordered constructors. Adds explicit __init__ methods to the Ordered graph classes. These are pass-through methods, the only purpose of which is to raise a DeprecationWarning whenever one of the Ordered classes is instantiated. * Add warnings filter to conftest. * move depr directives to class docstrings. Works better with autoclass. * Add depr reminder to developer/deprecations.rst. * Add note to release_dev.
Diffstat (limited to 'networkx/classes')
-rw-r--r--networkx/classes/ordered.py91
1 files changed, 87 insertions, 4 deletions
diff --git a/networkx/classes/ordered.py b/networkx/classes/ordered.py
index 74bd5965..67021e5a 100644
--- a/networkx/classes/ordered.py
+++ b/networkx/classes/ordered.py
@@ -1,4 +1,10 @@
"""
+
+.. deprecated:: 2.6
+
+ The ordered variants of graph classes in this module are deprecated and
+ will be removed in version 3.0.
+
Consistently ordered variants of the default base classes.
Note that if you are using Python 3.6+, you shouldn't need these classes
because the dicts in Python 3.6+ are ordered.
@@ -28,6 +34,7 @@ subgraphs and replace with code similar to:
"""
from collections import OrderedDict
+import warnings
from .graph import Graph
from .multigraph import MultiGraph
@@ -42,25 +49,70 @@ __all__.extend(
class OrderedGraph(Graph):
- """Consistently ordered variant of :class:`~networkx.Graph`."""
+ """Consistently ordered variant of :class:`~networkx.Graph`.
+
+ .. deprecated:: 2.6
+
+ OrderedGraph is deprecated and will be removed in version 3.0.
+ Use `Graph` instead, which guarantees order is preserved for
+ Python >= 3.7
+ """
node_dict_factory = OrderedDict
adjlist_outer_dict_factory = OrderedDict
adjlist_inner_dict_factory = OrderedDict
edge_attr_dict_factory = OrderedDict
+ def __init__(self, incoming_graph_data=None, **attr):
+ warnings.warn(
+ (
+ "OrderedGraph is deprecated and will be removed in version 3.0.\n"
+ "Use `Graph` instead, which guarantees order is preserved for\n"
+ "Python >= 3.7\n"
+ ),
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ super(OrderedGraph, self).__init__(incoming_graph_data, **attr)
+
class OrderedDiGraph(DiGraph):
- """Consistently ordered variant of :class:`~networkx.DiGraph`."""
+ """Consistently ordered variant of :class:`~networkx.DiGraph`.
+
+ .. deprecated:: 2.6
+
+ OrderedDiGraph is deprecated and will be removed in version 3.0.
+ Use `DiGraph` instead, which guarantees order is preserved for
+ Python >= 3.7
+ """
node_dict_factory = OrderedDict
adjlist_outer_dict_factory = OrderedDict
adjlist_inner_dict_factory = OrderedDict
edge_attr_dict_factory = OrderedDict
+ def __init__(self, incoming_graph_data=None, **attr):
+ warnings.warn(
+ (
+ "OrderedDiGraph is deprecated and will be removed in version 3.0.\n"
+ "Use `DiGraph` instead, which guarantees order is preserved for\n"
+ "Python >= 3.7\n"
+ ),
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ super(OrderedDiGraph, self).__init__(incoming_graph_data, **attr)
+
class OrderedMultiGraph(MultiGraph):
- """Consistently ordered variant of :class:`~networkx.MultiGraph`."""
+ """Consistently ordered variant of :class:`~networkx.MultiGraph`.
+
+ .. deprecated:: 2.6
+
+ OrderedMultiGraph is deprecated and will be removed in version 3.0.
+ Use `MultiGraph` instead, which guarantees order is preserved for
+ Python >= 3.7
+ """
node_dict_factory = OrderedDict
adjlist_outer_dict_factory = OrderedDict
@@ -68,12 +120,43 @@ class OrderedMultiGraph(MultiGraph):
edge_key_dict_factory = OrderedDict
edge_attr_dict_factory = OrderedDict
+ def __init__(self, incoming_graph_data=None, **attr):
+ warnings.warn(
+ (
+ "OrderedMultiGraph is deprecated and will be removed in version 3.0.\n"
+ "Use `MultiGraph` instead, which guarantees order is preserved for\n"
+ "Python >= 3.7\n"
+ ),
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ super(OrderedMultiGraph, self).__init__(incoming_graph_data, **attr)
+
class OrderedMultiDiGraph(MultiDiGraph):
- """Consistently ordered variant of :class:`~networkx.MultiDiGraph`."""
+ """Consistently ordered variant of :class:`~networkx.MultiDiGraph`.
+
+ .. deprecated:: 2.6
+
+ OrderedMultiDiGraph is deprecated and will be removed in version 3.0.
+ Use `MultiDiGraph` instead, which guarantees order is preserved for
+ Python >= 3.7
+ """
node_dict_factory = OrderedDict
adjlist_outer_dict_factory = OrderedDict
adjlist_inner_dict_factory = OrderedDict
edge_key_dict_factory = OrderedDict
edge_attr_dict_factory = OrderedDict
+
+ def __init__(self, incoming_graph_data=None, **attr):
+ warnings.warn(
+ (
+ "OrderedMultiDiGraph is deprecated and will be removed in version 3.0.\n"
+ "Use `MultiDiGraph` instead, which guarantees order is preserved for\n"
+ "Python >= 3.7\n"
+ ),
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ super(OrderedMultiDiGraph, self).__init__(incoming_graph_data, **attr)