Skip to content

Commit

Permalink
CLN: Remove deprecated numba functions (pandas-dev#53455)
Browse files Browse the repository at this point in the history
CLN/DEPR: Remove deprecated numba functions
  • Loading branch information
lithomas1 authored and topper-123 committed Jun 5, 2023
1 parent 32c9ea9 commit f107695
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
4 changes: 2 additions & 2 deletions pandas/core/groupby/numba_.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def generate_numba_agg_func(
-------
Numba function
"""
numba_func = jit_user_function(func, nopython, nogil, parallel)
numba_func = jit_user_function(func)
if TYPE_CHECKING:
import numba
else:
Expand Down Expand Up @@ -152,7 +152,7 @@ def generate_numba_transform_func(
-------
Numba function
"""
numba_func = jit_user_function(func, nopython, nogil, parallel)
numba_func = jit_user_function(func)
if TYPE_CHECKING:
import numba
else:
Expand Down
33 changes: 5 additions & 28 deletions pandas/core/util/numba_.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
"""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

Expand Down Expand Up @@ -63,27 +60,20 @@ def get_jit_arguments(
return {"nopython": nopython, "nogil": nogil, "parallel": parallel}


def jit_user_function(
func: Callable, nopython: bool, nogil: bool, parallel: bool
) -> Callable:
def jit_user_function(func: Callable) -> Callable:
"""
JIT the user's function given the configurable arguments.
If user function is not jitted already, mark the user's function
as jitable.
Parameters
----------
func : function
user defined function
nopython : bool
nopython parameter for numba.JIT
nogil : bool
nogil parameter for numba.JIT
parallel : bool
parallel parameter for numba.JIT
Returns
-------
function
Numba JITed function
Numba JITed function, or function marked as JITable by numba
"""
if TYPE_CHECKING:
import numba
Expand All @@ -94,19 +84,6 @@ def jit_user_function(
# Don't jit a user passed jitted function
numba_func = func
else:

@numba.generated_jit(nopython=nopython, nogil=nogil, parallel=parallel)
def numba_func(data, *_args):
if getattr(np, func.__name__, False) is func or isinstance(
func, types.BuiltinFunctionType
):
jf = func
else:
jf = numba.jit(func, nopython=nopython, nogil=nogil)

def impl(data, *_args):
return jf(data, *_args)

return impl
numba_func = numba.extending.register_jitable(func)

return numba_func
4 changes: 2 additions & 2 deletions pandas/core/window/numba_.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def generate_numba_apply_func(
-------
Numba function
"""
numba_func = jit_user_function(func, nopython, nogil, parallel)
numba_func = jit_user_function(func)
if TYPE_CHECKING:
import numba
else:
Expand Down Expand Up @@ -207,7 +207,7 @@ def generate_numba_table_func(
-------
Numba function
"""
numba_func = jit_user_function(func, nopython, nogil, parallel)
numba_func = jit_user_function(func)
if TYPE_CHECKING:
import numba
else:
Expand Down

0 comments on commit f107695

Please sign in to comment.