Skip to content

Commit

Permalink
Merge branch 'master' into security-policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Jan 25, 2024
2 parents 96b2c38 + 2065fe1 commit 8a4f87c
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 147 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/label-on-approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
allowed-endpoints: >
api.github.com:443
- name: Find comment
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
uses: peter-evans/find-comment@d5fe37641ad8451bdd80312415672ba26c86575e # v3.0.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -74,7 +74,7 @@ jobs:
(steps.fc.outputs.comment-id == '') &&
(!contains(github.event.pull_request.labels.*.name, 'approved')) &&
(github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -85,7 +85,7 @@ jobs:
- name: Update comment
if: |
contains(github.event.pull_request.labels.*.name, 'approved')
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ jobs:
strategy:
matrix:
include:
- tox-env: py38-coverage-eofs
- tox-env: py38-coverage
python-version: "3.8"
markers: -m 'not slow'
- tox-env: py39-coverage-sbck-eofs
- tox-env: py39-coverage-sbck
python-version: "3.9"
markers: -m 'not slow'
- tox-env: py310-coverage # No markers -- includes slow tests
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/testdata-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
echo "Latest xclim-testdata tag: ${{ env.XCLIM_TESTDATA_TAG }}"
echo "Tag for xclim-testdata in CI: ${{ env.XCLIM_TESTDATA_BRANCH }}"
- name: Find Comment
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
uses: peter-evans/find-comment@d5fe37641ad8451bdd80312415672ba26c86575e # v3.0.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -60,7 +60,7 @@ jobs:
core.setFailed('Configured `xclim-testdata` tag is not `latest`.')
- name: Update Failure Comment
if: ${{ failure() }}
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -76,7 +76,7 @@ jobs:
edit-mode: replace
- name: Update Success Comment
if: ${{ success() }}
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/workflow-warning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
allowed-endpoints: >
api.github.com:443
- name: Find comment
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
uses: peter-evans/find-comment@d5fe37641ad8451bdd80312415672ba26c86575e # v3.0.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -45,7 +45,7 @@ jobs:
(steps.fc.outputs.comment-id == '') &&
(!contains(github.event.pull_request.labels.*.name, 'approved')) &&
(github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Update comment
if: |
contains(github.event.pull_request.labels.*.name, 'approved')
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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 All @@ -25,6 +25,7 @@ Breaking changes
* `bump2version` has been replaced with `bump-my-version` to bump the version number using configurations set in the `pyproject.toml` file. (:issue:`1557`, :pull:`1569`).
* `xclim`'s units registry and units formatting are now extended from `cf-xarray`. The exponent sign "^" is now never added in the ``units`` attribute. For example, square meters are given as "m2" instead of "m^2" by xclim, both are still accepted as input. (:issue:`1010`, :pull:`1590`).
* `yamale` is now listed as a core dependency (was previously listed in the `dev` installation recipe). (:issue:`1595`, :pull:`1596`).
* Due to a licensing limitation, the calculation of empirical orthogonal function based on `eofs` (``xclim.sdba.properties.first_eof``) has been removed from `xclim`. (:issue:`1620`, :pull:`1621`).

Bug fixes
^^^^^^^^^
Expand Down
23 changes: 7 additions & 16 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To install `xclim` via `pip`, run this command in your terminal:

.. code-block:: shell
$ pip install xclim
$ python -m pip install xclim
If you don't have `pip`_ installed, this `Python installation guide`_ can guide you through the process.

Expand Down Expand Up @@ -55,7 +55,7 @@ Both of these libraries are available on PyPI and conda-forge:

.. code-block:: shell
$ pip install flox clisops
$ python -m pip install flox clisops
# Or, alternatively:
$ conda install -c conda-forge flox clisops
Expand All @@ -70,7 +70,7 @@ For convenience, these libraries can be installed alongside `xclim` using the fo

.. code-block:: shell
$ pip install -r requirements_upstream.txt
$ python -m pip install -r requirements_upstream.txt
Or, alternatively:

Expand Down Expand Up @@ -105,17 +105,8 @@ Afterwards, `SBCK` can be installed from PyPI using `pip`:

.. code-block:: shell
$ pip install SBCK
$ python -m pip install pybind11 sbck
Another experimental function :py:indicator:`xclim.sdba.property.first_eof` makes use of the `eofs`_ library, which is available on both PyPI and conda-forge:

.. code-block:: shell
$ pip install eofs
# or alternatively,
$ conda install -c conda-forge eofs
.. _eofs: https://ajdawson.github.io/eofs/
.. _SBCK: https://github.com/yrobink/SBCK
.. _Eigen3: https://eigen.tuxfamily.org/index.php

Expand Down Expand Up @@ -145,7 +136,7 @@ Once you have extracted a copy of the source, you can install it with pip:

.. code-block:: shell
$ pip install -e ".[dev]"
$ python -m pip install -e ".[dev]"
Alternatively, you can also install a local development copy via `flit`_:

Expand All @@ -160,10 +151,10 @@ Alternatively, you can also install a local development copy via `flit`_:
Creating a Conda environment
----------------------------

To create a conda environment including `xclim`'s dependencies and several optional libraries (notably: `clisops`, `eigen`, `eofs`, and `flox`) and development dependencies, run the following command from within your cloned repo:
To create a conda environment including `xclim`'s dependencies and several optional libraries (notably: `clisops`, `eigen`, `sbck`, and `flox`) and development dependencies, run the following command from within your cloned repo:

.. code-block:: console
$ conda env create -n my_xclim_env python=3.8 --file=environment.yml
$ conda activate my_xclim_env
(my_xclim_env) $ pip install -e .
(my_xclim_env) $ python -m pip install -e .
20 changes: 0 additions & 20 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -1835,26 +1835,6 @@ @article{roy_extremeprecip_2023
year = {2023},
}

@article{dawson_eofs_2016,
title = {eofs: {A} {Library} for {EOF} {Analysis} of {Meteorological}, {Oceanographic}, and {Climate} {Data}},
volume = {4},
issn = {2049-9647},
shorttitle = {eofs},
url = {https://openresearchsoftware.metajnl.com/article/10.5334/jors.122/},
doi = {10.5334/jors.122},
abstract = {Article: eofs: A Library for EOF Analysis of Meteorological, Oceanographic, and Climate Data},
language = {eng},
number = {1},
urldate = {2022-11-11},
journal = {Journal of Open Research Software},
author = {Dawson, Andrew},
month = apr,
year = {2016},
note = {Number: 1
Publisher: Ubiquity Press},
pages = {e14},
}

@article{francois_multivariate_2020,
title = {Multivariate bias corrections of climate simulations: which benefits for which losses?},
volume = {11},
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies:
- xarray >=2022.06.0,<2023.11.0
- yamale
# Extras
- eofs
- flox
# Testing and development dependencies
- black >=22.12
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ target-version = [
]

[tool.bumpversion]
current_version = "0.47.5-dev.8"
current_version = "0.47.5-dev.9"
commit = true
commit_args = "--no-verify"
tag = false
Expand Down
16 changes: 0 additions & 16 deletions tests/test_sdba/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,3 @@ def test_get_measure(self, open_dataset):

meas = sdba.properties.var.get_measure()(sim_var, ref_var)
np.testing.assert_allclose(meas, [0.408327], rtol=1e-3)


class TestEOF:
def test_first_eof(self, open_dataset):
pytest.importorskip("eofs")
sim = (
open_dataset("NRCANdaily/nrcan_canada_daily_tasmax_1990.nc")
.tasmax.isel(lon=slice(0, 10), lat=slice(50, 60))
.load()
)

out = sdba.properties.first_eof(sim)
np.testing.assert_allclose(
[out.mean(), out.max()], [0.099976, 0.103867], rtol=1e-5
)
assert (out.isnull() == sim.isnull().any("time")).all()
13 changes: 2 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ env_list =
docs
notebooks_doctests
offline-prefetch
; opt-slow
py38
py39-upstream-doctest
py310
Expand Down Expand Up @@ -58,8 +57,10 @@ allowlist_externals =
# Requires tox-conda compatible with [email protected]
;[testenv:conda]
;description = Run tests with pytest under {basepython} (Anaconda distribution)
;commands_pre =
;conda_channels = conda-forge
;conda_env = environment-dev.yml
;deps =
;extras =

[testenv:notebooks_doctests{-coverage,}]
Expand All @@ -68,15 +69,6 @@ commands =
pytest --no-cov --nbval --dist=loadscope --rootdir=tests/ --ignore=docs/notebooks/example.ipynb docs/notebooks
pytest --rootdir=tests/ --xdoctest xclim

# Requires tox-conda compatible with [email protected]
;[testenv:opt-{slow,not_slow}]
;description = Run tests with optional requirements (SBCK (experimental), eofs) and pytest under {basepython} (Anaconda distribution)
;conda_env = environment-dev.yml
;commands =
; pip check
; !slow: pytest xclim -m "not slow" --durations=10
; slow: pytest xclim --durations=10

[testenv:offline{-prefetch,}{-coverage,}]
description = Run tests with pytest under {basepython}, preventing socket connections (except for unix sockets for async support)
commands:
Expand Down Expand Up @@ -112,7 +104,6 @@ deps =
numba: llvmlite==0.42.0rc1
coverage: coveralls
upstream: -rrequirements_upstream.txt
eofs: eofs
sbck: pybind11
install_command = python -m pip install --no-user {opts} {packages}
download = True
Expand Down
2 changes: 1 addition & 1 deletion xclim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

__author__ = """Travis Logan"""
__email__ = "[email protected]"
__version__ = "0.47.5-dev.8"
__version__ = "0.47.5-dev.9"


_module_data = _files("xclim.data")
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
Loading

0 comments on commit 8a4f87c

Please sign in to comment.