Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MAINT: Addarray-api-tests CI stage, addndarray.__array_namespace__#25167

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ngoldbaum merged 2 commits intonumpy:mainfrommtsokol:array-api-test-ci
Nov 28, 2023

Conversation

@mtsokol
Copy link
Member

@mtsokolmtsokol commentedNov 16, 2023
edited
Loading

Hi@rgommers@asmeurer,

This draft PR introducesarray-api-tests CI stage. Here are some important notes:

  • It's the first WIP implementation that I managed to initially run on my fork. I'm sharing it here to start the discussion.
  • Icouldn't findarray-api-tests on PyPI, so I followed implementation inhttps://github.com/google/jax/pull/16099/files, wherearray-api-tests is cloned, and some issues are manually fixed (for now).
  • array-api-skips.txt contains and disables quite a lot of tests - the rationale is to merge it first, and then, as Array API PRs arrive, enable tests gradually.
  • In this PR I added__array_namespace__ tondarray class and__array_api_version__ to the main namespace.
  • xp.bool is required to run the tests and it can't be XFAILed, soAPI: Add and redefinenumpy.bool [Array API] #25080 needs to be merged before this PR[EDIT] Merged.

honno reacted with rocket emoji
@mtsokolmtsokol changed the titleMAINT: Add array-api-tests CI stage, addndarray.__array_namespace__MAINT: Addarray-api-tests CI stage, addndarray.__array_namespace__Nov 16, 2023
@mtsokolmtsokol self-assigned thisNov 16, 2023
@mtsokolmtsokolforce-pushed thearray-api-test-ci branch 2 times, most recently from0d50cd4 toedd114cCompareNovember 16, 2023 21:18
Copy link
Member

Choose a reason for hiding this comment

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

Don't know if there's a cleaner place to put this file than the project root.

@asmeurer
Copy link
Member

This could also be used to run tests for numpy.array_api, but I guess that's lower priority.

mtsokol reacted with thumbs up emoji

run:|
python -m pip install -r build_requirements.txt
python -m pip install -r test_requirements.txt
python -m pip install hypothesis!=6.88.4 # 6.88.4 leads to a strange error
Copy link
Contributor

@jakevdpjakevdpNov 16, 2023
edited
Loading

Choose a reason for hiding this comment

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

This needs to be"hypothesis<6.88.4". The problem is warnings from hypothesis, so it's only an issue is if your pytest configuration errors on warnings. (Reported here:data-apis/array-api-tests#211)

Copy link
Contributor

@jakevdpjakevdpNov 16, 2023
edited
Loading

Choose a reason for hiding this comment

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

Oh, I see-W below, so you definitely will need this version bound until that is addressed upstream.

mtsokol reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

This should be fixed bydata-apis/array-api-tests#212, so the!=6.88.4 can probably be dropped by updating to a newerarray-api-tests commit?

And if not, should it be< rather than!=, because there are newer hypothesis versions out already and the problem is unlikely to only exist in that exact 6.88.4 version?

Copy link
Member

Choose a reason for hiding this comment

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

Actually,hypothesis is already present intest_requirements.txt, so this line does nothing - I think it can be removed.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

That's right - removed it.

@mtsokolmtsokol marked this pull request as ready for reviewNovember 24, 2023 13:20
@mtsokol
Copy link
MemberAuthor

Hi@rgommers, I rebased the branch and nowarray_api_tests stage runs and passes (withskips.txt file and ignored warnings) - it's ready for a review.

rgommers reacted with thumbs up emoji

Copy link
Member

@rgommersrgommers left a comment

Choose a reason for hiding this comment

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

This is looking pretty good to me, and test is green with a clean test log. All my suggestions are pretty small.

array_api_tests/test_set_functions.py

# newaxis not included in numpy namespace as of v1.26.2
array_api_tests/test_constants.py::test_newaxis
Copy link
Member

Choose a reason for hiding this comment

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

This one can be left out I think, sincenumpy.newaxis exists.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Sure, removed!

run:|
python -m pip install -r build_requirements.txt
python -m pip install -r test_requirements.txt
python -m pip install hypothesis!=6.88.4 # 6.88.4 leads to a strange error
Copy link
Member

Choose a reason for hiding this comment

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

This should be fixed bydata-apis/array-api-tests#212, so the!=6.88.4 can probably be dropped by updating to a newerarray-api-tests commit?

And if not, should it be< rather than!=, because there are newer hypothesis versions out already and the problem is unlikely to only exist in that exact 6.88.4 version?

# newaxis not included in numpy namespace as of v1.26.2
array_api_tests/test_constants.py::test_newaxis

# linalg.solve issue in numpy.array_api as of v1.26.2 (see numpy#25146)
Copy link
Member

Choose a reason for hiding this comment

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

This issue has been fixed already, and didn't affect the main namespace. Can this be dropped?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, removed.

# linalg.solve issue in numpy.array_api as of v1.26.2 (see numpy#25146)
array_api_tests/test_linalg.py::test_solve

# https://github.com/numpy/numpy/issues/21373
Copy link
Member

Choose a reason for hiding this comment

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

also fixed already

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Right, removed.

