diff --git a/.zenodo.json b/.zenodo.json index 4f1c80aa..1b58c911 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -60,6 +60,11 @@ "orcid": "https://orcid.org/0000-0002-6799-9109", "affiliation": "Bureau of Meteorology, Australia", "name": "Holmes, Ryan" + }, + { + "orcid": "https://orcid.org/0009-0001-4486-0120", + "affiliation": "Independent researcher, Vietnam", + "name": "Bogacheva, Jenya" } diff --git a/packages/utils/tests/data/test_converter.py b/packages/utils/tests/data/test_converter.py index 6fc5df5a..a7ed9f12 100644 --- a/packages/utils/tests/data/test_converter.py +++ b/packages/utils/tests/data/test_converter.py @@ -17,37 +17,36 @@ from pyearthtools.utils.data import converter -SIMPLE_DATA_ARRAY = xr.DataArray([1, 2, 3, 4, 5]) +SIMPLE_DATA_ARRAY = xr.DataArray([1, 2, 3, 4, 5], dims=("x",), coords={"x": [0, 1, 2, 3, 4]}, name="Entry") SIMPLE_DATA_SET = xr.Dataset({"Entry": SIMPLE_DATA_ARRAY}) def test_NumpyConverter(): """ - This test provides coverage, but does not test for - correctness + Checks conversion from xarray to numpy and back """ - # This round-trips convert and unconvert - nc = converter.NumpyConverter() - _np_array1 = nc.convert_from_xarray(SIMPLE_DATA_ARRAY) - - # FIXME - # xr_da1 = nc.convert_to_xarray(np_array1) + nc_da = converter.NumpyConverter() + _ = nc_da.convert_from_xarray(SIMPLE_DATA_ARRAY) - # Test conversion from xarray works nc = converter.NumpyConverter() - _np_array2 = nc.convert_from_xarray(SIMPLE_DATA_SET) + np_array = nc.convert_from_xarray(SIMPLE_DATA_SET) + xr_ds = nc.convert_to_xarray(np_array) + assert isinstance(xr_ds, xr.Dataset) + assert "Entry" in xr_ds + xr.testing.assert_identical(xr_ds["Entry"], SIMPLE_DATA_ARRAY) def test_DaskConverter(): """ - This test provides coverage, but does not test for - correctness + Checks conversion from xarray to dask and back """ dc = converter.DaskConverter() - _da_array1 = dc.convert_from_xarray(SIMPLE_DATA_ARRAY) - - # FIXME - # xr_da1 = dc.convert_to_xarray(da_array1) + da_array = dc.convert_from_xarray(SIMPLE_DATA_SET) + da_array = da_array.compute() + xr_ds = dc.convert_to_xarray(da_array) + assert isinstance(xr_ds, xr.Dataset) + assert "Entry" in xr_ds + xr.testing.assert_identical(xr_ds["Entry"], SIMPLE_DATA_ARRAY)