Skip to content

Versioning support, bulk of complex testing #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Mar 13, 2023

Conversation

honno
Copy link
Member

@honno honno commented Jan 27, 2023

Resolves #20 with the introduced marker min_version(api_version), so tests only run when specified with a later version. The env var ARRAY_API_TESTS_VERSION allows one to specify a version to test with, which currently defaults to xp.__array_api_version__ and fallsback to "2021.12".

Covers complex testing for extended and new functions in the 2022.12 spec. Does not cover outside of that yet, nor complex special cases—something for a future PR.

Realise I need to update Hypothesis first so it recognizes 2022.12 before I'd want this merged.

__all__ = ["COMPLEX_VER", "api_version", "xps"]


COMPLEX_VER: str = "2022.12"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this. There's more that was added in 2022 than just complex numbers.

Why not convert the version string to a tuple of numbers, so you can just compare like if version >= (2022,).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this is just meant to represent the version where complex numbers were added, not some be-end-all. It existed as a variable for historic reasons, as it was previously "draft" and then something I'd just updated, but really I can grep-replace instances of it to "2022.12" now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather just use inline version checks with the actual version. That's much more explicit to anyone reading the test code. We can include links to the spec changelog or versionadded admonitions as references if needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather just use inline version checks with the actual version. That's much more explicit to anyone reading the test code. We can include links to the spec changelog or versionadded admonitions as references if needed.

Pushed a change which represents what I was going for, which I think is what you're saying.

@honno honno marked this pull request as ready for review February 14, 2023 11:20
@honno honno requested a review from asmeurer February 21, 2023 11:00
@asmeurer
Copy link
Member

Does hypothesis use the api_version keyword to __array_namespace__? https://data-apis.org/array-api/draft/API_specification/generated/array_api.array.__array_namespace__.html#array_api.array.__array_namespace__ (not that anything even has that outside of numpy.array_api)?

@asmeurer
Copy link
Member

I tried running this on data-apis/array-api-compat#14 and there were several failures (outside of the expected XFAILs).

FAILED array_api_tests/test_creation_functions.py::test_asarray_arrays - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_creation_functions.py::test_full_like - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_creation_functions.py::test_ones_like - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_creation_functions.py::test_zeros_like - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_data_type_functions.py::test_result_type - TypeError: result_type() received an invalid combination of arguments - got (torch.dtype, torch.dtype), but expected one of:
FAILED array_api_tests/test_linalg.py::test_matrix_transpose - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_linalg.py::test_vecdot - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_manipulation_functions.py::test_concat - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_manipulation_functions.py::test_stack - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_add[add(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_add[__iadd__(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_add[__iadd__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_divide[divide(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__truediv__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__itruediv__(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__itruediv__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_equal[equal(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_equal[__eq__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_log1p - AssertionError: out=inf, but should be roughly log1p(x)=87.49823360321435 [log1p()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[multiply(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__mul__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__imul__(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__imul__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[not_equal(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[__ne__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_pow[pow(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__pow__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__ipow__(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__ipow__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_remainder[__mod__(x1, x2)] - AssertionError: out.dtype=int8, but should be int32 [__mod__(int32, int8)]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[subtract(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__sub__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__isub__(x1, x2)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__isub__(x, s)] - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch
FAILED array_api_tests/test_searching_functions.py::test_where - hypothesis.errors.InvalidArgument: dtype=torch.complex64 not recognised in array_api_compat.torch

(there might be more too since the known xfails were all skipped).

@honno
Copy link
Member Author

honno commented Feb 24, 2023

Does hypothesis use the api_version keyword to __array_namespace__?

Nope. It uses __array_namespace__() just for a throaway check is all.

several failures

Thanks for the report, I've identified a few issues before we can get this in. I'll prioritise resolving them so hopefully end of next week everythings up-to-speed.

@honno
Copy link
Member Author

honno commented Mar 13, 2023

Thanks for the report, I've identified a few issues before we can get this in. I'll prioritise resolving them so hopefully end of next week everythings up-to-speed.

I should of mentioned last week I think I've addressed any blocking issues @asmeurer. So I'll continue to work on this branch, but if things look good to you it's okay to merge as-is on my end.

@asmeurer
Copy link
Member

Let's merge this. I'll open an issue if I notice any issues with testing the compat library.

@asmeurer asmeurer merged commit a533680 into data-apis:master Mar 13, 2023
@honno honno deleted the complex-support branch February 28, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split the test suite for spec versions
2 participants