示例#1
0
def test_rank_wrong_var_name():
    with pytest.raises(ValueError):
        rank(
            raster_ds[['arr1', 'arr2', 'arr3']],
            'arr1',
            data_vars=['arr2', 'arr9'],
        )
示例#2
0
def test_rank_all_data_vars_not_contain_ref_error():
    with pytest.raises(ValueError):
        rank(
            raster_ds[['arr1', 'arr2', 'arr3']],
            'arr9',
            data_vars=['arr1', 'arr2'],
        )
示例#3
0
def test_rank_data_vars_elem_type_error():
    with pytest.raises(TypeError):
        rank(raster_ds[['arr1', 'arr2', 'arr3']], 'arr1', data_vars=[0])
示例#4
0
def test_rank_dim_ref_param_type_error():
    with pytest.raises(TypeError):
        rank(raster_ds[['arr1', 'arr2', 'arr3']], ['arr1'])
示例#5
0
def test_rank_raster_type_error():
    with pytest.raises(TypeError):
        rank(arr1, 'arr1')
示例#6
0
def test_rank_some_data_vars():
    expected_arr = xr.DataArray([[np.nan, 4, 2, 2], [4, 3, np.nan, 5],
                                 [5, 1, 2, 0], [np.nan, 3, 2, np.nan]])
    result_arr = rank(raster_ds, 'arr', ['arr1', 'arr2'])

    assert result_arr.equals(expected_arr)
示例#7
0
def test_rank_all_data_vars():
    expected_arr = xr.DataArray([[np.nan, 3, 2, 0], [4, 1, np.nan, 1],
                                 [5, 1, 2, 0], [np.nan, 1, 1, np.nan]])
    result_arr = rank(raster_ds, 'arr')

    assert result_arr.equals(expected_arr)