-
-
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
Conversation
pandas/core/util/numba_.py
Outdated
@@ -79,10 +81,17 @@ def jit_user_function(func: Callable) -> Callable: | |||
import numba | |||
else: | |||
numba = import_optional_dependency("numba") | |||
import types |
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.
Could we import this at the top?
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
): | ||
# 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 comment
The 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 jit_user_function
, because this is returning a function that is not jit-compiled (and has also probably not come from user derived source!). I do however think it is likely restore the functionality of being able to pass a NumPy or builtin function to rolling.apply
xref: #55247 (comment).
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking this and adding the test.
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Can you take another look at this? |
doc/source/whatsnew/v2.2.0.rst
Outdated
- Bug in :class:`pandas.core.window.Rolling` where duplicate datetimelike indexes are treated as consecutive rather than equal with ``closed='left'`` and ``closed='neither'`` (:issue:`20712`) | ||
- Bug in :meth:`DataFrame.apply` where passing ``raw=True`` ignored ``args`` passed to the applied function (:issue:`55009`) | ||
- Bug in :meth:`pandas.read_excel` with a ODS file without cached formatted cell for float values (:issue:`55219`) | ||
- Fixed a spurious deprecation warning from ``numba`` >= 0.58.0 when passing a numpy ufunc in :class:`pandas.core.window.Rolling.apply` with ``engine="numba"`` (:issue:`55247`) |
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
Looks good just a comment |
Thanks @lithomas1 |
… 0.58.0) (#56820) Backport PR #55327: COMPAT: Fix warning with numba >= 0.58.0 Co-authored-by: Thomas Li <[email protected]>
* COMPAT: Fix warning with numba >= 0.58.0 * Update numba_.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add a test * skip if no numba * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update v2.2.0.rst --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.