Skip to content

Commit

Permalink
Add test for different training times (:pull:1995 extra) (#2013)
Browse files Browse the repository at this point in the history
<!--Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [ ] This PR addresses an already opened issue (for bug fixes /
features)
    - This PR fixes #xyz
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [ ] CHANGELOG.rst has been updated (with summary of main changes)
- [ ] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added

### What kind of change does this PR introduce?

*Just add a test for Sarah's hidden feature (`ref` and `hist` can have
different times, which will not affect the computation of adjustment
factors)

### Does this PR introduce a breaking change?


### Other information:
  • Loading branch information
coxipi authored Dec 10, 2024
2 parents 6c554fa + ed0905f commit 127ba65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
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

0 comments on commit 127ba65

Please sign in to comment.