|
8 | 8 | scalars, xps, kwargs)
|
9 | 9 |
|
10 | 10 | from hypothesis import assume, given
|
11 |
| -from hypothesis.strategies import integers, floats, one_of, none, booleans, just, shared |
| 11 | +from hypothesis.strategies import integers, floats, one_of, none, booleans, just, shared, composite |
12 | 12 |
|
13 | 13 |
|
14 | 14 | optional_dtypes = none() | shared_dtypes
|
@@ -148,10 +148,17 @@ def test_full(shape, fill_value, dtype):
|
148 | 148 | assert all(equal(a, asarray(fill_value, **kwargs))), "full() array did not equal the fill value"
|
149 | 149 |
|
150 | 150 |
|
| 151 | +@composite |
| 152 | +def fill_values(draw): |
| 153 | + kw = draw(shared(kwargs(dtype=none() | xps.scalar_dtypes()), key="full_like_kw")) |
| 154 | + dtype = kw.get("dtype", None) or draw(shared_dtypes) |
| 155 | + return draw(xps.from_dtype(dtype)) |
| 156 | + |
| 157 | + |
151 | 158 | @given(
|
152 | 159 | x=xps.arrays(dtype=shared_dtypes, shape=shapes),
|
153 |
| - fill_value=shared_dtypes.flatmap(xps.from_dtype), |
154 |
| - kw=kwargs(dtype=none() | shared_dtypes), |
| 160 | + fill_value=fill_values(), |
| 161 | + kw=shared(kwargs(dtype=none() | xps.scalar_dtypes()), key="full_like_kw"), |
155 | 162 | )
|
156 | 163 | def test_full_like(x, fill_value, kw):
|
157 | 164 | out = full_like(x, fill_value, **kw)
|
|
0 commit comments