From b04b7cb7b5e6095a76280f74fdabf35b14783412 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Mon, 16 Oct 2023 16:29:44 +1100 Subject: [PATCH] Improve error condition and error message --- src/skan/csr.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/skan/csr.py b/src/skan/csr.py index c247d553..295a5d5a 100644 --- a/src/skan/csr.py +++ b/src/skan/csr.py @@ -671,10 +671,12 @@ def prune_paths(self, indices: npt.ArrayLike) -> 'Skeleton': """ # warning: slow image_cp = np.copy(self.skeleton_image) - if np.any(np.array(indices) > self.paths.shape[1]): + if not np.all(np.array(indices) < self.n_paths): raise ValueError( - f'The path index {i} does not exist in the ' - 'summary dataframe. Resummarise the skeleton.' + f'The path index {np.max(indices)} does not exist in this ' + f'skeleton. (The highest path index is {self.n_paths}.)\n' + 'If you obtained the index from a summary table, you ' + 'probably need to resummarize the skeleton.' ) for i in indices: pixel_ids_to_wipe = self.path(i)