giotto-ai / giotto-tda

A high-performance topological machine learning toolbox in Python
https://giotto-ai.github.io/gtda-docs
Other
858 stars 175 forks source link

Allow more general input to ripser when metric='precomputed', improve/refactor check_point_clouds and add tests #386

Closed ulupo closed 4 years ago

ulupo commented 4 years ago

Types of changes

Description The initial thrust for this PR was the need to lift unnecessary input restrictions in gtda.externals.ripser when metric='precomputed'. Namely, pairwise_distances(X, metric='precomputed') will perform input validation and reject anyX containing negative entries. But the theory of Vietoris-Rips filtrations and the C++ implementation of ripser handle these cases perfectly well.

However, simply removing the call to pairwise_distances in the case metric='precomputed' would have removed useful checks for input shape (square). The point of view was adopted that since gtda.externals.ripser is not exposed to the user via documentation, and is only meant to be called by VietorisRipsPersistence instances, these checks should in fact be moved to the input validation steps in that class, i.e. to the calls to check_point_clouds.

Hence, check_point_clouds was refactored as follows:

Finally, comprehensive tests for check_point_clouds were created.

Checklist