1
0

Accepting request 833761 from devel:languages:python:numeric

OBS-URL: https://build.opensuse.org/request/show/833761
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-networkx?expand=0&rev=24
This commit is contained in:
Dominique Leuenberger 2020-09-14 10:16:42 +00:00 committed by Git OBS Bridge
commit bfb48b7651
8 changed files with 59 additions and 492 deletions

View File

@ -0,0 +1,17 @@
From: Antonio Larrosa <alarrosa@suse.com>
Subject: Disable test that fails on i586
The issue was reported at https://github.com/networkx/networkx/issues/4203
Index: networkx-2.5/networkx/algorithms/shortest_paths/tests/test_weighted.py
===================================================================
--- networkx-2.5.orig/networkx/algorithms/shortest_paths/tests/test_weighted.py
+++ networkx-2.5/networkx/algorithms/shortest_paths/tests/test_weighted.py
@@ -230,7 +230,7 @@ class TestWeightedPath(WeightedTestBase)
vlp(G, s, t, length, nx.single_source_dijkstra, weight)
vlp(G, s, t, length, nx.single_source_bellman_ford, weight)
vlp(G, s, t, length, goldberg_radzik, weight)
- vlp(G, s, t, length, astar, weight)
+ #vlp(G, s, t, length, astar, weight)
def weight(u, v, _):
return 2 ** (u * v)

View File

