def test_combine_wrong_var_name(): with pytest.raises(ValueError): combine( raster_ds[['arr1', 'arr2', 'arr3']], data_vars=['arr1', 'arr9'], )
def test_combine_data_vars_elem_type_error(): with pytest.raises(TypeError): combine(raster_ds[['arr1', 'arr2', 'arr3']], data_vars=[0])
def test_combine_some_data_vars(): result_arr = combine(raster_ds[['arr1', 'arr2', 'arr3']], ['arr1', 'arr3']) expected_arr = xr.DataArray([[np.nan, 1, 2, 3], [4, 5, np.nan, 6], [7, 6, 2, 8], [9, 10, 11, np.nan]]) assert result_arr.equals(expected_arr)
def test_combine_raster_type_error(): with pytest.raises(TypeError): combine(arr1)
def test_combine_all_data_vars(): result_arr = combine(raster_ds[['arr1', 'arr2', 'arr3']]) expected_arr = xr.DataArray([[np.nan, 1, 2, 3], [4, 5, np.nan, 6], [7, 8, 9, 10], [np.nan, 11, 12, np.nan]]) assert result_arr.equals(expected_arr)