Skip to content

Commit

Permalink
fix: adapt code so it works with different versions of networkx
Browse files Browse the repository at this point in the history
  • Loading branch information
celprov committed Sep 8, 2023
1 parent 5f95281 commit e5c42e8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mriqc/engine/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,11 @@ def _generate_dependency_list(self, graph):
from nipype.pipeline.engine.utils import topological_sort

self.procs, _ = topological_sort(graph)
self.depidx = nx.to_scipy_sparse_matrix(
graph, nodelist=self.procs, format="lil"
)

#In different versions of networkx, the function is called differently
to_sparse = getattr(nx, 'to_scipy_sparse_array', None) or getattr(nx, 'to_scipy_sparse_matrix')
self.depidx = to_sparse(graph, nodelist=self.procs, format="lil")

self.refidx = self.depidx.astype(int)
self.proc_done = np.zeros(len(self.procs), dtype=bool)
self.proc_pending = np.zeros(len(self.procs), dtype=bool)
Expand Down

0 comments on commit e5c42e8

Please sign in to comment.