Skip to content

Commit

Permalink
Improve error condition and error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jni committed Oct 16, 2023
1 parent 0241322 commit b04b7cb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/skan/csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b04b7cb

Please sign in to comment.