-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Public testing framework for duck array integration #6894
Comments
with the implementation in #4972 you should already be able to specify a hypothesis strategy to create e.g. a random awkward array. Same with For setup and teardown I think we could use I agree that moving the array library tests to dedicated repositories makes a lot sense (for example, the |
Sounds good!
Yes just
But then the user writing the test code would have to write one of their own tests per xarray method wouldn't they? I think we should avoid putting that much work on them if we can. I think your current approach seems fine so far...
That's basically technical debt, so we should make a point to remove them from xarray eventually.
So long as @benbovy (or someone) writes new tests to cover the bugs that were revealed then this is fine. |
Typing duck array is also a little challenging I find, we pretty much only do |
Thanks @Illviljan - I was literally just thinking about that here. |
Another thing that might be useful is the hypothesis strategies in the test suite for the array API consortium standard (cc @keewis). |
there's also the experimental array api strategies built into hypothesis |
@asmeurer recently pointed me to https://data-apis.org/array-api-tests/. Would that be useful here? |
Looks like these use these
I think they are complementary. In theory if xarray supports the array API standard and a library passes all the data array API tests, then it should also pass all of xarray's tests (rendering the latter uneccessary). But in practice I think the tests here would still be useful, if only for the possible case of libraries that don't fully meet the API standard yet would still work fine in xarray. |
What is your issue?
In #4972 @keewis started writing a public framework for testing the integration of any duck array class in xarray, inspired by the testing framework pandas has for
ExtensionArrays
. This is a meta-issue for what our version of that framework for wrapping numpy-like duck arrays should look like.(Feel free to edit / add to this)
What behaviour should we test?
We have a lot of xarray methods to test with any type of duck array. Each of these bullets should correspond to one or more testing base classes which the duck array library author would inherit from. In rough order of increasing complexity:
Variable
Duckarray tests for constructors and properties #6903.shape
,.dtype
etc. exist on the wrapped array, see Awkward array backend? #4285 for example Duckarray tests for constructors and properties #6903We don't need to test that the array class obeys everything else in the Array API Standard. (For instance
.device
is probably never going to be used by xarray directly.) We instead assume that if the array class doesn't implement something in the API standard but all the generated tests pass, then all is well.How extensible does our testing framework need to be?
To be able to test any type of wrapped array our testing framework needs to itself be quite flexible.
np.testing.assert_equal
is not enough to guarantee correctness, so the user creating tests needs to specify additional checks. Automatic duck array testing - reductions #4972 shows how to do this for checking the units of resulting pint arrays.chunks
argument when the array is created, and any results need to first call.compute()
. Testing parallel-executed arrays might also require pretty complicatedSetUps
andTearDowns
in fixtures too. (see also Alternative parallel execution frameworks in xarray #6807)What documentation / examples do we need?
All of this content should really go on a dedicated page in the docs, perhaps grouped alongside other ways of extending xarray.
Where should duck array compatibility testing eventually live?
Right now the tests for sparse & pint are going into the xarray repo, but presumably we don't want tests for every duck array type living in this repository. I suggest that we want to work towards eventually having no array library-specific tests in this repository at all. (Except numpy I guess.) Thanks @crusaderky for the original suggestion.
Instead all tests involving pint could live in pint-xarray, all involving sparse could live in the sparse repository (or a new sparse-xarray repo), etc. etc. We would set those test jobs to re-run when xarray is released, and then xref any issues revealed here if needs be.
We should probably also move some of our existing tests #7023 (review)
The text was updated successfully, but these errors were encountered: