jni / skan

Python module to analyse skeleton (thin object) images
https://skeleton-analysis.org
BSD 3-Clause "New" or "Revised" License
118 stars 40 forks source link

Improved error reporting and tests for prune_paths() methods #212

Closed ns-rse closed 1 year ago

ns-rse commented 1 year ago

Closes #206

The error arises during usage of csr.Skeleton.prune_paths() which takes a list of indices, typical from csr.summarize(), which are to be pruned. If the index is outside of the range of rows in the data frame a ValueError is thrown.

It was first highlighted during early development of pruning iteratively but can arise any time in inappropriate value that is greater than the number of paths in a skeleton is passed to prune_path() method.

A try: ... except: ... is introduced to capture this and report, hopefully informatively, what the problem is and how to correct it. Tests are introduced for this method, parametrized to test removing different types of paths along with tests of two exceptions that can arise.

jni commented 1 year ago

@ns-rse Thinking about this: I think we can catch early and fail: if np.any(np.array(indices_to_remove) > len(self.paths))? Something like that?

ns-rse commented 1 year ago

The @slackline account is my personal rather than work account sorry for the mistake.

jni commented 1 year ago

I've pushed a few changes, we can probably merge this live in a bit. 😊