Esempio n. 1
0
def test_resample_iterations_dix_no_squeeze(f_prob):
    """Test _resample_iteration_idx with singular dimension."""
    da = f_prob.expand_dims("test_dim")
    actual = resample_iterations_idx(da, iterations=ITERATIONS)
    other = resample_iterations(da, iterations=ITERATIONS)
    assert "test_dim" in actual.dims
    assert actual.coords.to_dataset().equals(other.coords.to_dataset())
Esempio n. 2
0
def test_resampling_roughly_identical_mean(f_prob):
    """check that resampling functions result in allclose iteration mean."""
    da = f_prob.isel(lon=0, lat=0, drop=True)
    iterations = 1000
    r1 = resample_iterations(da, iterations=iterations, replace=True)
    r2 = resample_iterations_idx(da, iterations=iterations, replace=True)
    xr.testing.assert_allclose(r1.mean("iteration"),
                               r2.mean("iteration"),
                               atol=0.05,
                               rtol=0.05)
Esempio n. 3
0
def test_resample_iterations_dix_no_squeeze(f_prob):
    """Test _resample_iteration_idx with singular dimension.

    Currently this fails for dimensions with just a single index as we use `squeeze` in
    the code and not using squeeze doesnt maintain functionality. This means that
    ``_resample_iteration_idx`` should not be called on singleton dimension inputs
    (which is not critical and can be circumvented when using squeeze before.).
    """
    da = f_prob.expand_dims("test_dim")
    actual = resample_iterations_idx(da, iterations=ITERATIONS)
    assert "test_dim" in actual.dims
Esempio n. 4
0
def test_resampling_identical_dim(f_prob):
    """check that resampling functions have the same ordering of dims and coords."""
    da = f_prob
    r1 = resample_iterations(da, iterations=ITERATIONS)
    r2 = resample_iterations_idx(da, iterations=ITERATIONS)
    assert_dim_coords(r1, r2)