Skip to content

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

Merged
merged 9 commits into from
Jan 11, 2024

Conversation

lithomas1
Copy link
Member

@lithomas1 lithomas1 commented Sep 29, 2023

@lithomas1 lithomas1 added Compat pandas objects compatability with Numpy or Python functions numba numba-accelerated operations labels Sep 29, 2023
@@ -79,10 +81,17 @@ def jit_user_function(func: Callable) -> Callable:
import numba
else:
numba = import_optional_dependency("numba")
import types
Copy link
Member

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?

@lithomas1
Copy link
Member Author

pre-commit.ci autofix

):
# Not necessary to jit builtins or np functions
# This will mess up register_jitable
numba_func = func

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?).

Copy link
Member Author

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.

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.

Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Nov 12, 2023
@lithomas1 lithomas1 added this to the 2.2 milestone Dec 28, 2023
@lithomas1 lithomas1 removed the Stale label Dec 28, 2023
@lithomas1
Copy link
Member Author

pre-commit.ci autofix

@lithomas1
Copy link
Member Author

@mroeschke

Can you take another look at this?
This would be nice to have for 2.2.

- 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`)
Copy link
Member

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

@mroeschke
Copy link
Member

Looks good just a comment

@mroeschke mroeschke merged commit 5955ca6 into pandas-dev:main Jan 11, 2024
@mroeschke
Copy link
Member

Thanks @lithomas1

lithomas1 added a commit that referenced this pull request Jan 11, 2024
… 0.58.0) (#56820)

Backport PR #55327: COMPAT: Fix warning with numba >= 0.58.0

Co-authored-by: Thomas Li <[email protected]>
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions numba numba-accelerated operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: NumbaPendingDeprecationWarning with numba 0.58.0
3 participants