Skip to content

Commit 252c8b3

Browse files
committed
Improve tests for geomspace and logspace functions with proper parametrization through pytest
1 parent 857be19 commit 252c8b3

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

dpnp/tests/test_arraycreation.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -908,19 +908,31 @@ def test_set_shape(shape):
908908
assert_array_equal(na, da)
909909

910910

911-
def test_geomspace_zero_error():
911+
@pytest.mark.parametrize(
912+
"start, stop, num",
913+
[
914+
(0, 5, 3),
915+
(2, 0, 3),
916+
(0, 0, 3),
917+
(dpnp.array([0]), 7, 10),
918+
(-2, numpy.array([[0]]), 7),
919+
([2, 4, 0], 3, 5),
920+
],
921+
)
922+
def test_geomspace_zero_error(start, stop, num):
912923
with pytest.raises(ValueError):
913-
dpnp.geomspace(0, 5, 3)
914-
dpnp.geomspace(2, 0, 3)
915-
dpnp.geomspace(0, 0, 3)
924+
dpnp.geomspace(start, stop, num)
916925

917926

918-
def test_space_num_error():
927+
@pytest.mark.parametrize("xp", [dpnp, numpy])
928+
@pytest.mark.parametrize("func", ["geomspace", "logspace"])
929+
@pytest.mark.parametrize(
930+
"start, stop, num",
931+
[(2, 5, -3), ([2, 3], 5, -3)],
932+
)
933+
def test_space_num_error(xp, func, start, stop, num):
919934
with pytest.raises(ValueError):
920-
dpnp.geomspace(2, 5, -3)
921-
dpnp.logspace(2, 5, -3)
922-
dpnp.geomspace([2, 3], 5, -3)
923-
dpnp.logspace([2, 3], 5, -3)
935+
getattr(xp, func)(start, stop, num)
924936

925937

926938
@pytest.mark.parametrize("sign", [-1, 1])

0 commit comments

Comments
 (0)