• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Ouranosinc / xclim / 11485787478
92%

Build:
DEFAULT BRANCH: main
Ran 23 Oct 2024 06:22PM UTC
Jobs 8
Files 73
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

23 Oct 2024 06:18PM UTC coverage: 89.377% (-0.01%) from 89.391%
11485787478

push

github

web-flow
Fix conversion of units of multivariate DataArray in sdba (#1972)

<!--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?

Conversion of units of multivariate DataArray is now properly handled
`sdba.TrainAdjust` and `sdba.Adjust`. There was a bug where the units
could be changed before a conversion of the magntitudes could occur.

e.g. 

```python
out = sdba.dOTC.adjust(sim=sim,ref=ref,hist=hist)
```
`hist` would be converted to `ref` units properly, and then, the units
of `sim` would be changed too, without any actual conversion taking
place. This may have something to do with the weirdness of Generators.



### Does this PR introduce a breaking change?

No 

### Other information:

Just to show where I'm getting at, you can test: 

```python
from xclim import sdba
from xclim.testing import open_dataset
ds = open_dataset('sdba/ahccd_1950-2013.nc').isel(location=0)
ds2 = open_dataset('sdba/CanESM2_1950-2100.nc').isel(location=0)
da = sdba.stack_variables(ds)
da2 = sdba.stack_variables(ds2)
ref = da.sel(time=slice("1950", "1979"))
hist = da2.sel(time=slice("1950", "1979"))
sim = da2.sel(time=slice("1980", "2009"))
out = sdba.dOTC.adjust(sim=sim.copy(), ref=ref.copy(), hist=hist.copy()) 
print(out["multivar"].attrs["_units"], out.sel(multivar="tasmax").mean().values)

>>> ['mm day-1', 'degC'] 14.25703882896165  # new xclim
>>... (continued)

6 of 6 new or added lines in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

9373 of 10487 relevant lines covered (89.38%)

7.55 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
2
95.12
-0.7% xclim/sdba/base.py
Jobs
ID Job ID Ran Files Coverage
1 run-3.11-ubuntu-latest-standard - 11485787478.1 23 Oct 2024 06:31PM UTC 73
83.57
GitHub Action Run
2 run-3.10-windows-latest-py310-coverage-prefetch - 11485787478.2 23 Oct 2024 06:31PM UTC 73
81.5
GitHub Action Run
3 run-3.12-ubuntu-latest-standard - 11485787478.3 23 Oct 2024 06:31PM UTC 73
81.69
GitHub Action Run
4 run-3.10-ubuntu-latest-standard - 11485787478.4 23 Oct 2024 06:31PM UTC 73
81.66
GitHub Action Run
5 run-3.11-ubuntu-latest-py311-coverage-sbck-offline-prefetch - 11485787478.5 23 Oct 2024 06:31PM UTC 73
83.54
GitHub Action Run
6 run-{{ matrix.python-version }}-conda - 11485787478.6 23 Oct 2024 06:31PM UTC 73
87.17
GitHub Action Run
7 run-3.11-macos-latest-py311-coverage-extras - 11485787478.7 23 Oct 2024 06:31PM UTC 73
87.13
GitHub Action Run
8 11485787478.8 23 Oct 2024 06:31PM UTC 73
81.66
GitHub Action Run
Source Files on build 11485787478
  • Tree
  • List 73
  • Changed 71
  • Source Changed 0
  • Coverage Changed 24
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • aa52a717 on github
  • Prev Build on main (#11444851732)
  • Next Build on main (#11506427990)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc