You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting a new issue to continue the discussion from #8244 about the test structure for NamedArray (xref #8238).
In theory it seems like we'd want to test both Variable and NamedArray, but I also don't like the idea of them potentially diverging once we switch to a new repo. OTOH perhaps there won't be much updating of such core functionality.
Maybe we could avoid divergence by importing from the NamedArray test suite and using the same arithmetic tests but on the Variable class?
i'm of the same opinion as @TomNicholas that we can package the shared tests in namedarray, and have the tests for Variable inherit those tests while also including their own specific tests.
It should work to use pytest_collection_modifyitems to collect tests from namedarray that should be also tested in xarray without modification. It's slightly more complicated to add external tests that need to override fixtures, but pytest-dev/pytest#421 (comment) lays out a nice solution (see example pseudo-code below for NamedArray/Variable example). I recognize that this type of property testing would be well suited for Hypothesis, but also expect that would slow down progress too much to be an immediate solution.
@andersy005 when do you think would be the best time to test out this method for migrating tests? I could try it out anytime and don't see many downsides to testing while namedarray is still coupled with xarray.
# namedarray/testing.pyimportnumpyasnpclassNamedArrayTestSuite:
@pytest.fixturedeftarget(self):
"""Fixture that needs to be re-declared"""assert0@pytest.fixturedefdata(self):
return0.5*np.arange(10).reshape(2, 5)
deftest_properties(self, target, data):
asserttarget.dims== ("x", "y")
assertnp.array_equal(target.data, data)
asserttarget.attrs== {"key": "value"}
asserttarget.ndim==2asserttarget.sizes== {"x": 2, "y": 5}
asserttarget.size==10asserttarget.nbytes==80assertlen(target) ==2
Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!
Starting a new issue to continue the discussion from #8244 about the test structure for NamedArray (xref #8238).
It should work to use
pytest_collection_modifyitems
to collect tests from namedarray that should be also tested in xarray without modification. It's slightly more complicated to add external tests that need to override fixtures, but pytest-dev/pytest#421 (comment) lays out a nice solution (see example pseudo-code below for NamedArray/Variable example). I recognize that this type of property testing would be well suited for Hypothesis, but also expect that would slow down progress too much to be an immediate solution.@andersy005 when do you think would be the best time to test out this method for migrating tests? I could try it out anytime and don't see many downsides to testing while namedarray is still coupled with xarray.
The text was updated successfully, but these errors were encountered: