8000 BUG: Fix auxdata initialization in ufunc slow path by seberg · Pull Request #28118 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix auxdata initialization in ufunc slow path #28118

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 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion numpy/_core/src/umath/ufunc_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ execute_ufunc_loop(PyArrayMethod_Context *context, int masked,
* based on the fixed strides.
*/
PyArrayMethod_StridedLoop *strided_loop;
NpyAuxData *auxdata;
NpyAuxData *auxdata = NULL;
npy_intp fixed_strides[NPY_MAXARGS];

NpyIter_GetInnerFixedStrideArray(iter, fixed_strides);
Expand Down
14 changes: 14 additions & 0 deletions numpy/_core/tests/test_nep50_promotions.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@ def test_integer_comparison(sctype, other_val, comp):
assert_array_equal(comp(other_val, val_obj), comp(other_val, val))


@pytest.mark.parametrize("arr", [
np.ones((100, 100), dtype=np.uint8)[::2], # not trivially iterable
np.ones(20000, dtype=">u4"), # cast and >buffersize
np.ones(100, dtype=">u4"), # fast path compatible with cast
])
def test_integer_comparison_with_cast(arr):
# Similar to above, but mainly test a few cases that cover the slow path
# the test is limited to unsigned ints and -1 for simplicity.
res = arr >= -1
assert_array_equal(res, np.ones_like(arr, dtype=bool))
res = arr < -1
assert_array_equal(res, np.zeros_like(arr, dtype=bool))


@pytest.mark.parametrize("comp",
[np.equal, np.not_equal, np.less_equal, np.less,
np.greater_equal, np.greater])
Expand Down
Loading
0