From f5c189b1355e49bdbcf08dd01dd61bcf36db56c1 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 16 Oct 2024 16:28:37 +0100 Subject: [PATCH] fix(nml): get-segment-info stop when reached cell root --- neuroml/nml/helper_methods.py | 9 +++++++-- neuroml/nml/nml.py | 11 ++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/neuroml/nml/helper_methods.py b/neuroml/nml/helper_methods.py index dbe1cc5..a394630 100644 --- a/neuroml/nml/helper_methods.py +++ b/neuroml/nml/helper_methods.py @@ -2471,8 +2471,13 @@ def get_segment_location_info(self, seg_id): sg_root = current current = parent - parent = list(graph.predecessors(current))[0] - children = list(graph.successors(parent)) + try: + parent = list(graph.predecessors(current))[0] + children = list(graph.successors(parent)) + # if reached root, this will error because root has no + # predecessors, so we break + except IndexError: + break distance_from_bpt = self.get_distance(seg_id, source=current) else: diff --git a/neuroml/nml/nml.py b/neuroml/nml/nml.py index b5ea5db..b19790d 100644 --- a/neuroml/nml/nml.py +++ b/neuroml/nml/nml.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # -# Generated Fri Sep 13 14:23:30 2024 by generateDS.py version 2.44.1. +# Generated Wed Oct 16 16:26:54 2024 by generateDS.py version 2.44.1. # Python 3.11.10 (main, Sep 9 2024, 00:00:00) [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)] # # Command line options: @@ -50047,8 +50047,13 @@ def get_segment_location_info(self, seg_id): sg_root = current current = parent - parent = list(graph.predecessors(current))[0] - children = list(graph.successors(parent)) + try: + parent = list(graph.predecessors(current))[0] + children = list(graph.successors(parent)) + # if reached root, this will error because root has no + # predecessors, so we break + except IndexError: + break distance_from_bpt = self.get_distance(seg_id, source=current) else: