Skip to content

Conversation

lucascolley
Copy link
Member

@lucascolley lucascolley commented Dec 12, 2023

Reference issue

Closes gh-19181, towards gh-18866.

What does this implement/fix?

  • Consolidates the array API test-skip infrastructure into a single pytest fixture and marker.

Additional information

  • Also makes some minor improvements to some tests in cluster.

@lucascolley lucascolley added the array types Items related to array API support and input array validation (see gh-18286) label Dec 12, 2023
@lucascolley lucascolley added scipy.cluster maintenance Items related to regular maintenance tasks labels Dec 12, 2023
@lucascolley lucascolley added this to the 1.13.0 milestone Dec 12, 2023
@lucascolley
Copy link
Member Author

I suppose we don't need to fix gh-19683 (causing the CI failures) before this, in which case this is ready for review @tylerjereddy (no rush of course)

@lucascolley
Copy link
Member Author

I've reverted the fix for gh-19683 as that can be done separately, I think this should pass CI now

Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

I just went through the first two files in the diff so far, but added a few comments. It mostly looks like an improvement from what I've seen so far at least, but need to circle back for the next 4 files in the diff.

@lucascolley lucascolley force-pushed the array-api-decorators branch 2 times, most recently from a6707b3 to 3b62ced Compare January 1, 2024 02:16
@lucascolley lucascolley changed the title MAINT/TST: improve array API test skip decorators TST: consolidate array API test skip decorators Jan 1, 2024
@lucascolley
Copy link
Member Author

@tylerjereddy I've fixed the granularity problem by using a pytest fixture and a new mark. I've also consolidated all of the decorators into one, so that now we just have two additional marks whenever any skipping is used.

Sorry, the diff has increased in size by quite a bit, but I think this is the right direction.

@lucascolley lucascolley force-pushed the array-api-decorators branch from 3b62ced to d3d6eba Compare January 1, 2024 14:58
@lucascolley lucascolley force-pushed the array-api-decorators branch 4 times, most recently from 9ceb4a4 to 093e409 Compare January 1, 2024 15:58
@lucascolley
Copy link
Member Author

lucascolley commented Jan 1, 2024

Okay, this is ready for a look @tylerjereddy . I've had some success with the rework - the granularity issue is fixed, the skips can be applied to classes now, and overall verbosity in the test files is reduced greatly.

cc @tupui as original author of the infra in case you're interested

@lucascolley lucascolley force-pushed the array-api-decorators branch 2 times, most recently from b472d55 to 09421e7 Compare January 22, 2024 10:02
Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

I took a detailed look again today, including looking at the test pass/skip numbers for this branch vs. main, and re-reading every single line of the diff here again.

I think I'm in favor of merge once the failing test is marked appropriately. Perhaps we could start a fresh issue for the array-like/empty list input business since going through this PR multiple rounds can take a fair bit of time, and that was only a few cases I think.

EDIT: to clarify, there are way more skips on this branch vs. main, while preserving or increasing the number of passes (if you rebase), so that's consistent with properly registered skips now.

@lucascolley
Copy link
Member Author

Thanks Tyler!

I think I'm in favor of merge once the failing test is marked appropriately. Perhaps we could start a fresh issue for the array-like/empty list input business since going through this PR multiple rounds can take a fair bit of time, and that was only a few cases I think.

If you don't mind, when I find the time, I'll go ahead with my suggestion of:

  • When a parameter takes (e.g.) either an ndarray or an int, we should have tests for both types, for all backends.

  • When a parameter takes just an ndarray (but e.g. ints happen to work with NumPy), we do not support array-likes for alternative backends. xp.asarray should be used in all tests, and a singular separate test, just for NumPy, should check array-like input.

and make sure that is consistent here. I'm pretty sure that makes sense and is better than what we currently have.

I'll also clear up any unresolved comments and let you know when I think this looks ready 👍

@lucascolley
Copy link
Member Author

lucascolley commented Feb 11, 2024

@tylerjereddy I think this is ready to go now. I believe that the test coverage is now strictly increased in this PR. The lint failures are unrelated (will send a separate PR). oops, lint error is related, fixing now

@lucascolley lucascolley force-pushed the array-api-decorators branch 2 times, most recently from 5186ba3 to bc7c7c5 Compare February 11, 2024 16:50
@lucascolley
Copy link
Member Author

@rgommers merge conflict resolved, at your leisure :)

Comment on lines +122 to +123
@pytest.mark.xfail(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
Copy link
Member Author

Choose a reason for hiding this comment

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

should probably skip rather than xfail here.

@lucascolley
Copy link
Member Author

Still one numpy.array_api reference lurking in the docs.

image

@tylerjereddy
Copy link
Contributor

I spent quite some time reading every line of the diff again and checking the arithmetic on the skip/pass results for a cuda-enabled full array API test suite assessment of this branch vs. main. I think this is the second time I've done this now, and the remaining cleanups/comments don't justify a block IMO. Much easier to review those smaller things in a follow-up.

This is a clear improvement in the array API testing infrastructure so I'm going to merge it now. The commit history is clean/reasonable for the size of the PR, so I'll keep it. This is mostly internal testing infrastructure improvements, and has been open for long enough to give folks time to comment if they wanted to.

It is true that we're getting deeper into pytest + decorator magic, but hard to avoid for all the backend orchestration.

Thanks!

@tylerjereddy tylerjereddy merged commit 1db4966 into scipy:main Feb 16, 2024
@lucascolley
Copy link
Member Author

thanks for the thorough reviews Tyler! Will send a follow-up for the few remaining bits in the coming days 👍

@lucascolley lucascolley deleted the array-api-decorators branch February 16, 2024 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
array types Items related to array API support and input array validation (see gh-18286) maintenance Items related to regular maintenance tasks scipy.cluster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TST: improve array API test skip decorators
3 participants