Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Ouranosinc/xclim into fix_d…
Browse files Browse the repository at this point in the history
…otc_standardization
  • Loading branch information
coxipi committed Sep 4, 2024
2 parents 86be79a + 32cb8f5 commit e313e52
Show file tree
Hide file tree
Showing 89 changed files with 800 additions and 912 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/add-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Generate App Token
id: token_generator
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3
uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4
with:
app-id: ${{ secrets.OURANOS_HELPER_BOT_ID }}
private-key: ${{ secrets.OURANOS_HELPER_BOT_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
pypi.org:443
- name: Generate App Token
id: token_generator
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3
uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4
with:
app-id: ${{ secrets.OURANOS_HELPER_BOT_ID }}
private-key: ${{ secrets.OURANOS_HELPER_BOT_KEY }}
Expand All @@ -55,7 +55,7 @@ jobs:
with:
token: ${{ steps.token_generator.outputs.token }}
- name: Set up Python3
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: "3.x"
- name: Import GPG Key
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install CI libraries
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install CI libraries
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
sudo apt-get update
sudo apt-get install libeigen3-dev
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install CI libraries
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-mastodon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Send toot to Mastodon
if: ${{ github.event.inputs.dry-run != 'true' }} || ${{ github.event_name == 'release' }}
uses: cbrgm/mastodon-github-action@b97a4c288a6fd9d75821d92432704339202e090f # v2.1.7
uses: cbrgm/mastodon-github-action@eec9734402fe90511688538f942a916c61808ba7 # v2.1.8
with:
url: ${{ secrets.MASTODON_URL }}
access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python3
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: "3.x"
- name: Install CI libraries
Expand All @@ -40,4 +40,4 @@ jobs:
run: |
python -m flit build
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 # v1.10.1
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: Upload Artifact
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874
with:
name: SARIF file
path: results.sarif
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python3
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: "3.x"
- name: Install CI libraries
Expand All @@ -40,7 +40,7 @@ jobs:
run: |
python -m flit build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 # v1.10.1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ repos:
- id: yamllint
args: [ '--config-file=.yamllint.yaml' ]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.6.3
hooks:
- id: ruff
args: [ '--fix' ]
- repo: https://github.com/pylint-dev/pylint
rev: v3.2.6
rev: v3.2.7
hooks:
- id: pylint
args: [ '--rcfile=.pylintrc.toml', '--errors-only', '--jobs=0', '--disable=import-error' ]
Expand Down Expand Up @@ -92,7 +92,7 @@ repos:
hooks:
- id: gitleaks
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.1
rev: 0.29.2
hooks:
- id: check-github-workflows
- id: check-readthedocs
Expand Down
19 changes: 10 additions & 9 deletions .pylintrc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
# extension-pkg-allow-list =
extension-pkg-allow-list = ["cftime"]

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
Expand All @@ -36,7 +36,7 @@ fail-under = 10
# from-stdin =

# Files or directories to be skipped. They should be base names, not paths.
ignore = ["CVS"]
ignore = ["CVS", "conftest.py"]

# Add files or directories matching the regular expressions patterns to the
# ignore-list. The regex matches against paths and can be in Posix or Windows
Expand All @@ -62,7 +62,7 @@ ignored-modules = ["xclim.indicators"]
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use, and will cap the count on Windows to
# avoid hangs.
jobs = 1
jobs = 4

# Control the amount of potential inferred values when inferring a single object.
# This can help the performance when dealing with large functions or complex,
Expand All @@ -78,7 +78,7 @@ persistent = true

# Minimum Python version to use for version dependent checks. Will default to the
# version used to run pylint.
py-version = "3.8"
py-version = "3.9"

# Discover python modules and packages in the file system subtree.
# recursive =
Expand Down Expand Up @@ -253,13 +253,13 @@ max-args = 15
max-attributes = 7

# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr = 5
max-bool-expr = 10

# Maximum number of branch for function / method body.
max-branches = 30

# Maximum number of locals for function / method body.
max-locals = 50
max-locals = 75

# Maximum number of parents for a class (see R0901).
max-parents = 7
Expand All @@ -268,7 +268,7 @@ max-parents = 7
max-public-methods = 20

# Maximum number of return / yield for function / method body.
max-returns = 13
max-returns = 15

# Maximum number of statements in function / method body.
max-statements = 100
Expand All @@ -295,10 +295,10 @@ indent-after-paren = 4
indent-string = " "

# Maximum number of characters on a single line.
max-line-length = 150
max-line-length = 200

# Maximum number of lines in a module.
max-module-lines = 1500
max-module-lines = 2000

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
Expand Down Expand Up @@ -373,6 +373,7 @@ disable = [
"invalid-name",
"invalid-unary-operand-type",
"locally-disabled",
"missing-function-docstring",
"missing-module-docstring",
"no-member",
"protected-access",
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Breaking changes
Breaking changes
^^^^^^^^^^^^^^^^
* `platformdirs` is no longer a direct dependency of `xclim`, but `pooch` is required to use many of the new testing functions (installable via `pip install pooch` or `pip install 'xclim[dev]'`). (:pull:`1889`).
* The following previously-deprecated functions have now been removed from `xclim`: ``xclim.core.calendar.convert_calendar``, ``xclim.core.calendar.date_range``, ``xclim.core.calendar.date_range_like``, ``xclim.core.calendar.interp_calendar``, ``xclim.core.calendar.days_in_year``, ``xclim.core.calendar.datetime_to_decimal_year``. For guidance on how to migrate to alternatives, see the `version 0.50.0 Breaking changes <#v0-50-0-2024-06-17>`_. (:issue:`1010`, :pull:`1845`).

Internal changes
^^^^^^^^^^^^^^^^
Expand All @@ -28,6 +29,9 @@ Internal changes
* ``xclim.testing.utils.nimbus`` replaces much of this functionality. See the `xclim` documentation for more information.
* Many tests focused on evaluating the normal operation of remote file access tools under ``xclim.testing`` have been removed. (:pull:`1889`).
* Setup and teardown functions that were found under ``tests/conftest.py`` have been optimized to reduce redundant calls when running ``pytest xclim``. Some obsolete `pytest` fixtures have also been removed.(:pull:`1889`).
* Many ``DeprecationWarning`` and ``FutureWarning`` messages emitted from `xarray` and `pint` have been addressed. (:issue:`1719`, :pull:`1881`).
* The codebase has been adjusted to address many `pylint`-related warnings and errors. In some cases, `casting` was used to redefine some `numpy` and `xarray` objects. (:issue:`1719`, :pull:`1881`).
* ``xclim.core`` now uses absolute imports for clarity and some objects commonly used in the module have been moved to hidden submodules. (:issue:`1719`, :pull:`1881`).

v0.52.0 (2024-08-08)
--------------------
Expand Down
2 changes: 1 addition & 1 deletion CI/requirements_ci.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ coveralls==4.0.1
deptry==0.20.0
flit==3.9.0
pip==24.2
pylint==3.2.6
pylint==3.2.7
tox==4.18.0
tox-gh==1.3.2
38 changes: 19 additions & 19 deletions CI/requirements_ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ bracex==2.4 \
--hash=sha256:a27eaf1df42cf561fed58b7a8f3fdf129d1ea16a81e1fadd1d17989bc6384beb \
--hash=sha256:efdc71eff95eaff5e0f8cfebe7d01adf2c8637c8c92edaf63ef348c241a82418
# via wcmatch
bump-my-version==0.25.3 \
--hash=sha256:43638a60adee76d6d7112b7ab7403f0115a4db96d8e6276d935fcbed853673aa \
--hash=sha256:9a3752cccf5a4235d2e23705e09ba322f38b20ec162089b6af523049005c5245
bump-my-version==0.26.0 \
--hash=sha256:9e2c01b7639960379440c4a371b3c8c0aa66cf6979985f1c9ba2e7c2fb4a185f \
--hash=sha256:fe35ebae91e92deebe809ce06bfa37303e45e4f087ad4a371f605702e767623f
# via -r CI/requirements_ci.in
cachetools==5.4.0 \
--hash=sha256:3ae3b49a3d5e28a77a0be2b37dbcb89005058959cb2323858c2657c4a8cab474 \
Expand Down Expand Up @@ -193,19 +193,19 @@ coveralls==4.0.1 \
--hash=sha256:7a6b1fa9848332c7b2221afb20f3df90272ac0167060f41b5fe90429b30b1809 \
--hash=sha256:7b2a0a2bcef94f295e3cf28dcc55ca40b71c77d1c2446b538e85f0f7bc21aa69
# via -r CI/requirements_ci.in
deptry==0.19.1 \
--hash=sha256:023073247e5dac21254bf7b600ca2e2b71560652d2dfbe11535445ee912ca059 \
--hash=sha256:0bad85a77b31360d0f52383b14783fdae4a201b597c0158fe10e91a779c67079 \
--hash=sha256:1c12fea1d2301f42c7035c5636e4b9421457fde256fe7a241245662d20b4c841 \
--hash=sha256:2c6b2df353e5113fd2f787c2f7e694657548d388929e988e8644bd178e19fc5c \
--hash=sha256:3a20ef0dd1c737fb05553d1b9c2fa9f185d0c9d3d881d255334cef401ffdc599 \
--hash=sha256:43f33789b97b47313609e92b62fabf8a71bba0d35a7476806da5d3d152e32345 \
--hash=sha256:7344c6cea032b549d86e156aa1e679fb94cd44deb7e93f25cb6d9c0ded5ea06f \
--hash=sha256:a1abc119f9c8536b8ab1ee2122d4130665f33225d00d8615256ce354eb2c11ba \
--hash=sha256:a407bab3486e3844f93d702f1a381942873b2a46056c693b5634bbde219bb056 \
--hash=sha256:af8a0a9c42f8f92dfbc048e724fa89b9131f032f7e245812260560c214395abf \
--hash=sha256:c59142d9dca8873325692fbb7aa1d2902fde87020dcc8102f75120ba95515172 \
--hash=sha256:ff7d8954265c48ea334fdd508339c51d3fba05e2d4a8be47712c69d1c8d35c94
deptry==0.20.0 \
--hash=sha256:012fb106dbea6ca95196cdcd75ac90c516c8f01292f7934f2e802a7cf025a660 \
--hash=sha256:0c90ce64e637d0e902bc97c5a020adecfee9e9f09ee0bf4c61554994139bebdb \
--hash=sha256:41434d95124851b83cb05524d1a09ad6fea62006beafed2ef90a6b501c1b237f \
--hash=sha256:62e9aaf3aea9e2ca66c85da98a0ba0290b4d3daea4e1d0ad937d447bd3c36402 \
--hash=sha256:6886ff44aaf26fd83093f14f844ebc84589d90df9bbad9a1625e8a080e6f1be2 \
--hash=sha256:8ce3920e2bd6d2b4427ab31ab8efb94bbef897001c2d395782bc30002966d12d \
--hash=sha256:9f92e7e97ef42477717747b190bc6796ab94b35655af126d8c577f7eae0eb3a9 \
--hash=sha256:ace3b39b1d0763f357c79bab003d1b135bea2eb61102be539992621a42d1ac7b \
--hash=sha256:b3b4b22d1406147de5d606a24042126cd74d52fdfdb0232b9c5fd0270d601610 \
--hash=sha256:d1a00f8c9e6c0829a4a523edd5e526e3df06d2b50e0a99446f09f9723df2efad \
--hash=sha256:e233859f150df70ffff76e95f9b7326fc25494b9beb26e776edae20f0f515e7d \
--hash=sha256:f6cee6005997791bb77155667be055333fb63ae9a24f0f103f25faf1e7affe34
# via -r CI/requirements_ci.in
dill==0.3.8 \
--hash=sha256:3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca \
Expand Down Expand Up @@ -382,9 +382,9 @@ pygments==2.18.0 \
--hash=sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199 \
--hash=sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a
# via rich
pylint==3.2.6 \
--hash=sha256:03c8e3baa1d9fb995b12c1dbe00aa6c4bcef210c2a2634374aedeb22fb4a8f8f \
--hash=sha256:a5d01678349454806cff6d886fb072294f56a58c4761278c97fb557d708e1eb3
pylint==3.2.7 \
--hash=sha256:02f4aedeac91be69fb3b4bea997ce580a4ac68ce58b89eaefeaf06749df73f4b \
--hash=sha256:1b7a721b575eaeaa7d39db076b6e7743c993ea44f57979127c517c6c572c803e
# via -r CI/requirements_ci.in
pyproject-api==1.7.1 \
--hash=sha256:2dc1654062c2b27733d8fd4cdda672b22fe8741ef1dde8e3a998a9547b071eeb \
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
xarray.CFTimeIndex.__module__ = "xarray"

import xclim # noqa
from xclim import indicators as _indicators # noqa
from xclim.core.indicator import registry # noqa

# If extensions (or modules to document with autodoc) are in another
Expand All @@ -45,7 +46,7 @@
indicators = {}
# FIXME: Include cf module when its indicators documentation is improved.
for module in ("atmos", "generic", "land", "seaIce", "icclim", "anuclim"):
for key, ind in getattr(xclim.indicators, module).__dict__.items():
for key, ind in getattr(_indicators, module).__dict__.items():
if hasattr(ind, "_registry_id") and ind._registry_id in registry: # noqa
indicators[ind._registry_id] = { # noqa
"realm": ind.realm,
Expand Down
1 change: 1 addition & 0 deletions docs/notebooks/analogs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"\n",
"\n",
"def plot_best_analog(scores, ax=None):\n",
" \"\"\"Plot the best analog on the map.\"\"\"\n",
" scores1d = scores.stack(site=[\"lon\", \"lat\"])\n",
" lon, lat = scores1d.isel(site=scores1d.argmin(\"site\")).site.item()\n",
" ax = ax or plt.gca()\n",
Expand Down
3 changes: 0 additions & 3 deletions docs/notebooks/benchmarks/sdba_quantile.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"\n",
"import numpy as np\n",
"\n",
"import xclim\n",
"from xclim import sdba\n",
"from xclim.testing import open_dataset\n",
"\n",
Expand Down Expand Up @@ -90,8 +89,6 @@
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"\n",
Expand Down
2 changes: 2 additions & 0 deletions docs/notebooks/customize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@
" \"\"\"Any period with more than max_n consecutive missing values is considered invalid\"\"\"\n",
"\n",
" def is_missing(self, null, count, max_n=5):\n",
" \"\"\"Return a boolean mask where True values are for elements that are considered missing and masked on the output.\"\"\"\n",
" return null.map(longest_run, dim=\"time\") >= max_n\n",
"\n",
" @staticmethod\n",
" def validate(max_n):\n",
" \"\"\"Return whether the options are valid.\"\"\"\n",
" return max_n > 0"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/ensembles-advanced.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
"metadata": {},
"outputs": [],
"source": [
"## NESTED results using KKZ\n",
"# NESTED results using KKZ\n",
"for n in np.arange(5, 15, 3):\n",
" ids = ensembles.kkz_reduce_ensemble(crit, num_select=n)\n",
" print(ids)"
Expand All @@ -313,7 +313,7 @@
},
"outputs": [],
"source": [
"## UNNESTED results using k-means\n",
"# UNNESTED results using k-means\n",
"for n in np.arange(5, 15, 3):\n",
" ids, cluster, fig_data = ensembles.kmeans_reduce_ensemble(\n",
" crit, method={\"n_clusters\": n}, random_state=42, make_graph=True\n",
Expand Down
9 changes: 4 additions & 5 deletions docs/notebooks/ensembles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,15 @@
},
"outputs": [],
"source": [
"import xarray as xr\n",
"\n",
"# Set display to HTML style (for fancy output)\n",
"xr.set_options(display_style=\"html\", display_width=50)\n",
"\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"\n",
"from xclim import ensembles\n",
"\n",
"# Set display to HTML style (for fancy output)\n",
"xr.set_options(display_style=\"html\", display_width=50)\n",
"\n",
"%matplotlib inline\n",
"\n",
"ens = ensembles.create_ensemble(data_folder.glob(\"ens_tas_m*.nc\")).load()\n",
Expand Down
Loading

0 comments on commit e313e52

Please sign in to comment.