-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
COMPAT: Fix warning with numba >= 0.58.0 #55327
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
Changes from 8 commits
9343eca
aa60545
e6995b6
891c05b
1f7b25e
16a453d
c8bb008
df4f48a
860633b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
"""Common utilities for Numba operations""" | ||
from __future__ import annotations | ||
|
||
import types | ||
from typing import ( | ||
TYPE_CHECKING, | ||
Callable, | ||
) | ||
|
||
import numpy as np | ||
|
||
from pandas.compat._optional import import_optional_dependency | ||
from pandas.errors import NumbaUtilError | ||
|
||
|
@@ -83,6 +86,12 @@ def jit_user_function(func: Callable) -> Callable: | |
if numba.extending.is_jitted(func): | ||
# Don't jit a user passed jitted function | ||
numba_func = func | ||
elif getattr(np, func.__name__, False) is func or isinstance( | ||
func, types.BuiltinFunctionType | ||
): | ||
# Not necessary to jit builtins or np functions | ||
# This will mess up register_jitable | ||
numba_func = func | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor thing... I think this breaks the implied contract in the function name Perhaps it would be good to add a unit test that exercises this path with view of preventing a similar issue in future (assuming there isn't one present now?). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the slow reply here. I think this should be fine - the return type in the docstring says it can return a function that is JITable by numba. (In the pandas code, I also don't think there's anywhere where we directly apply the jitted user function on data (we always pass it to another jitted function that calls the output from jit_user_function).) Will add a test for this, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking this and adding the test. |
||
else: | ||
numba_func = numba.extending.register_jitable(func) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should belong in the
Other
section, and the other entries have already been moved I believe