Skip to content

Commit

Permalink
Add missing types in yaml schema (#1600)
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:
- [x] This PR addresses an already opened issue (for bug fixes /
features)
    - This PR fixes #1595
- [ ] 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?

* Allows "str" for indicator parameter "src_freq"
* Allows "kind : int" for indicator parameter's parameters.

### Does this PR introduce a breaking change?
No, it simply validates yaml definition that were supported before.

### Other information:
I added a note to the module doc about "kind" and how it is meant to be
used in a yaml.
  • Loading branch information
aulemahal authored Jan 24, 2024
2 parents f28cbbd + 8368412 commit e1148b2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Announcements
New features and enhancements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Added uncertainty partitioning method `lafferty_sriver` from Lafferty and Sriver (2023), which can partition uncertainty related to the downscaling method. (:issue:`1497`, :pull:`1529`).
* Validate YAML indicators description before trying to build module. (:issue:`1523`, :pull:`1560`).
* Validate YAML indicators description before trying to build module. (:issue:`1523`, :issue:`1595`, :pull:`1560`, :pull:`1596`, :pull:`1600`).
* Support ``indexer`` keyword in YAML indicator description. (:issue:`1522`, :pull:`1561`).
* New ``xclim.core.calendar.stack_periods`` and ``unstack_periods`` for performing ``rolling(time=...).construct(..., stride=...)`` but with non-uniform temporal periods like years or months. They replace ``xclim.sdba.processing.construct_moving_yearly_window`` and ``unpack_moving_yearly_window`` which are deprecated and will be removed in a future release.

Expand Down
2 changes: 2 additions & 0 deletions xclim/core/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
units: <param units> # Only valid if "compute" points to a generic function
default : <param default>
description: <param description>
kind: <param kind> # Override the parameter kind.
# This is mostly useful for transforming an optional variable into a required one by passing ``kind: 0``.
...
... # and so on.
Expand Down
3 changes: 2 additions & 1 deletion xclim/data/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variables: map(include('variable'), key=regex(r'^[\w]+$'), required=False)
indicator:
abstract: str(required=False)
allowed_periods: list(enum('A', 'Q', 'M', 'W'), required=False)
src_freq: list(str(), required=False)
src_freq: any(str(), list(str()), required=False)
base: str(required=False)
compute: str(required=False)
input: map(str(), key=str(), required=False)
Expand All @@ -32,6 +32,7 @@ parameter:
default: any(str(), num(), bool(), null(), include('indexer'), required=False)
choices: list(str(), required=False)
units: str(required=False)
kind: int(required=False)

indexer:
drop: bool(required=False)
Expand Down

0 comments on commit e1148b2

Please sign in to comment.