Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow NumPy functions to pass type checks #692

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

allispaul
Copy link

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

Types of changes

  • 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

  • I have read the guidelines for contributing.
  • 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.

@allispaul allispaul marked this pull request as draft March 19, 2024 23:37
@allispaul allispaul marked this pull request as ready for review March 19, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Cannot run Scaler() [BUG]
1 participant