Skip to content

Commit

Permalink
more refactoring to pass on and add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
coxipi committed Nov 27, 2024
1 parent 57ccf19 commit e4a1a40
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/test_sdba/test_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,30 @@ def test_harmonize_units_multivariate(self, series, random, use_dask):
ds, ds2 = unstack_variables(da), unstack_variables(da2)
assert (ds.tas.units == ds2.tas.units) & (ds.pr.units == ds2.pr.units)

def test_matching_time(self, series, random):
def test_matching_times(self, series, random):
n = 10
u = random.random(n)
da = series(u, "tas", start="2000-01-01")
da2 = series(u, "tas", start="2010-01-01")
with pytest.raises(
ValueError, match="`ref` and `hist` should have the same time arrays."
ValueError,
match="`ref` and `hist` have distinct time arrays, this is not supported for BaseAdjustment adjustment.",
):
BaseAdjustment._check_matching_times(ref=da, hist=da2)

def test_matching_time_sizes(self, series, random):
n = 10
u = random.random(n)
da = series(u, "tas", start="2000-01-01")
n = 20
u = random.random(n)
da2 = series(u, "tas", start="2010-01-01")
with pytest.raises(
ValueError,
match="Inputs have different size for the time array, this is not supported for BaseAdjustment adjustment.",
):
BaseAdjustment._check_matching_time_sizes(ref=da, hist=da2)


class TestLoci:
@pytest.mark.parametrize("group,dec", (["time", 2], ["time.month", 1]))
Expand Down

0 comments on commit e4a1a40

Please sign in to comment.