summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSayed Adel <seiko@imavr.com>2022-12-21 00:36:16 +0200
committerSayed Adel <seiko@imavr.com>2022-12-21 01:17:10 +0200
commit1e80637c93853a05c56ea9178f8304e8ef9caebd (patch)
treed47167b1c2694092c75efeb8570285083bcef5d4
parent1d5b3397dc7beaf9ca7b2326127e74f55aecd162 (diff)
downloadnumpy-1e80637c93853a05c56ea9178f8304e8ef9caebd.tar.gz
BUG, SIMD: Fix the bitmask of the boolean comparison
-rw-r--r--numpy/core/src/umath/loops_comparison.dispatch.c.src6
-rw-r--r--numpy/core/tests/test_umath.py12
2 files changed, 9 insertions, 9 deletions
diff --git a/numpy/core/src/umath/loops_comparison.dispatch.c.src b/numpy/core/src/umath/loops_comparison.dispatch.c.src
index 2cd76c35e..f61ef4113 100644
--- a/numpy/core/src/umath/loops_comparison.dispatch.c.src
+++ b/numpy/core/src/umath/loops_comparison.dispatch.c.src
@@ -234,7 +234,7 @@ static void simd_binary_@kind@_b8(char **args, npy_intp len)
npyv_b8 a = npyv_cmpeq_u8(npyv_load_u8(src1), vzero);
npyv_b8 b = npyv_cmpeq_u8(npyv_load_u8(src2), vzero);
npyv_b8 c = npyv_@VOP@_b8(a, b);
- npyv_store_u8(dst, npyv_andc_u8(npyv_cvt_u8_b8(c), truemask));
+ npyv_store_u8(dst, npyv_and_u8(npyv_cvt_u8_b8(c), truemask));
}
for (; len > 0; --len, ++src1, ++src2, ++dst) {
@@ -258,7 +258,7 @@ static void simd_binary_scalar1_@kind@_b8(char **args, npy_intp len)
for (; len >= vstep; len -= vstep, src += vstep, dst += vstep) {
npyv_b8 b = npyv_cmpeq_u8(npyv_load_u8(src), vzero);
npyv_b8 c = npyv_@VOP@_b8(a, b);
- npyv_store_u8(dst, npyv_andc_u8(npyv_cvt_u8_b8(c), truemask));
+ npyv_store_u8(dst, npyv_and_u8(npyv_cvt_u8_b8(c), truemask));
}
for (; len > 0; --len, ++src, ++dst) {
@@ -281,7 +281,7 @@ static void simd_binary_scalar2_@kind@_b8(char **args, npy_intp len)
for (; len >= vstep; len -= vstep, src += vstep, dst += vstep) {
npyv_b8 a = npyv_cmpeq_u8(npyv_load_u8(src), vzero);
npyv_b8 c = npyv_@VOP@_b8(a, b);
- npyv_store_u8(dst, npyv_andc_u8(npyv_cvt_u8_b8(c), truemask));
+ npyv_store_u8(dst, npyv_and_u8(npyv_cvt_u8_b8(c), truemask));
}
for (; len > 0; --len, ++src, ++dst) {
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 073a370c0..3364eb7e6 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -284,16 +284,16 @@ class TestComparisons:
b_lst = b.tolist()
# (Binary) Comparison (x1=array, x2=array)
- comp_b = np_comp(a, b)
- comp_b_list = [py_comp(x, y) for x, y in zip(a_lst, b_lst)]
+ comp_b = np_comp(a, b).view(np.uint8)
+ comp_b_list = [int(py_comp(x, y)) for x, y in zip(a_lst, b_lst)]
# (Scalar1) Comparison (x1=scalar, x2=array)
- comp_s1 = np_comp(np_scalar, b)
- comp_s1_list = [py_comp(scalar, x) for x in b_lst]
+ comp_s1 = np_comp(np_scalar, b).view(np.uint8)
+ comp_s1_list = [int(py_comp(scalar, x)) for x in b_lst]
# (Scalar2) Comparison (x1=array, x2=scalar)
- comp_s2 = np_comp(a, np_scalar)
- comp_s2_list = [py_comp(x, scalar) for x in a_lst]
+ comp_s2 = np_comp(a, np_scalar).view(np.uint8)
+ comp_s2_list = [int(py_comp(x, scalar)) for x in a_lst]
# Sequence: Binary, Scalar1 and Scalar2
assert_(comp_b.tolist() == comp_b_list,