Add several bug fix patches.

- Add -doc patch to fix building the gallery of examples.
- Add -is patch to reduce noise in sagemath.
- Add upstream bug fix patches: -source-target, -union-find, -cb-iterable,
  -iterable, and -dict-iteration.
This commit is contained in:
Jerry James 2019-09-11 13:16:07 -06:00
parent eb127cd15c
commit f6852e8613
8 changed files with 236 additions and 7 deletions

View File

@ -0,0 +1,60 @@
https://github.com/networkx/networkx/commit/eb3a675c5b2b15e33b0a4a35bcee34d6b81ed94d
Replace cb.iterable with np.iterable (#3458)
`matplotlib.cbook.iterable` is deprecated in matplotlib 3.1
https://matplotlib.org/3.1.0/api/cbook_api.html#matplotlib.cbook.iterable
Fixes https://github.com/networkx/networkx/issues/3466
--- networkx/drawing/nx_pylab.py.orig 2019-04-11 14:52:34.000000000 -0600
+++ networkx/drawing/nx_pylab.py 2019-09-11 10:14:12.380878784 -0600
@@ -550,7 +550,6 @@ def draw_networkx_edges(G, pos,
try:
import matplotlib
import matplotlib.pyplot as plt
- import matplotlib.cbook as cb
from matplotlib.colors import colorConverter, Colormap, Normalize
from matplotlib.collections import LineCollection
from matplotlib.patches import FancyArrowPatch
@@ -576,13 +575,13 @@ def draw_networkx_edges(G, pos,
# set edge positions
edge_pos = np.asarray([(pos[e[0]], pos[e[1]]) for e in edgelist])
- if not cb.iterable(width):
+ if not np.iterable(width):
lw = (width,)
else:
lw = width
if not is_string_like(edge_color) \
- and cb.iterable(edge_color) \
+ and np.iterable(edge_color) \
and len(edge_color) == len(edge_pos):
if np.alltrue([is_string_like(c) for c in edge_color]):
# (should check ALL elements)
@@ -591,7 +590,7 @@ def draw_networkx_edges(G, pos,
for c in edge_color])
elif np.alltrue([not is_string_like(c) for c in edge_color]):
# If color specs are given as (rgb) or (rgba) tuples, we're OK
- if np.alltrue([cb.iterable(c) and len(c) in (3, 4)
+ if np.alltrue([np.iterable(c) and len(c) in (3, 4)
for c in edge_color]):
edge_colors = tuple(edge_color)
else:
@@ -673,7 +672,7 @@ def draw_networkx_edges(G, pos,
line_width = None
shrink_source = 0 # space from source to tail
shrink_target = 0 # space from head to target
- if cb.iterable(node_size): # many node sizes
+ if np.iterable(node_size): # many node sizes
src_node, dst_node = edgelist[i][:2]
index_node = nodelist.index(dst_node)
marker_size = node_size[index_node]
@@ -797,7 +796,6 @@ def draw_networkx_labels(G, pos,
"""
try:
import matplotlib.pyplot as plt
- import matplotlib.cbook as cb
except ImportError:
raise ImportError("Matplotlib required for draw()")
except RuntimeError:

View File

@ -0,0 +1,17 @@
https://github.com/networkx/networkx/commit/52e7b5d8732c84512f5423661f234790ce7b1b5f
Fix dict iteration for Py3.8
Python 3.8 tracks if any key names change while iterating.
https://github.com/python/cpython/pull/12596
--- networkx/classes/reportviews.py.orig 2019-04-11 14:52:34.000000000 -0600
+++ networkx/classes/reportviews.py 2019-09-11 09:36:56.783002687 -0600
@@ -1025,7 +1025,7 @@ class EdgeView(OutEdgeView):
def __iter__(self):
seen = {}
for n, nbrs in self._nodes_nbrs():
- for nbr in nbrs:
+ for nbr in list(nbrs):
if nbr not in seen:
yield (n, nbr)
seen[n] = 1

12
python-networkx-doc.patch Normal file
View File

@ -0,0 +1,12 @@
--- doc/conf.py.orig 2019-04-11 14:52:34.000000000 -0600
+++ doc/conf.py 2019-09-11 12:27:51.389122126 -0600
@@ -72,7 +72,8 @@ sphinx_gallery_conf = {
# path where to save gallery generated examples
'gallery_dirs': 'auto_examples',
'backreferences_dir': 'modules/generated',
- 'expected_failing_examples': ['../examples/advanced/plot_parallel_betweenness.py']
+ 'filename_pattern': '/plot_(?!parallel_betweenness)',
+ 'expected_failing_examples': ['../examples/graph/plot_football.py']
}
# generate autosummary pages

22
python-networkx-is.patch Normal file
View File

@ -0,0 +1,22 @@
--- networkx/convert_matrix.py.orig 2019-04-11 14:52:34.000000000 -0600
+++ networkx/convert_matrix.py 2019-09-11 09:40:18.967671622 -0600
@@ -560,7 +560,7 @@ def from_numpy_matrix(A, parallel_edges=
edges = map(lambda e: (int(e[0]), int(e[1])),
zip(*(np.asarray(A).nonzero())))
# handle numpy constructed data type
- if python_type is 'void':
+ if python_type == 'void':
# Sort the fields by their offset, then by dtype, then by name.
fields = sorted((offset, dtype, name) for name, (dtype, offset) in
A.dtype.fields.items())
--- networkx/drawing/nx_pydot.py.orig 2019-04-11 14:52:34.000000000 -0600
+++ networkx/drawing/nx_pydot.py 2019-09-11 09:40:50.592150597 -0600
@@ -199,7 +199,7 @@ def to_pydot(N):
name = N.name
graph_defaults = N.graph.get('graph', {})
- if name is '':
+ if name == '':
P = pydot.Dot('', graph_type=graph_type, strict=strict,
**graph_defaults)
else:

View File

@ -0,0 +1,27 @@
https://github.com/networkx/networkx/commit/d27930ce099d6f0edca8d5d91d5f3a8d9dc90c9d
Fix deprecation warning with Python 3.7 (#3487)
Replace collections.Iterable with collections.abc.Iterable to fix deprecation warning with Python 3.7:
"DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working"
--- networkx/drawing/nx_pylab.py.orig 2019-09-11 10:14:12.380878784 -0600
+++ networkx/drawing/nx_pylab.py 2019-09-11 10:14:26.196649773 -0600
@@ -373,7 +373,7 @@ def draw_networkx_nodes(G, pos,
draw_networkx_labels()
draw_networkx_edge_labels()
"""
- import collections
+ from collections.abc import Iterable
try:
import matplotlib.pyplot as plt
import numpy as np
@@ -399,7 +399,7 @@ def draw_networkx_nodes(G, pos,
except ValueError:
raise nx.NetworkXError('Bad value in node positions.')
- if isinstance(alpha, collections.Iterable):
+ if isinstance(alpha, Iterable):
node_color = apply_alpha(node_color, alpha, nodelist, cmap, vmin, vmax)
alpha = None

View File

@ -0,0 +1,34 @@
https://github.com/networkx/networkx/commit/ea2c8db07e0047daa649d484c4cf68ec2d9035f7
typo: swap source and target
--- networkx/algorithms/shortest_paths/astar.py.orig 2019-04-11 14:52:34.000000000 -0600
+++ networkx/algorithms/shortest_paths/astar.py 2019-09-11 09:22:19.922448001 -0600
@@ -131,7 +131,7 @@ def astar_path(G, source, target, heuris
enqueued[neighbor] = ncost, h
push(queue, (ncost + h, next(c), neighbor, ncost, curnode))
- raise nx.NetworkXNoPath("Node %s not reachable from %s" % (source, target))
+ raise nx.NetworkXNoPath("Node %s not reachable from %s" % (target, source))
def astar_path_length(G, source, target, heuristic=None, weight='weight'):
--- networkx/algorithms/shortest_paths/weighted.py.orig 2019-04-11 14:52:34.000000000 -0600
+++ networkx/algorithms/shortest_paths/weighted.py 2019-09-11 09:22:46.694007187 -0600
@@ -1422,7 +1422,7 @@ def bellman_ford_path_length(G, source,
return length[target]
except KeyError:
raise nx.NetworkXNoPath(
- "node %s not reachable from %s" % (source, target))
+ "node %s not reachable from %s" % (target, source))
def single_source_bellman_ford_path(G, source, weight='weight'):
@@ -1597,7 +1597,7 @@ def single_source_bellman_ford(G, source
try:
return (dist[target], paths[target])
except KeyError:
- msg = "Node %s not reachable from %s" % (source, target)
+ msg = "Node %s not reachable from %s" % (target, source)
raise nx.NetworkXNoPath(msg)

View File

@ -0,0 +1,33 @@
https://github.com/networkx/networkx/commit/1203164760f7be90d5c3a50ab7ab99f04453af8f
Fix UnionFind set extraction (#3224)
Paths are not guaranteed to be fully pruned by the current
implementation if subtrees are unioned, e.g.:
> uf = UnionFind()
> uf.union(1, 2)
> uf.union(3, 4)
> uf.union(4, 5)
> uf.union(1, 5)
In the current implementation, parents[1]=3 and parents[2]=1.
Thus, the mere call of networkx.utils.groups(parents) will yield a
wrong result:
[set([2]), set([1, 3, 4, 5])]
This patch fixes this behavior by simply doing a "find" operation
(which, in turn, does full path pruning) on every key before calling
groups.
--- networkx/utils/union_find.py.orig 2019-04-11 14:52:34.000000000 -0600
+++ networkx/utils/union_find.py 2019-09-11 09:27:32.240303742 -0600
@@ -90,6 +90,10 @@ class UnionFind:
[['x', 'y'], ['z']]
"""
+ # Ensure fully pruned paths
+ for x in self.parents.keys():
+ _ = self[x] # Evaluated for side-effect only
+
# TODO In Python 3.3+, this should be `yield from ...`.
for block in groups(self.parents).values():
yield block

View File

@ -2,11 +2,33 @@
Name: python-%{srcname}
Version: 2.3
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Creates and Manipulates Graphs and Networks
License: BSD
URL: http://networkx.github.io/
Source0: https://github.com/networkx/networkx/archive/%{srcname}-%{version}.tar.gz
# The football example requires network access, so expect it to fail.
# The parallel betweenness example hangs when executed, possibly due to a
# function that cannot be pickled. In any case, skip it.
Patch0: %{name}-doc.patch
# Fix incorrect uses of the 'is' keyword
Patch1: %{name}-is.patch
# Fix swapped source and target arguments
# https://github.com/networkx/networkx/commit/ea2c8db07e0047daa649d484c4cf68ec2d9035f7
Patch2: %{name}-source-target.patch
# Fix UnionFind set extraction
# https://github.com/networkx/networkx/commit/1203164760f7be90d5c3a50ab7ab99f04453af8f
Patch3: %{name}-union-find.patch
# Replace use of deprecated matplotlib.cbook.iterable with np.iterable
# https://github.com/networkx/networkx/commit/eb3a675c5b2b15e33b0a4a35bcee34d6b81ed94d
Patch4: %{name}-cb-iterable.patch
# Fix the import of Iterable for python 3
# https://github.com/networkx/networkx/commit/d27930ce099d6f0edca8d5d91d5f3a8d9dc90c9d
Patch5: %{name}-iterable.patch
# Fix iterating over a dictionary when the key names may change
# https://github.com/networkx/networkx/commit/52e7b5d8732c84512f5423661f234790ce7b1b5f
Patch6: %{name}-dict-iteration.patch
BuildArch: noarch
BuildRequires: python3-devel
@ -100,15 +122,11 @@ for f in $(grep -FRl %{_bindir}/env .); do
rm $f.orig
done
# The football example requires network access, and the parallel betweenness
# example has a function that cannot be pickled.
sed -i "/expected_failing_examples/s|]|,'../examples/advanced/plot_parallel_betweenness.py','../examples/graph/plot_football.py'&|" doc/conf.py
%build
%py3_build
# Build the documentation
PYTHONPATH=$PWD/build/lib sphinx-build-3 -C doc html
PYTHONPATH=$PWD/build/lib make -C doc html
%install
%py3_install
@ -141,9 +159,15 @@ grep -rlZ '^#!' %{buildroot}%{python3_sitelib}/networkx | xargs -0 chmod a+x
%{python3_sitelib}/networkx*
%files doc
%doc html/*
%doc doc/build/html/*
%changelog
* Wed Sep 11 2019 Jerry James <loganjerry@gmail.com> - 2.3-5
- Add -doc patch to fix building the gallery of examples
- Add -is patch to reduce noise in sagemath
- Add upstream bug fix patches: -source-target, -union-find, -cb-iterable,
-iterable, and -dict-iteration
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 2.3-4
- Rebuilt for Python 3.8