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

Ouranosinc / xclim / 6042074519
90%
main: 92%

Build:
Build:
LAST BUILD BRANCH: eco-ci-project
DEFAULT BRANCH: main
Ran 31 Aug 2023 08:29PM UTC
Jobs 2
Files 70
Run time 3s
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

31 Aug 2023 08:20PM UTC coverage: 90.667% (-0.01%) from 90.681%
6042074519

push

github

web-flow
Partial and relative unit declarations (#1414)

<!--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
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [x] CHANGES.rst has been updated (with summary of main changes)
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added

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

* `declare_units` can accept relative declaration. For example
`thresh="<tas>"` means that `thresh` should have the same dimensions as
`tas`. More complex declarations are possible : `thresh="<tas> / <pr>"`
or `thresh="[length] / <tas> "`.
* It can also be only _partially_ declared with `partial=True`. In that
case, the passed dimensions are stored in the wrapper, but the
`check_units` code is not injected.

Both additions are useful for "generic" indices. For example:
```
@declare_units(partial=True, threshold="<data>")
def spell_length(
    data: xr.DataArray, threshold: Quantified, reducer: str, freq: str, op: str
) 
```
Here, `spell_length` already "knows" that the `threshold` should have
the same units (dimensions) as `data`, but we still haven't declare
those. Different indicators can be created from the function, each one
either explicitly re-wrapping with `declare_units(data="...")` or simply
using `Indicator`'s `input` argument to map `data` to a known variable.

Another change this brings is an additional `dimensions` field in
`variable.yml`. I realized that Indicators using `input` to map generic
inputs to precipitation variables were not "aware" that the "hydro"
context could be used. This was because the mapping was passing... (continued)

89 of 97 new or added lines in 5 files covered. (91.75%)

8316 of 9172 relevant lines covered (90.67%)

3.48 hits per line

Jobs
ID Job ID Ran Files Coverage
1 run-{{ matrix.tox-env }} - 6042074519.1 31 Aug 2023 08:32PM UTC 0
86.26
2 run-{{ matrix.tox-env }}-opt-slow - 6042074519.2 31 Aug 2023 08:32PM UTC 0
90.26
Source Files on build 6042074519
Detailed source file information is not available for this build.
  • Back to Repo
  • 0f71622c on github
  • Prev Build on master (#6041816573)
  • Next Build on master (#6042371855)
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