Skip to content

Commit 738df73

Browse files
committed
Add third party test for bitwise_count
1 parent c27aae9 commit 738df73

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

dpnp/tests/third_party/cupy/binary_tests/test_elementwise.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import unittest
24

35
from dpnp.tests.third_party.cupy import testing
@@ -27,6 +29,38 @@ def test_bitwise_or(self):
2729
def test_bitwise_xor(self):
2830
self.check_binary_int("bitwise_xor")
2931

32+
@testing.with_requires("numpy>=2.0.0")
33+
@testing.for_int_dtypes(no_bool=True)
34+
@testing.numpy_cupy_array_equal()
35+
def test_bitwise_count(self, xp, dtype):
36+
info = xp.iinfo(dtype)
37+
if xp.issubdtype(dtype, xp.signedinteger):
38+
a = xp.array(
39+
[
40+
0,
41+
-1,
42+
1,
43+
info.min,
44+
info.min + 1,
45+
info.max,
46+
info.max - 1,
47+
info.max // 2,
48+
],
49+
dtype=dtype,
50+
)
51+
else:
52+
a = xp.array(
53+
[
54+
0,
55+
1,
56+
info.max,
57+
info.max - 1,
58+
info.max // 2,
59+
],
60+
dtype=dtype,
61+
)
62+
return xp.bitwise_count(a)
63+
3064
def test_invert(self):
3165
self.check_unary_int("invert")
3266

0 commit comments

Comments
 (0)