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 0a39d27..06fbf32 100644 --- a/neuroml/nml/nml.py +++ b/neuroml/nml/nml.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # -# Generated Tue Oct 15 15:36:13 2024 by generateDS.py version 2.44.1. +# Generated Wed Oct 16 16:30:12 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: @@ -49590,8 +49590,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: