diff --git a/test/test_helpers/test_geofunctions.py b/test/test_helpers/test_geofunctions.py index 1c096e06ac2d091de2a973d5013181849933e743..56ea6cba423f262b19e7294603f93268f9303548 100644 --- a/test/test_helpers/test_geofunctions.py +++ b/test/test_helpers/test_geofunctions.py @@ -70,8 +70,7 @@ class TestHaversineDist: np.array([0., 0., 0.]), True, np.array([[np.pi, np.pi/2., np.pi/4.], [np.pi/2., 0., np.pi/4.], - [3./4.*np.pi, np.pi/4., 0.]]) - ) + [3./4.*np.pi, np.pi/4., 0.]])), )) def test_haversine_dist_on_unit_sphere_fields_and_scalars(self, lat1, lon1, lat2, lon2, to_radians, expected_dist): dist = haversine_dist(lat1=lat1, lon1=lon1, lat2=lat2, lon2=lon2, to_radians=to_radians, earth_radius=1.) @@ -81,7 +80,7 @@ class TestHaversineDist: ( (np.array([0., 0.]), 0., 0., 0., True), (0., np.array([0., 0.]), 0., 0., True), - (0., 0.,np.array([0., 0.]), 0., True), + (0., 0., np.array([0., 0.]), 0., True), (0., 0., 0., np.array([0., 0.]), True), )) diff --git a/test/test_helpers/test_helpers.py b/test/test_helpers/test_helpers.py index 29e2601c311fed6671f65a65ade1edd285ee78f7..f2e2b341afa424ce351c0253f41c75e362b77eba 100644 --- a/test/test_helpers/test_helpers.py +++ b/test/test_helpers/test_helpers.py @@ -1,5 +1,6 @@ import numpy as np import xarray as xr +import dask.array as da import datetime as dt import logging @@ -352,6 +353,10 @@ class TestConvert2xrDa: def custom_xr_dataset(self, custom_xr_dataarray): return xr.Dataset({'test_1': custom_xr_dataarray}) + @pytest.fixture + def custom_1d_daarray(self, custom_1d_npdata): + return da.array(custom_1d_npdata) + def test_convert2xrda_xrdata_in(self, custom_xr_dataarray, custom_xr_dataset): assert (convert2xrda(custom_xr_dataarray) == custom_xr_dataarray).all() assert (convert2xrda(custom_xr_dataset) == custom_xr_dataset).all() @@ -416,3 +421,10 @@ class TestConvert2xrDa: converted_data = convert2xrda(wrong_input, use_1d_default=True) assert f"`arr' must be arry-like, int or float. But is of type {type(wrong_input)}" in e.value.args[0] + def test_convert2xrda_dask_in_default_true_nokwargs(self, custom_1d_daarray): + with pytest.raises(TypeError) as e: + convert2xrda(custom_1d_daarray, True) + assert "`use_1d_default=True' is used with `arr' of type da.array. For da.arrays please pass `use_1d_default=False' and specify keywords for xr.DataArray via kwargs." in \ + e.value.args[0] + assert "`use_1d_default=True' is used with `arr' of type da.array. For da.arrays please pass" + \ + " `use_1d_default=False' and specify keywords for xr.DataArray via kwargs." in e.value.args[0]