data-apis / array-api-tests

Test suite for the PyData Array APIs standard
https://data-apis.org/array-api-tests/
MIT License
65 stars 42 forks source link

Incomplete tests #301

Open asmeurer opened 3 days ago

asmeurer commented 3 days ago

This is a tracking issue for tests that are currently incomplete. These are mostly notated in the code by TODO comments, but it's useful to note them all here too. I haven't checked everything throughly so if there is something missing that isn't noted in a comment it might not be listed here.

Note there are also some functions that aren't yet tested at all, but those are covered in separate issues (e.g., #248 #299). I also am not including tests that are currently skipped entirely as flaky (https://github.com/data-apis/array-api-tests/issues/300).

test_array_object.py

test_creation_functions.py

The device keyword is never tested (see below)

test_data_type_functions.py

test_fft.py

test_has_names.py

test_indexing.py

test_inspection_functions.py

Basically none of the inspection APIs are currently tested, beyond the basic signature tests. Note that for many of these functions, we may not even need to use hypothesis. Just a basic test that the function outputs the right thing and a smoke test that the data outputted is correct.

test_linalg.py

(note: values testing here might be hard. Values testing isn't as high priority for functions that already generally work)

Additionally, there are some limitations in the hypothesis strategies used by some of the functions. These should be made more general so that the functions are actually tested on a full gamut of possible inputs:

test_manipulation_functions.py

test_operators_and_elementwise_functions.py

test_signatures.py

Several issues tracked in other issues: https://github.com/data-apis/array-api-tests/issues/256, https://github.com/data-apis/array-api-tests/issues/171

test_sorting_functions.py

test_special_cases.py

Many special cases are not tested. This is tracked at https://github.com/data-apis/array-api-tests/issues/284

test_statistical_functions.py

See also https://github.com/data-apis/array-api-tests/issues/167

OTHER

ev-br commented 1 day ago

test_negative (there is a TODO about uints)

The TODO is # TODO: clarify if uints are acceptable, adjust accordingly and apparently negative(uint) wraps around in at least several libraries:

In [1]: import torch

In [2]: torch.negative
Out[2]: <function torch._VariableFunctionsClass.negative>

In [3]: torch.negative(torch.as_tensor(3, dtype=torch.uint8))
Out[3]: tensor(253, dtype=torch.uint8)

In [4]: import jax.numpy as jnp

In [5]: jnp.negative(jnp.asarray(3, dtype=jnp.uint8))
Out[5]: Array(253, dtype=uint8)

In [6]: import numpy as np

In [7]: np.negative(np.asarray(3, dtype=np.uint8))
Out[7]: np.uint8(253)

In [8]: np.__version__
Out[8]: '2.1.0'

In [9]: import array_api_strict as xp

In [10]: xp.negative(xp.asarray(3, dtype=xp.uint8))
Out[10]: Array(253, dtype=array_api_strict.uint8)

The spec does not seem to fix the behavior for unsigned ints: https://data-apis.org/array-api/latest/API_specification/generated/array_api.negative.html

So maybe a first action item is to clarify the spec?