Skip to content

Commit 8adc06a

Browse files
committed
Add additional tests for fill
`test_fill_non_scalar` now checks for strings and `test_fill_bool` added to verify bools are properly cast to 1
1 parent 48c8051 commit 8adc06a

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

tests/test_fill.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
import dpnp as dnp
88

99

10-
def test_fill_non_scalar():
10+
@pytest.mark.parametrize(
11+
"val, error",
12+
[
13+
pytest.param(dnp.ones(2, dtype="i4"), ValueError, id="array"),
14+
pytest.param(dict(), TypeError, id="dictionary"),
15+
pytest.param("0", TypeError, id="string"),
16+
],
17+
)
18+
def test_fill_non_scalar(val, error):
1119
a = dnp.ones(5, dtype="i4")
12-
val = dnp.ones(2, dtype="i4")
13-
14-
with pytest.raises(ValueError):
20+
with pytest.raises(error):
1521
a.fill(val)
1622

17-
with pytest.raises(TypeError):
18-
a.fill(dict())
19-
2023

2124
def test_fill_compute_follows_data():
2225
q1 = dpctl.SyclQueue()
@@ -76,3 +79,9 @@ def test_fill_complex_to_float():
7679

7780
a.fill(complex(2, 0))
7881
assert_array_equal(a, 2)
82+
83+
84+
def test_fill_bool():
85+
a = dnp.full(5, fill_value=7, dtype="i4")
86+
a.fill(True)
87+
assert_array_equal(a, 1)

0 commit comments

Comments
 (0)