giotto-ai / giotto-tda

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

Allow NumPy functions to pass type checks #692

Closed allispaul closed 4 months ago

allispaul commented 6 months ago

Reference issues/PRs Fixes #682. Fixes #683.

Types of changes

Description As of NumPy 1.25, functions like np.mean are no longer instances of types.FunctionType (because they are C, rather than Python, functions). See this discussion. This was leading to the error in #683 and #682, and causing a number of tests to fail.

This PR fixes the issue by replacing types.FunctionType with typing.Callable. (If this is considered too broad, an alternative solution would be to add type(np.mean) to the relevant type checks; I'd be happy to write this up instead.)

Tests on the files I updated are passing; some other tests are failing for me for reasons having to do with a behavior change in sklearn, unrelated to this PR.

Checklist

matteocao commented 4 months ago

@allispaul thank you for your PR and contribution. as I mentioned in my other message, i will force merge this PR and try to fix all the CI and make a new realease.

thanks!