-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Labels
low priorityLow priority issueLow priority issue
Description
test_operators_and_elementwise_functions.py
is the most complicated part of the test suite. That inherent complexity should be mitigated as much as possible via good docs. I wrote some broader docs in the file, but think docstrings similiar to the one seen in ph.assert_dtype()
would be well-suited for the *_assert_against_refimpl()
utilities.
array-api-tests/array_api_tests/pytest_helpers.py
Lines 82 to 123 in 87834dd
def assert_dtype( | |
func_name: str, | |
in_dtype: Union[DataType, Sequence[DataType]], | |
out_dtype: DataType, | |
expected: Optional[DataType] = None, | |
*, | |
repr_name: str = "out.dtype", | |
): | |
""" | |
Assert the output dtype is as expected. | |
If expected=None, we infer the expected dtype as in_dtype, to test | |
out_dtype, e.g. | |
>>> x = xp.arange(5, dtype=xp.uint8) | |
>>> out = xp.abs(x) | |
>>> assert_dtype('abs', x.dtype, out.dtype) | |
is equivalent to | |
>>> assert out.dtype == xp.uint8 | |
Or for multiple input dtypes, the expected dtype is inferred from their | |
resulting type promotion, e.g. | |
>>> x1 = xp.arange(5, dtype=xp.uint8) | |
>>> x2 = xp.arange(5, dtype=xp.uint16) | |
>>> out = xp.add(x1, x2) | |
>>> assert_dtype('add', [x1.dtype, x2.dtype], out.dtype) | |
is equivalent to | |
>>> assert out.dtype == xp.uint16 | |
We can also specify the expected dtype ourselves, e.g. | |
>>> x = xp.arange(5, dtype=xp.int8) | |
>>> out = xp.sum(x) | |
>>> default_int = xp.asarray(0).dtype | |
>>> assert_dtype('sum', x, out.dtype, default_int) | |
""" |
Metadata
Metadata
Assignees
Labels
low priorityLow priority issueLow priority issue