giotto-tda
giotto-tda copied to clipboard
Allow NumPy functions to pass type checks
Reference issues/PRs Fixes #682. Fixes #683.
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
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
- [x] I have read the guidelines for contributing.
- [x] My code follows the code style of this project. I used
flake8
to check my Python changes. - [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed. I used
pytest
to check this on Python tests.