Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for different training times (:pull:1995 extra) #2013

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Bug fixes
Internal changes
^^^^^^^^^^^^^^^^
* Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`).
* Using different time for `ref` and `hist` is now explicitly forbidden in many bias adjustment methods (e.g. `EmpiricalQuantileMapping`). Methods that combine `ref,hist,sim` in a same `map_groups` also require the time arrays to be equal in size. (:issue:`1903`, :pull:`1995`)
* Nans in `OTC` and `dOTC` are only dropped and put back in place at the lowest level so that the size of time array never changes on xarray levels. (:pull:`1995`)
* Using different time for `ref` and `hist` is now explicitly forbidden in many bias adjustment methods (e.g. `EmpiricalQuantileMapping`). Methods that combine `ref,hist,sim` in a same `map_groups` also require the time arrays to be equal in size. (:issue:`1903`, :pull:`1995`, :pull:`2013`)
* Nans in `OTC` and `dOTC` are only dropped and put back in place at the lowest level so that the size of time array never changes on xarray levels. (:pull:`1995`, :pull:`2013`)
* `streamflow` entry replaced with `q` in ``variables.yml``. (:issue:`1912`, :pull:`1996`)
* In order to address 403 (forbidden) request errors when retrieving data from GitHub via ReadTheDocs, the ``nimbus`` class has been modified to use an overloaded `fetch` method that appends a User-Agent header to the request. (:pull:`2001`).
* Addressed a very rare race condition that can happen if `pytest` is tearing down the test environment when running across multiple workers. (:pull:`1863`).
Expand Down
13 changes: 13 additions & 0 deletions tests/test_sdba/test_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,19 @@ def test_add_dims(self, use_dask, open_dataset):
scen2 = EQM2.adjust(sim).load()
assert scen2.sel(location=["Kugluktuk", "Vancouver"]).isnull().all()

def test_different_times_training(self, series, random):
n = 10
u = random.random(n)
ref = series(u, "tas", start="2000-01-01")
u2 = random.random(n)
hist = series(u2, "tas", start="2000-01-01")
hist_fut = series(u2, "tas", start="2001-01-01")
ds = EmpiricalQuantileMapping.train(ref, hist).ds
EmpiricalQuantileMapping._allow_diff_training_times = True
ds_fut = EmpiricalQuantileMapping.train(ref, hist_fut).ds
EmpiricalQuantileMapping._allow_diff_training_times = False
assert (ds.af == ds_fut.af).all()


@pytest.mark.slow
class TestMBCn:
Expand Down
Loading