# missing copy arg
array_api_tests/test_signatures.py::test_func_signature[reshape]

# https://github.com/numpy/numpy/issues/21211
Copy link
Member

Choose a reason for hiding this comment

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

Closed, ultimately fixed by#21218 I believe.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Removed.

run:|
python -m pip install -r build_requirements.txt
python -m pip install -r test_requirements.txt
python -m pip install hypothesis!=6.88.4 # 6.88.4 leads to a strange error
Copy link
Member

Choose a reason for hiding this comment

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

Actually,hypothesis is already present intest_requirements.txt, so this line does nothing - I think it can be removed.

submodules:'true'
path:'array-api-tests'
-name:Fix array-apis bug
# Temporary workaround for https://github.com/data-apis/array-api/issues/631
Copy link
Member

Choose a reason for hiding this comment

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

This should have been fixed yesterday, can you check if things pass now without this fixup with the latest commit fromarray-api-tests?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, it's fixed now.

with:
submodules:recursive
fetch-depth:0
-name:Checkout array-api-tests
Copy link
Member

Choose a reason for hiding this comment

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

This is fine for now, but once a bunch of the updates are made we should instead use a regular git submodule for these tests, so that they get run locally. Right now if this job fails, re-running locally will be a bit of a hassle.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Right - at some point I will make it a submodule.

returnNULL;
}

if (strcmp(array_api_version,"2022.12")!=0) {
Copy link
Member

Choose a reason for hiding this comment

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

Callingndarray.__array_namespace__(api_version='2021.12') should work too. The newer version is a superset of the older one, so we'd want to support both. And when we upgrade to say2023.12 in the future, asking for2022.12 should not break. So adding a test to check this will be useful.

Copy link
Member

Choose a reason for hiding this comment

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

Second suggested regression test:

>>>importnumpyasnp>>>xp=np.arange(2).__array_namespace__()>>>assertxpisnp

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I addedtest__array_namespace__ for that purpose.


if (strcmp(array_api_version,"2022.12")!=0) {
PyErr_Format(PyExc_ValueError,
"Version \"%s\" of Array API is not supported.",
Copy link
Member

Choose a reason for hiding this comment

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

minor:

Suggested change
"Version \"%s\" of Array API is not supported.",
"Version \"%s\" oftheArray API Standard is not supported.",

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Updated!

@charrischarris changed the titleMAINT: Addarray-api-tests CI stage, addndarray.__array_namespace__MAINT: Addarray-api-tests CI stage, addndarray.__array_namespace__Nov 24, 2023
@mtsokol
Copy link
MemberAuthor

Ok, I think it's ready on my end.

@ngoldbaum
Copy link
Member

ngoldbaum commentedNov 28, 2023
edited
Loading

All looks good to me, merging to unblock the other array API PRs. Thanks@mtsokol!

Just out of curiosity, how is__array_namespace__ supposed to work for a library that only partially supports the array API?

@ngoldbaumngoldbaum merged commit06d7bdf intonumpy:mainNov 28, 2023
@rgommers
Copy link
Member

Just out of curiosity, how is__array_namespace__ supposed to work for a library that only partially supports the array API?

It isn't - adding the method is kinda saying "I fully support this". In practice one has to be pragmatic and some gaps that aren't too important can simply be ignored. But if you're missing lots of functionality, don't add this method. Think of it like a C standard - there's defines to check whether say C99 is used, but not "C99 minus x, y and z".

@mtsokolmtsokol deleted the array-api-test-ci branchNovember 28, 2023 21:54
@asmeurer
Copy link
Member

To add to that, at least the way array-api-compat is currently written,__array_namespace__ will bypass the compat namespacehttps://github.com/data-apis/array-api-compat/blob/main/array_api_compat/common/_helpers.py#L76-L77. That should probably be fixed though if NumPy is adding it, because we will probably need to maintain some compat wrappers even after@mtsokol's work because of things that are kept for backwards compatibility.

returnNULL;
}

if (strcmp(array_api_version,"2021.12")!=0&&
Copy link
Member

Choose a reason for hiding this comment

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

Is the point of array_api_version to be forwards compatible, or should this error too?

Copy link
Member

Choose a reason for hiding this comment

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

2022.12 is a superset of 2021.12, so if a user asks for the latter, it's fine to return the former.

@rgommers
Copy link
Member

To add to that, at least the way array-api-compat is currently written,__array_namespace__ will bypass the compat namespacehttps://github.com/data-apis/array-api-compat/blob/main/array_api_compat/common/_helpers.py#L76-L77. That should probably be fixed though if NumPy is adding it, because we will probably need to maintain some compat wrappers even after@mtsokol's work because of things that are kept for backwards compatibility.

Hmm, we should get to ~100% compatibility. Do you have specific things in mind? If so, let's open an issue now inarray-api-compat and fix it soon?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@rgommersrgommersAwaiting requested review from rgommers

2 more reviewers

@asmeurerasmeurerasmeurer left review comments

@jakevdpjakevdpjakevdp left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

@mtsokolmtsokol

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@mtsokol@asmeurer@ngoldbaum@rgommers@jakevdp

[8]ページ先頭

©2009-2025 Movatter.jp