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

(Do Merge) NumPy 2: Removed dead code conflicting with binary builds against NumPy 2 #9474

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 2 additions & 13 deletions numba/np/ufunc/_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ cleaner_dealloc(PyUFuncCleaner *self)
if (ufunc->functions)
PyArray_free(ufunc->functions);
if (ufunc->types)
PyArray_free(ufunc->types);
PyArray_free((void*)ufunc->types);
if (ufunc->data)
PyArray_free(ufunc->data);
PyArray_free((void*)ufunc->data);
PyObject_Del(self);
}

Expand Down Expand Up @@ -496,7 +496,6 @@ dufunc__add_loop(PyDUFuncObject * self, PyObject * args)
int idx=-1, usertype=NPY_VOID;
int *arg_types_arr=NULL;
PyObject *arg_types=NULL, *loop_obj=NULL, *data_obj=NULL;
PyUFuncGenericFunction old_func=NULL;

if (self->frozen) {
PyErr_SetString(PyExc_ValueError,
Expand Down Expand Up @@ -545,16 +544,6 @@ dufunc__add_loop(PyDUFuncObject * self, PyObject * args)
arg_types_arr, data_ptr) < 0) {
goto _dufunc__add_loop_fail;
}
} else if (PyUFunc_ReplaceLoopBySignature(ufunc,
(PyUFuncGenericFunction)loop_ptr,
arg_types_arr, &old_func) == 0) {
/* TODO: Consider freeing any memory held by the old loop (somehow) */
for (idx = 0; idx < ufunc->ntypes; idx++) {
if (ufunc->functions[idx] == (PyUFuncGenericFunction)loop_ptr) {
ufunc->data[idx] = data_ptr;
break;
}
}
Comment on lines -548 to -557
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a case that reaches this:

from numba import vectorize, types


@vectorize
def foo(x):
    return x

foo.add(tuple([types.intp]))
foo.add(tuple([types.intp]))

I think it is valid for Numba to reject the second .add.

} else {
/* The following is an attempt to loosely follow the allocation
code in Numpy. See ufunc_frompyfunc() in
Expand Down
2 changes: 2 additions & 0 deletions numba/np/ufunc/dufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
intrinsic)
from numba.core.typing import npydecl
from numba.core.typing.templates import AbstractTemplate, signature
from numba.core.compiler_lock import global_compiler_lock
from numba.cpython.unsafe.tuple import tuple_setitem
from numba.np.ufunc import _internal
from numba.parfors import array_analysis
Expand Down Expand Up @@ -232,6 +233,7 @@ def _compile_for_args(self, *args, **kws):
argtys.append(argty)
return self._compile_for_argtys(tuple(argtys))

@global_compiler_lock
def _compile_for_argtys(self, argtys, return_type=None):
"""
Given a tuple of argument types (these should be the array
Expand Down
4 changes: 2 additions & 2 deletions numba/tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2667,11 +2667,11 @@ def test_f_strings(self):
"""
# requires formatting (FORMAT_VALUE) and concatenation (BUILD_STRINGS)
def impl1(a):
return f"AA_{a+3}_B"
return f"AA_{a + 3}_B"

# does not require concatenation
def impl2(a):
return f"{a+2}"
return f"{a + 2}"

# no expression
def impl3(a):
Expand Down