AFM-SPM / TopoStats

An AFM image analysis program to batch process data and obtain statistics from images
https://afm-spm.github.io/TopoStats/
GNU Lesser General Public License v3.0
57 stars 10 forks source link

tests: Adapts get_skeleton() tests to the getSkeleton() class #821

Closed ns-rse closed 5 months ago

ns-rse commented 5 months ago

First step in adding tests to the maxgamill-Sheffield/800-better-tracing.

Tests

IMPORTANT

I noticed whilst developing the tests that the tests on a circular molecule with height_bias = 0.6 results in a strange skeleton. The ring of the circle is correct but there is a branch in the bottom right (search tests/tracing/test_skeletonize.py for TopoStats, circular, height_bias 0.6 and the array that is produced is above this).

This probably isn't what is expected but is worth giving some consideration to now because if such artifacts are produced on simple test cases its quite possible that we will get unwanted artifacts in more complex situations.

Additional Linting

Because I modified topostats/tracing/skeletonize.py it was linted as part of the pre-commit checks which include ruff, pylint and now numpydoc-validation, it had a lot of issues. I have therefore linted this file and...

Some of the disabled checks (line numbers are rough but should get you close)

Ruff

topostats/tracing/skeletonize.py:597:34: B006 Do not use mutable data structures for argument defaults
topostats/tracing/skeletonize.py:775:9: C901 `_prune_by_length` is too complex (11 > 10)

Pylint

topostats/tracing/skeletonize.py:1:0: C0302: Too many lines in module (1399/1000) (too-many-lines)
topostats/tracing/skeletonize.py:17:0: R0903: Too few public methods (1/2) (too-few-public-methods)
topostats/tracing/skeletonize.py:187:0: R0902: Too many instance attributes (13/7) (too-many-instance-attributes)
topostats/tracing/skeletonize.py:595:4: W0102: Dangerous default value {} as argument (dangerous-default-value)
topostats/tracing/skeletonize.py:567:0: R0903: Too few public methods (1/2) (too-few-public-methods)
topostats/tracing/skeletonize.py:768:36: E1121: Too many positional arguments for method call (too-many-function-args)
topostats/tracing/skeletonize.py:773:4: R0914: Too many local variables (18/15) (too-many-locals)
topostats/tracing/skeletonize.py:685:0: R0903: Too few public methods (1/2) (too-few-public-methods)
topostats/tracing/skeletonize.py:958:36: E1121: Too many positional arguments for method call (too-many-function-args)
topostats/tracing/skeletonize.py:875:0: R0903: Too few public methods (1/2) (too-few-public-methods)
topostats/tracing/skeletonize.py:1179:4: R0914: Too many local variables (16/15) (too-many-locals)
topostats/tracing/skeletonize.py:1335:0: R0914: Too many local variables (19/15) (too-many-locals)

Some hopefully useful comments on how to resolve some of these...

More importantly it is considerably easier to address these during development/writing of code and not at the end in a big "clean-up". We have pre-commit hooks in place and should use them and address issues that are reported on every commit even if it is tempting to bypass them.