@ -1,23 +0,0 @@
From 3987370c957de15249809672933dc06c2fed6fc1 Mon Sep 17 00:00:00 2001
From: Jarrod Millman <jarrod.millman@gmail.com>
Date: Wed, 30 Oct 2019 05:22:12 -0700
Subject: [PATCH] Fix matplotlib deprecation (#3697)
Fixes #3694
---
networkx/drawing/tests/test_pylab.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/networkx/drawing/tests/test_pylab.py b/networkx/drawing/tests/test_pylab.py
index 2ecd268d37..0fd3773b06 100644
--- a/networkx/drawing/tests/test_pylab.py
+++ b/networkx/drawing/tests/test_pylab.py
@@ -172,7 +172,7 @@ def test_multigraph_edgelist_tuples(self):
# See Issue #3295
G = nx.path_graph(3, create_using=nx.MultiDiGraph)
nx.draw_networkx(G, edgelist=[(0, 1, 0)])
- nx.draw_networkx(G, edgelist=[(0, 1, 0)], node_size=[10, 20])
+ nx.draw_networkx(G, edgelist=[(0, 1, 0)], node_size=[10, 20, 0])
def test_alpha_iter(self):
pos = nx.random_layout(self.G)

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f8f4ff0b6f96e4f9b16af6b84622597b5334bf9cae8cf9b2e42e7985d5c95c64
size 1462338

3
networkx-2.5.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7978955423fbc9639c10498878be59caf99b44dc304c2286162fd24b458c1602
size 1542085

View File

@ -1,390 +0,0 @@
From 83bf28a8f46a311f2bc277eab66226f6b9117c1d Mon Sep 17 00:00:00 2001
From: Ram Rachum <ram@rachum.com>
Date: Sun, 21 Jun 2020 22:24:11 +0300
Subject: [PATCH 1/2] Fix exception causes and messages in 12 modules
---
examples/subclass/plot_antigraph.py | 4 +--
.../algorithms/approximation/kcomponents.py | 4 +--
.../algorithms/assortativity/correlation.py | 18 +++++-----
networkx/algorithms/bipartite/cluster.py | 4 +--
networkx/algorithms/bipartite/edgelist.py | 19 +++++-----
networkx/algorithms/bipartite/matching.py | 4 +--
networkx/algorithms/bipartite/matrix.py | 4 +--
networkx/algorithms/bipartite/spectral.py | 4 +--
.../centrality/current_flow_betweenness.py | 36 +++++++++----------
.../current_flow_betweenness_subset.py | 20 +++++------
networkx/algorithms/centrality/katz.py | 12 +++----
.../algorithms/centrality/second_order.py | 4 +--
12 files changed, 68 insertions(+), 65 deletions(-)
Index: networkx-2.4/examples/subclass/plot_antigraph.py
===================================================================
--- networkx-2.4.orig/examples/subclass/plot_antigraph.py
+++ networkx-2.4/examples/subclass/plot_antigraph.py
@@ -71,8 +71,8 @@ class AntiGraph(nx.Graph):
"""
try:
return iter(set(self.adj) - set(self.adj[n]) - set([n]))
- except KeyError:
- raise NetworkXError("The node %s is not in the graph." % (n,))
+ except KeyError as e:
+ raise NetworkXError("The node %s is not in the graph." % (n,)) from e
def degree(self, nbunch=None, weight=None):
"""Return an iterator for (node, degree) in the dense graph.
Index: networkx-2.4/networkx/algorithms/approximation/kcomponents.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/approximation/kcomponents.py
+++ networkx-2.4/networkx/algorithms/approximation/kcomponents.py
@@ -245,8 +245,8 @@ class _AntiGraph(nx.Graph):
"""
try:
return iter(set(self._adj) - set(self._adj[n]) - set([n]))
- except KeyError:
- raise NetworkXError("The node %s is not in the graph." % (n,))
+ except KeyError as e:
+ raise NetworkXError("The node %s is not in the graph." % (n,)) from e
class AntiAtlasView(Mapping):
"""An adjacency inner dict for AntiGraph"""
Index: networkx-2.4/networkx/algorithms/assortativity/correlation.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/assortativity/correlation.py
+++ networkx-2.4/networkx/algorithms/assortativity/correlation.py
@@ -132,9 +132,9 @@ def degree_pearson_correlation_coefficie
"""
try:
import scipy.stats as stats
- except ImportError:
- raise ImportError(
- "Assortativity requires SciPy: http://scipy.org/ ")
+ except ImportError as e:
+ raise ImportError("Assortativity requires SciPy:"
+ "http://scipy.org/ ") from e
xy = node_degree_xy(G, x=x, y=y, nodes=nodes, weight=weight)
x, y = zip(*xy)
return stats.pearsonr(x, y)[0]
@@ -254,9 +254,9 @@ def attribute_ac(M):
"""
try:
import numpy
- except ImportError:
- raise ImportError(
- "attribute_assortativity requires NumPy: http://scipy.org/ ")
+ except ImportError as e:
+ raise ImportError('attribute_assortativity requires '
+ 'NumPy: http://scipy.org/') from e
if M.sum() != 1.0:
M = M / float(M.sum())
M = numpy.asmatrix(M)
@@ -271,9 +271,9 @@ def numeric_ac(M):
# numeric assortativity coefficient, pearsonr
try:
import numpy
- except ImportError:
- raise ImportError('numeric_assortativity requires ',
- 'NumPy: http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('numeric_assortativity requires '
+ 'NumPy: http://scipy.org/') from e
if M.sum() != 1.0:
M = M / float(M.sum())
nx, ny = M.shape # nx=ny
Index: networkx-2.4/networkx/algorithms/bipartite/cluster.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/bipartite/cluster.py
+++ networkx-2.4/networkx/algorithms/bipartite/cluster.py
@@ -115,9 +115,9 @@ def latapy_clustering(G, nodes=None, mod
try:
cc_func = modes[mode]
- except KeyError:
+ except KeyError as e:
raise nx.NetworkXError(
- "Mode for bipartite clustering must be: dot, min or max")
+ "Mode for bipartite clustering must be: dot, min or max") from e
if nodes is None:
nodes = G
Index: networkx-2.4/networkx/algorithms/bipartite/edgelist.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/bipartite/edgelist.py
+++ networkx-2.4/networkx/algorithms/bipartite/edgelist.py
@@ -139,8 +139,8 @@ def generate_edgelist(G, delimiter=' ',
"""
try:
part0 = [n for n, d in G.nodes.items() if d['bipartite'] == 0]
- except:
- raise AttributeError("Missing node attribute `bipartite`")
+ except BaseException as e:
+ raise AttributeError("Missing node attribute `bipartite`") from e
if data is True or data is False:
for n in part0:
for e in G.edges(n, data=data):
@@ -242,9 +242,9 @@ def parse_edgelist(lines, comments='#',
try:
u = nodetype(u)
v = nodetype(v)
- except:
+ except BaseException as e:
raise TypeError("Failed to convert nodes %s,%s to type %s."
- % (u, v, nodetype))
+ % (u, v, nodetype)) from e
if len(d) == 0 or data is False:
# no data or data type specified
@@ -253,9 +253,9 @@ def parse_edgelist(lines, comments='#',
# no edge types specified
try: # try to evaluate as dictionary
edgedata = dict(literal_eval(' '.join(d)))
- except:
- raise TypeError(
- "Failed to convert edge data (%s) to dictionary." % (d))
+ except BaseException as e:
+ raise TypeError("Failed to convert edge data"
+ " (%s) to dictionary." % (d)) from e
else:
# convert edge data to dictionary with specified keys and type
if len(d) != len(data):
@@ -266,10 +266,10 @@ def parse_edgelist(lines, comments='#',
for (edge_key, edge_type), edge_value in zip(data, d):
try:
edge_value = edge_type(edge_value)
- except:
+ except BaseException as e:
raise TypeError(
"Failed to convert %s data %s to type %s."
- % (edge_key, edge_value, edge_type))
+ % (edge_key, edge_value, edge_type)) from e
edgedata.update({edge_key: edge_value})
G.add_node(u, bipartite=0)
G.add_node(v, bipartite=1)
Index: networkx-2.4/networkx/algorithms/bipartite/matching.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/bipartite/matching.py
+++ networkx-2.4/networkx/algorithms/bipartite/matching.py
@@ -555,9 +555,9 @@ def minimum_weight_full_matching(G, top_
"""
try:
import scipy.optimize
- except ImportError:
+ except ImportError as e:
raise ImportError('minimum_weight_full_matching requires SciPy: ' +
- 'https://scipy.org/')
+ 'https://scipy.org/') from e
left, right = nx.bipartite.sets(G, top_nodes)
# Ensure that the graph is complete. This is currently a requirement in
# the underlying optimization algorithm from SciPy, but the constraint
Index: networkx-2.4/networkx/algorithms/bipartite/matrix.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/bipartite/matrix.py
+++ networkx-2.4/networkx/algorithms/bipartite/matrix.py
@@ -109,8 +109,9 @@ def biadjacency_matrix(G, row_order, col
return M.asformat(format)
# From Scipy 1.1.0, asformat will throw a ValueError instead of an
# AttributeError if the format if not recognized.
- except (AttributeError, ValueError):
- raise nx.NetworkXError("Unknown sparse matrix format: %s" % format)
+ except (AttributeError, ValueError) as e:
+ raise nx.NetworkXError(
+ "Unknown sparse matrix format: %s" % format) from e
def from_biadjacency_matrix(A, create_using=None, edge_attribute='weight'):
Index: networkx-2.4/networkx/algorithms/bipartite/spectral.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/bipartite/spectral.py
+++ networkx-2.4/networkx/algorithms/bipartite/spectral.py
@@ -56,9 +56,9 @@ def spectral_bipartivity(G, nodes=None,
"""
try:
import scipy.linalg
- except ImportError:
+ except ImportError as e:
raise ImportError('spectral_bipartivity() requires SciPy: ',
- 'http://scipy.org/')
+ 'http://scipy.org/') from e
nodelist = list(G) # ordering of nodes in matrix
A = nx.to_numpy_matrix(G, nodelist, weight=weight)
expA = scipy.linalg.expm(A)
Index: networkx-2.4/networkx/algorithms/centrality/current_flow_betweenness.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/centrality/current_flow_betweenness.py
+++ networkx-2.4/networkx/algorithms/centrality/current_flow_betweenness.py
@@ -90,15 +90,15 @@ def approximate_current_flow_betweenness
"""
try:
import numpy as np
- except ImportError:
- raise ImportError('current_flow_betweenness_centrality requires NumPy ',
- 'http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('current_flow_betweenness_centrality requires NumPy '
+ 'http://scipy.org/') from e
try:
from scipy import sparse
from scipy.sparse import linalg
- except ImportError:
- raise ImportError('current_flow_betweenness_centrality requires SciPy ',
- 'http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('current_flow_betweenness_centrality requires SciPy '
+ 'http://scipy.org/') from e
if not nx.is_connected(G):
raise nx.NetworkXError("Graph not connected.")
solvername = {"full": FullInverseLaplacian,
@@ -214,14 +214,14 @@ def current_flow_betweenness_centrality(
"""
try:
import numpy as np
- except ImportError:
- raise ImportError('current_flow_betweenness_centrality requires NumPy ',
- 'http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('current_flow_betweenness_centrality requires NumPy '
+ 'http://scipy.org/') from e
try:
import scipy
- except ImportError:
- raise ImportError('current_flow_betweenness_centrality requires SciPy ',
- 'http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('current_flow_betweenness_centrality requires SciPy '
+ 'http://scipy.org/') from e
if not nx.is_connected(G):
raise nx.NetworkXError("Graph not connected.")
n = G.number_of_nodes()
@@ -326,14 +326,14 @@ def edge_current_flow_betweenness_centra
from networkx.utils import reverse_cuthill_mckee_ordering
try:
import numpy as np
- except ImportError:
- raise ImportError('current_flow_betweenness_centrality requires NumPy ',
- 'http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('current_flow_betweenness_centrality requires NumPy '
+ 'http://scipy.org/') from e
try:
import scipy
- except ImportError:
- raise ImportError('current_flow_betweenness_centrality requires SciPy ',
- 'http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('current_flow_betweenness_centrality requires SciPy '
+ 'http://scipy.org/') from e
if not nx.is_connected(G):
raise nx.NetworkXError("Graph not connected.")
n = G.number_of_nodes()
Index: networkx-2.4/networkx/algorithms/centrality/current_flow_betweenness_subset.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/centrality/current_flow_betweenness_subset.py
+++ networkx-2.4/networkx/algorithms/centrality/current_flow_betweenness_subset.py
@@ -99,14 +99,14 @@ def current_flow_betweenness_centrality_
from networkx.utils import reverse_cuthill_mckee_ordering
try:
import numpy as np
- except ImportError:
+ except ImportError as e:
raise ImportError('current_flow_betweenness_centrality requires NumPy ',
- 'http://scipy.org/')
+ 'http://scipy.org/') from e
try:
import scipy
- except ImportError:
+ except ImportError as e:
raise ImportError('current_flow_betweenness_centrality requires SciPy ',
- 'http://scipy.org/')
+ 'http://scipy.org/') from e
if not nx.is_connected(G):
raise nx.NetworkXError("Graph not connected.")
n = G.number_of_nodes()
@@ -214,14 +214,14 @@ def edge_current_flow_betweenness_centra
"""
try:
import numpy as np
- except ImportError:
- raise ImportError('current_flow_betweenness_centrality requires NumPy ',
- 'http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('current_flow_betweenness_centrality requires NumPy '
+ 'http://scipy.org/') from e
try:
import scipy
- except ImportError:
- raise ImportError('current_flow_betweenness_centrality requires SciPy ',
- 'http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('current_flow_betweenness_centrality requires SciPy '
+ 'http://scipy.org/') from e
if not nx.is_connected(G):
raise nx.NetworkXError("Graph not connected.")
n = G.number_of_nodes()
Index: networkx-2.4/networkx/algorithms/centrality/katz.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/centrality/katz.py
+++ networkx-2.4/networkx/algorithms/centrality/katz.py
@@ -160,11 +160,11 @@ def katz_centrality(G, alpha=0.1, beta=1
try:
b = dict.fromkeys(G, float(beta))
- except (TypeError, ValueError, AttributeError):
+ except (TypeError, ValueError, AttributeError) as e:
b = beta
if set(beta) != set(G):
raise nx.NetworkXError('beta dictionary '
- 'must have a value for every node')
+ 'must have a value for every node') from e
# make up to max_iter iterations
for i in range(max_iter):
@@ -308,8 +308,8 @@ def katz_centrality_numpy(G, alpha=0.1,
"""
try:
import numpy as np
- except ImportError:
- raise ImportError('Requires NumPy: http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('Requires NumPy: http://numpy.org/') from e
if len(G) == 0:
return {}
try:
@@ -322,8 +322,8 @@ def katz_centrality_numpy(G, alpha=0.1,
nodelist = list(G)
try:
b = np.ones((len(nodelist), 1)) * float(beta)
- except (TypeError, ValueError, AttributeError):
- raise nx.NetworkXError('beta must be a number')
+ except (TypeError, ValueError, AttributeError) as e:
+ raise nx.NetworkXError('beta must be a number') from e
A = nx.adj_matrix(G, nodelist=nodelist, weight=weight).todense().T
n = A.shape[0]
Index: networkx-2.4/networkx/algorithms/centrality/second_order.py
===================================================================
--- networkx-2.4.orig/networkx/algorithms/centrality/second_order.py
+++ networkx-2.4/networkx/algorithms/centrality/second_order.py
@@ -99,8 +99,8 @@ def second_order_centrality(G):
try:
import numpy as np
- except ImportError:
- raise ImportError('Requires NumPy: http://scipy.org/')
+ except ImportError as e:
+ raise ImportError('Requires NumPy: http://numpy.org/') from e
n = len(G)
Index: networkx-2.4/networkx/drawing/tests/test_pylab.py
===================================================================
--- networkx-2.4.orig/networkx/drawing/tests/test_pylab.py
+++ networkx-2.4/networkx/drawing/tests/test_pylab.py
@@ -4,7 +4,7 @@ import itertools
import pytest
mpl = pytest.importorskip('matplotlib')
-mpl.use('PS', warn=False)
+mpl.use('PS')
plt = pytest.importorskip('matplotlib.pyplot')
plt.rcParams['text.usetex'] = False

View File

@ -1,69 +0,0 @@
diff --git a/networkx/readwrite/tests/test_gexf.py b/networkx/readwrite/tests/test_gexf.py
index afc40111..f16504c0 100644
--- a/networkx/readwrite/tests/test_gexf.py
+++ b/networkx/readwrite/tests/test_gexf.py
@@ -404,7 +404,8 @@ gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd" version="1.2">
nx.set_node_attributes(G, {n: n for n in numpy.arange(4)}, 'number')
G[0][1]['edge-number'] = numpy.float64(1.1)
- expected = """<gexf version="1.2" xmlns="http://www.gexf.net/1.2draft"\
+ if sys.version_info < (3, 8):
+ expected = """<gexf version="1.2" xmlns="http://www.gexf.net/1.2draft"\
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation\
="http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd">
<meta lastmodifieddate="{}">
@@ -449,6 +450,54 @@ gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd" version="1.2">
<edge id="2" source="2" target="3" />
</edges>
</graph>
+</gexf>""".format(time.strftime('%Y-%m-%d'), nx.__version__)
+ else:
+ expected = """<gexf xmlns="http://www.gexf.net/1.2draft"\
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation\
+="http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd"\
+ version="1.2">
+ <meta lastmodifieddate="{}">
+ <creator>NetworkX {}</creator>
+ </meta>
+ <graph defaultedgetype="undirected" mode="static" name="">
+ <attributes mode="static" class="edge">
+ <attribute id="1" title="edge-number" type="float" />
+ </attributes>
+ <attributes mode="static" class="node">
+ <attribute id="0" title="number" type="int" />
+ </attributes>
+ <nodes>
+ <node id="0" label="0">
+ <attvalues>
+ <attvalue for="0" value="0" />
+ </attvalues>
+ </node>
+ <node id="1" label="1">
+ <attvalues>
+ <attvalue for="0" value="1" />
+ </attvalues>
+ </node>
+ <node id="2" label="2">
+ <attvalues>
+ <attvalue for="0" value="2" />
+ </attvalues>
+ </node>
+ <node id="3" label="3">
+ <attvalues>
+ <attvalue for="0" value="3" />
+ </attvalues>
+ </node>
+ </nodes>
+ <edges>
+ <edge source="0" target="1" id="0">
+ <attvalues>
+ <attvalue for="1" value="1.1" />
+ </attvalues>
+ </edge>
+ <edge source="1" target="2" id="1" />
+ <edge source="2" target="3" id="2" />
+ </edges>
+ </graph>
</gexf>""".format(time.strftime('%Y-%m-%d'), nx.__version__)
obtained = '\n'.join(nx.generate_gexf(G))
assert expected == obtained

View File

@ -1,3 +1,40 @@
-------------------------------------------------------------------
Fri Sep 11 06:08:25 UTC 2020 - Antonio Larrosa <alarrosa@suse.com>
- Update to 2.5:
* Highlights:
+ Dropped support for Python 3.5.
+ add Pathlib support to work with files.
+ improve performance.
+ Updated docs and tests.
+ Removed code designed to work with Python 2.
* New Functions:
+ lukes_partitioning
+ triadic analysis functions
+ functions for trophic levels analysis
+ d_separated
+ is_regular and other regular graph measures
+ graph_hash using Weisfeiler Lehman methods
+ common_neighbor_centrality (CCPA link prediction)
+ max_weight_clique
+ path_weight and is_path
+ rescale_layout_dict
+ junction_tree
* New generators:
+ paley_graph
+ interval_graph
* New layouts:
+ multipartite_layout
- To see improvements, API changes and deprecations, please visit:
https://networkx.github.io/documentation/stable/release/release_2.5.html
- Dropped patches already included by upstream:
* numpy-38-test.patch
* matplotlib.patch
* networkx-pr4012-use-mpl.patch
- Add patch to remove a failing test in i586. The issue was
submitted to upstream at gh#networkx/networkx#4203:
* disable-test-failing-in-i586.patch
-------------------------------------------------------------------
Tue Jul 21 16:10:13 UTC 2020 - Benjamin Greiner <code@bnavigator.de>

View File

@ -19,18 +19,13 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-networkx
Version: 2.4
Version: 2.5
Release: 0
Summary: Python package for the study of complex networks
License: BSD-3-Clause
URL: https://networkx.github.io/
Source: https://files.pythonhosted.org/packages/source/n/networkx/networkx-%{version}.tar.gz
# UPSTREAM PATCH: gh#networkx/networkx#3724
Patch0: numpy-38-test.patch
# UPSTREAM PATCH: gh#networkx/networkx#3697
Patch1: matplotlib.patch
# UPSTREAM PATCH: gh#networkx/networkx#4012
Patch2: networkx-pr4012-use-mpl.patch
Patch0: disable-test-failing-in-i586.patch
BuildRequires: %{python_module PyYAML}
BuildRequires: %{python_module decorator >= 3.4.0}
BuildRequires: %{python_module matplotlib >= 3.1}