Skip to content

Commit 070286f

Browse files
Add tests for dpnp.isneginf()
1 parent 36152fa commit 070286f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

tests/test_logic.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from .helper import (
88
get_all_dtypes,
99
get_float_complex_dtypes,
10-
has_support_aspect64,
1110
)
1211

1312

@@ -394,3 +393,32 @@ def test_finite(op, data, dtype):
394393
dpnp_res = getattr(dpnp, op)(x, out=dp_out)
395394
assert dp_out is dpnp_res
396395
assert_equal(dpnp_res, np_res)
396+
397+
398+
@pytest.mark.parametrize("func", ["isneginf"], ids=["isneginf"])
399+
@pytest.mark.parametrize(
400+
"data",
401+
[
402+
[dpnp.inf, -1, 0, 1, dpnp.nan, -dpnp.inf],
403+
[[dpnp.inf, dpnp.nan], [dpnp.nan, 0], [1, -dpnp.inf]],
404+
],
405+
ids=[
406+
"[dpnp.inf, -1, 0, 1, dpnp.nan, -dpnp.inf]",
407+
"[[dpnp.inf, dpnp.nan], [dpnp.nan, 0], [1, -dpnp.inf]]",
408+
],
409+
)
410+
@pytest.mark.parametrize("dtype", get_float_complex_dtypes())
411+
def test_infinity_sign(func, data, dtype):
412+
x = dpnp.asarray(data, dtype=dtype)
413+
if dpnp.issubdtype(dtype, dpnp.complexfloating):
414+
with pytest.raises(TypeError):
415+
dpnp_res = getattr(dpnp, func)(x)
416+
else:
417+
np_res = getattr(numpy, func)(x.asnumpy())
418+
dpnp_res = getattr(dpnp, func)(x)
419+
assert_equal(dpnp_res, np_res)
420+
421+
dp_out = dpnp.empty(np_res.shape, dtype=dpnp.bool)
422+
dpnp_res = getattr(dpnp, func)(x, out=dp_out)
423+
assert dp_out is dpnp_res
424+
assert_equal(dpnp_res, np_res)

tests/third_party/cupy/logic_tests/test_content.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,16 @@ def test_isinf(self):
2929

3030
def test_isnan(self):
3131
self.check_unary_nan("isnan")
32+
33+
34+
class TestUfuncLike(unittest.TestCase):
35+
@testing.numpy_cupy_array_equal()
36+
def check_unary(self, name, xp):
37+
a = xp.array([-3, xp.inf, -1, -xp.inf, 0, 1, 2, xp.nan])
38+
return getattr(xp, name)(a)
39+
40+
def test_isneginf(self):
41+
self.check_unary("isneginf")
42+
43+
# def test_isposinf(self):
44+
# self.check_unary("isposinf")

0 commit comments

Comments
 (0)