Skip to content
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
40 changes: 16 additions & 24 deletions dpnp/tests/test_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2309,35 +2309,27 @@ def test_float_remainder_fmod_nans_inf(func, dtype, lhs, rhs):
assert_equal(result, expected)


@testing.with_requires("numpy>=2.0.0")
@pytest.mark.parametrize(
"data",
[[2, 0, -2], [1.1, -1.1]],
ids=["[2, 0, -2]", "[1.1, -1.1]"],
)
@pytest.mark.parametrize(
"dtype", get_all_dtypes(no_bool=True, no_unsigned=True)
"dtype", get_all_dtypes(no_none=True, no_unsigned=True)
)
def test_sign(data, dtype):
np_a = numpy.array(data, dtype=dtype)
dpnp_a = dpnp.array(data, dtype=dtype)
def test_sign(dtype):
a = generate_random_numpy_array((2, 3), dtype=dtype)
ia = dpnp.array(a, dtype=dtype)

result = dpnp.sign(dpnp_a)
expected = numpy.sign(np_a)
assert_dtype_allclose(result, expected)

# out keyword
if dtype is not None:
dp_out = dpnp.empty(expected.shape, dtype=expected.dtype)
result = dpnp.sign(dpnp_a, out=dp_out)
assert dp_out is result
if dtype == dpnp.bool:
assert_raises(TypeError, dpnp.sign, ia)
assert_raises(TypeError, numpy.sign, a)
else:
result = dpnp.sign(ia)
expected = numpy.sign(a)
assert_dtype_allclose(result, expected)


def test_sign_boolean():
dpnp_a = dpnp.array([True, False])

with pytest.raises(TypeError):
dpnp.sign(dpnp_a)
# out keyword
iout = dpnp.empty(expected.shape, dtype=expected.dtype)
result = dpnp.sign(ia, out=iout)
assert iout is result
assert_dtype_allclose(result, expected)


@pytest.mark.parametrize(
Expand Down
Loading
Loading