Uh oh!
There was an error while loading. Please reload this page.
Migrate VariableArithmetic to NamedArrayArithmetic - #8244
Conversation
Illviljan
commented
Sep 28, 2023
Could you do dtypes.py in separate PR @andersy005 ? That one can be merged quite easily I think. |
dcherian
commented
Sep 28, 2023
@andersy005 what are your thoughts on migrating tests for this. 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. cc @pydata/xarray for opinions |
andersy005
commented
Sep 28, 2023
|
TomNicholas
commented
Sep 29, 2023
Maybe we could avoid divergence by importing from the NamedArray test suite and using the same arithmetic tests but on the Variable class? |
andersy005
commented
Sep 29, 2023
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. |
maxrjones
commented
Oct 11, 2023
It should work to use @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# namedarray/tests/test_namedarray.pyfromnamedarray.testingimportNamedArrayTestSuitefromnamedarrayimportNamedArrayclassTestNamedArray(NamedArrayTestSuite):
@pytest.fixturedeftarget(self, data):
returnNamedArray(["x", "y"], data, {"key": "value"})# xarray/tests/test_variable.pyfromnamedarray.testingimportNamedArrayTestSuitefromxarrayimportVariableclassTestVariable(NamedArrayTestSuite):
@pytest.fixturedeftarget(self, data):
data=0.5*np.arange(10).reshape(2, 5)
returnVariable(["x", "y"], data, {"key": "value"}) |
whats-new.rstapi.rst