Skip to content

Commit 437471c

Browse files
committed
Prematurely update test_full_like for proposed spec change
See data-apis/array-api#274
1 parent a689ee6 commit 437471c

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

.github/workflows/numpy.yml

-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ jobs:
5151
"array_api_tests/test_signatures.py::test_function_positional_args[__index__]",
5252
"array_api_tests/test_signatures.py::test_function_keyword_only_args[prod]",
5353
"array_api_tests/test_signatures.py::test_function_keyword_only_args[sum]",
54-
55-
# https://github.com/data-apis/array-api-tests/pull/18#discussion_r715047213
56-
"array_api_tests/test_creation_functions.py::test_full_like"
5754
)
5855
5956
def pytest_collection_modifyitems(config, items):

array_api_tests/test_creation_functions.py

+3-18
Original file line numberDiff line numberDiff line change
@@ -157,34 +157,19 @@ def test_full(shape, fill_value, dtype):
157157
else:
158158
assert all(equal(a, asarray(fill_value, **kwargs))), "full() array did not equal the fill value"
159159

160-
@composite
161-
def fill_values(draw):
162-
# If dtype has been specified, fill_value should be inferred from it
163-
dtype = draw(shared_optional_dtypes)
164-
# If dtype=None, fill_value can be anything - full_like should infer the dtype
165-
if dtype is None:
166-
dtype = draw(sampled_from([xp.bool, xp.int32, xp.float32]))
167-
return draw(xps.from_dtype(dtype))
168160

169161
@given(
170162
x=xps.arrays(dtype=shared_dtypes, shape=shapes),
171-
fill_value=fill_values(),
163+
fill_value=shared_dtypes.flatmap(xps.from_dtype),
172164
dtype=shared_optional_dtypes,
173165
)
174166
def test_full_like(x, fill_value, dtype):
175167
x_like = full_like(x, fill_value, dtype=dtype)
176168

177169
if dtype is None:
178-
if isinstance(fill_value, bool):
179-
assert x_like.dtype == xp.bool, f"{fill_value=}, but full_like() did not produce a boolean array - instead was {x_like.dtype}"
180-
elif isinstance(fill_value, int):
181-
assert x_like.dtype in (xp.int32, xp.int64), f"{fill_value=}, but full_like() did not produce a int32 or int64 array - instead was {x_like.dtype}"
182-
elif isinstance(fill_value, float):
183-
assert x_like.dtype in (xp.float32, xp.float64), f"{fill_value=}, but full_like() did not produce a float32 or float64 array - instead was {x_like.dtype}"
184-
else:
185-
raise Exception(f"Sanity check failed, indiciating a bug in the test suite. {fill_value=} - should be a bool, int or float")
170+
assert x_like.dtype == x.dtype, f"{x.dtype=}, but full_like() did not produce a {x.dtype} array - instead was {x_like.dtype}"
186171
else:
187-
assert x_like.dtype == dtype
172+
assert x_like.dtype == None, f"{dtype=}, but full_like() did not produce a {dtype} array - instead was {x_like.dtype}"
188173

189174
assert x_like.shape == x.shape, "full_like() produced an array with incorrect shape"
190175
if is_float_dtype(x_like.dtype) and isnan(asarray(fill_value)):

0 commit comments

Comments
 (0)