Skip to content

Commit b37ecc9

Browse files
committed
Remove old scalar promotion tests
1 parent e40cac8 commit b37ecc9

File tree

1 file changed

+0
-68
lines changed

1 file changed

+0
-68
lines changed

array_api_tests/test_type_promotion.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -284,74 +284,6 @@ def test_inplace_operator_promotes_python_scalars(
284284
assert x.dtype == dtype, f'{x.dtype=!s}, but should be {dtype}'
285285

286286

287-
scalar_promotion_parametrize_inputs = [
288-
pytest.param(func, dtype, scalar_type, id=f'{func}-{dtype}-{scalar_type.__name__}')
289-
for func in sorted(set(dh.binary_op_to_symbol) - {'__matmul__'})
290-
for dtype in dh.category_to_dtypes[dh.op_in_categories[func]]
291-
for scalar_type in dh.dtypes_to_scalars[dtype]
292-
]
293-
294-
295-
@pytest.mark.parametrize('func,dtype,scalar_type', scalar_promotion_parametrize_inputs)
296-
@given(shape=hh.shapes, python_scalars=st.data(), data=st.data())
297-
def test_operator_scalar_arg_return_promoted(
298-
func, dtype, scalar_type, shape, python_scalars, data
299-
):
300-
"""
301-
See https://data-apis.github.io/array-api/latest/API_specification/type_promotion.html#mixing-arrays-with-python-scalars
302-
"""
303-
op = dh.binary_op_to_symbol[func]
304-
if op == '@':
305-
pytest.skip('matmul (@) is not supported for hh.scalars')
306-
307-
if dtype in dh.category_to_dtypes['integer']:
308-
s = python_scalars.draw(st.integers(*dh.dtype_ranges[dtype]))
309-
else:
310-
s = python_scalars.draw(st.from_type(scalar_type))
311-
scalar_as_array = ah.asarray(s, dtype=dtype)
312-
get_locals = lambda: dict(a=a, s=s, scalar_as_array=scalar_as_array)
313-
314-
fillvalue = data.draw(hh.scalars(st.just(dtype)))
315-
a = ah.full(shape, fillvalue, dtype=dtype)
316-
317-
# As per the spec:
318-
319-
# The expected behavior is then equivalent to:
320-
#
321-
# 1. Convert the scalar to a 0-D array with the same dtype as that of the
322-
# array used in the expression.
323-
#
324-
# 2. Execute the operation for `array <op> 0-D array` (or `0-D array <op>
325-
# array` if `scalar` was the left-hand argument).
326-
327-
array_scalar = f'a {op} s'
328-
array_scalar_expected = f'a {op} scalar_as_array'
329-
res = eval(array_scalar, get_locals())
330-
expected = eval(array_scalar_expected, get_locals())
331-
ah.assert_exactly_equal(res, expected)
332-
333-
scalar_array = f's {op} a'
334-
scalar_array_expected = f'scalar_as_array {op} a'
335-
res = eval(scalar_array, get_locals())
336-
expected = eval(scalar_array_expected, get_locals())
337-
ah.assert_exactly_equal(res, expected)
338-
339-
# Test in-place operators
340-
if op in ['==', '!=', '<', '>', '<=', '>=']:
341-
return
342-
array_scalar = f'a {op}= s'
343-
array_scalar_expected = f'a {op}= scalar_as_array'
344-
a = ah.full(shape, fillvalue, dtype=dtype)
345-
res_locals = get_locals()
346-
exec(array_scalar, get_locals())
347-
res = res_locals['a']
348-
a = ah.full(shape, fillvalue, dtype=dtype)
349-
expected_locals = get_locals()
350-
exec(array_scalar_expected, get_locals())
351-
expected = expected_locals['a']
352-
ah.assert_exactly_equal(res, expected)
353-
354-
355287
if __name__ == '__main__':
356288
for (i, j), p in dh.promotion_table.items():
357289
print(f'({i}, {j}) -> {p}')

0 commit comments

Comments
 (0)