From be82d6d318b34f30758510a85884b8559ccf61a5 Mon Sep 17 00:00:00 2001 From: Philipp Schlegel Date: Sun, 5 Jan 2025 13:00:04 +0000 Subject: [PATCH] _generate_segments: return list of arrays in vanilla implementation --- navis/graph/graph_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/navis/graph/graph_utils.py b/navis/graph/graph_utils.py index 2ab1e31f..ea93d19a 100644 --- a/navis/graph/graph_utils.py +++ b/navis/graph/graph_utils.py @@ -150,14 +150,17 @@ def _generate_segments( lengths = [d[s[0]] - d[s[-1]] for s in sequences] sequences = [x for _, x in sorted(zip(lengths, sequences), reverse=True)] + # Turn into list of arrays + sequences = [np.array(s) for s in sequences] + # Isolated nodes would not be included in the sequences(because they are treated # as roots, not leafs. Let's add them manually here. for node in nx.isolates(x.graph): - sequences.append([node]) + sequences.append(np.array([node])) lengths.append(0) if return_lengths: - return sequences, sorted(lengths, reverse=True) + return sequences, np.array(sorted(lengths, reverse=True)) else: return sequences