From 74d233893d13507b009ab12e0cc63a164a3f36df Mon Sep 17 00:00:00 2001 From: meliurwen Date: Fri, 3 Feb 2023 13:18:31 +0100 Subject: [PATCH] Updated the `networkx` dependency to the latest version (`3.0`) and updated the code to reflect the change --- setup-requirements.txt | 2 +- src/pyctbn/legacy/estimators/structure_estimator.py | 2 +- tests/estimators/test_structure_estimator.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup-requirements.txt b/setup-requirements.txt index bea6363..96bb0cb 100644 --- a/setup-requirements.txt +++ b/setup-requirements.txt @@ -1,5 +1,5 @@ matplotlib==3.6.3 -networkx==2.8.8 +networkx==3.0 numpy==1.24.1 pandas==1.5.3 scipy==1.10.0 diff --git a/src/pyctbn/legacy/estimators/structure_estimator.py b/src/pyctbn/legacy/estimators/structure_estimator.py index 2810184..9ed3368 100755 --- a/src/pyctbn/legacy/estimators/structure_estimator.py +++ b/src/pyctbn/legacy/estimators/structure_estimator.py @@ -129,7 +129,7 @@ class StructureEstimator(object): :return: The adjacency matrix of the graph ``_complete_graph`` :rtype: numpy.ndArray """ - return nx.adj_matrix(self._complete_graph, self._nodes).toarray().astype(bool) + return nx.adjacency_matrix(self._complete_graph, self._nodes).toarray().astype(bool) def spurious_edges(self) -> typing.List: """Return the spurious edges present in the estimated structure, if a prior net structure is present in diff --git a/tests/estimators/test_structure_estimator.py b/tests/estimators/test_structure_estimator.py index f45925a..9f54e6d 100755 --- a/tests/estimators/test_structure_estimator.py +++ b/tests/estimators/test_structure_estimator.py @@ -103,7 +103,7 @@ class TestStructureEstimator(unittest.TestCase): def test_adjacency_matrix(self): se1 = StructureConstraintBasedEstimator(self.s1, 0.1, 0.1) se1.ctpc_algorithm() - adj_matrix = nx.adj_matrix(self.real_net_structure, self.s1.structure.nodes_labels).toarray().astype(bool) + adj_matrix = nx.adjacency_matrix(self.real_net_structure, self.s1.structure.nodes_labels).toarray().astype(bool) self.assertTrue(np.array_equal(adj_matrix, se1.adjacency_matrix())) def test_save_plot_estimated_graph(self):