Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix CI bug
  • Loading branch information
guilhermeleobas committed Oct 26, 2023
commit c706afa1d04bd3f2e1eab1a6ec5acc4969781396
7 changes: 3 additions & 4 deletions numba/np/ufunc/_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,9 @@ dufunc_setfrozen(PyDUFuncObject * self, PyObject * value, void * closure)
if (PyObject_IsTrue(value)) {
self->frozen = 1;
} else {
self->frozen = 0;
// PyErr_SetString(PyExc_ValueError,
// "cannot clear the _DUFunc.frozen flag");
// result = -1;
PyErr_SetString(PyExc_ValueError,
"cannot clear the _DUFunc.frozen flag");
result = -1;
}
return result;
}
Expand Down
2 changes: 0 additions & 2 deletions numba/np/ufunc/dufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,12 @@ def ol_at(ufunc, a, indices, b=None):
if nin == 1 and not cgutils.is_nonelike(b):
raise TypeError('second operand provided when ufunc is unary')

self._frozen = False
if cgutils.is_nonelike(b):
self.add((a.dtype,))
elif b_scalar:
self.add((a.dtype, b))
else:
self.add((a.dtype, b.dtype))
self._frozen = True

def impl_b_none(ufunc, a, indices, b=None):
for idx in indices:
Expand Down
22 changes: 14 additions & 8 deletions numba/tests/npyufunc/test_dufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,23 @@ def impl():


class TestDUFuncAt(TestCase):
def _compare_output(self, fn, a, *args):
def _compare_output(self, fn, ufunc, a, *args):
expected = a.copy()
got = a.copy()
fn.py_func(expected, *args)
ufunc.at(expected, *args)
fn(got, *args)
self.assertPreciseEqual(expected, got)

def _generate_jit(self, ufunc):
if ufunc.nin == 2:
vec = vectorize('int64(int64, int64)')(lambda a, b: ufunc(a, b))
vec = vectorize()(lambda a, b: ufunc(a, b))
else:
vec = vectorize('int64(int64)')(lambda a: ufunc(a))
vec = vectorize()(lambda a: ufunc(a))

# if ufunc.nin == 2:
# vec = vectorize('int64(int64, int64)')(lambda a, b: ufunc(a, b))
# else:
# vec = vectorize('int64(int64)')(lambda a: ufunc(a))

@njit
def fn(*args):
Expand All @@ -175,17 +180,17 @@ def negative_jit_2(a, indices, b):
return negative_vec.at(a, indices, b)

# basic testing
self._compare_output(add_at, a, [2, 5, 2], 1)
self._compare_output(add_at, np.add, a, [2, 5, 2], 1)

# missing second operand
err_msg = 'second operand needed for ufunc'
with self.assertRaisesRegex(TypeError, err_msg):
add_at(a.copy(), [2, 5, 3], None)

self._compare_output(negative_at, a.copy(), [2, 5, 3])
self._compare_output(negative_at, np.negative, a.copy(), [2, 5, 3])

b = np.array([100, 100, 100])
self._compare_output(add_at, a.copy(), [2, 5, 2], b)
self._compare_output(add_at, np.add, a.copy(), [2, 5, 2], b)

# extraneous second operand
err_msg = 'second operand provided when ufunc is unary'
Expand All @@ -204,7 +209,8 @@ def test_ufunc_at_ellipsis(self):
# with subspaces
arr = np.zeros(5, dtype=int)
add_at = self._generate_jit(np.add)
self._compare_output(add_at, arr, slice(None), np.ones(5, dtype=int))
self._compare_output(add_at, np.add, arr, slice(None),
np.ones(5, dtype=int))

def test_ufunc_at_negative(self):
arr = np.ones(5, dtype=np.int32)
Expand Down