From d36e81a1c795b3f9daaafac2a7ce40e012f3f5ed Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Tue, 10 Oct 2023 08:09:04 -0700 Subject: [PATCH] improve reliability of get_latest_roots --- caveclient/chunkedgraph.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/caveclient/chunkedgraph.py b/caveclient/chunkedgraph.py index 25a28dae..fbfd21cd 100644 --- a/caveclient/chunkedgraph.py +++ b/caveclient/chunkedgraph.py @@ -888,6 +888,12 @@ def suggest_latest_roots( stop_layer = max(1, stop_layer) chunks_orig = self.get_leaves(root_id, stop_layer=stop_layer) + while len(chunks_orig) == 0: + stop_layer -= 1 + if stop_layer == 1: + raise ValueError(f'There were no children for root_id={root_id} at level 2, something is wrong with the chunkedgraph') + chunks_orig = self.get_leaves(root_id, stop_layer=stop_layer) + chunk_list = np.array( [ len(