Skip to content

Commit

Permalink
Merge branch 'master' into opt-dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre authored Jan 26, 2024
2 parents 04e89e8 + e1917e2 commit f4e6fca
Show file tree
Hide file tree
Showing 64 changed files with 163 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ jobs:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
dap.service.does.not.exist:443
files.pythonhosted.org:443
github.com:443
pypi.org:443
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ repos:
- id: yamllint
args: [ '--config-file=.yamllint.yaml' ]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.1.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.1.13
rev: v0.1.14
hooks:
- id: ruff
- repo: https://github.com/pylint-dev/pylint
Expand All @@ -61,7 +61,7 @@ repos:
- id: nbqa-pyupgrade
args: [ '--py38-plus' ]
- id: nbqa-black
additional_dependencies: [ 'black==23.12.1' ]
additional_dependencies: [ 'black==24.1.0' ]
- id: nbqa-isort
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
Expand All @@ -73,7 +73,7 @@ repos:
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [ 'black==23.12.1' ]
additional_dependencies: [ 'black==24.1.0' ]
exclude: '(xclim/indices/__init__.py|docs/installation.rst)'
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.1
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Announcements
* `xclim` now officially supports Python3.12 (requires `numba>=0.59.0`). (:pull:`1613`).
* `xclim` now adheres to the `Semantic Versioning 2.0.0 <https://semver.org/>`_ specification. (:issue:`1556`, :pull:`1569`).
* The `xclim` repository now uses `GitHub Discussions <https://github.com/Ouranosinc/xclim/discussions>`_ to offer help for users, coordinate translation efforts, and support general Q&A for the `xclim` community. The `xclim` `Gitter` room has been deprecated in favour of GitHub Discussions. (:issue:`1571`, :pull:`1572`).
* For secure correspondence, `xclim` now offers a PGP key for users to encrypt sensitive communications. For more information, see the ``SECURITY.md``. (:issue:`1181`, :pull:`1604`).

New features and enhancements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -26,6 +27,7 @@ Breaking changes
* `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`).
* `black` formatting style has been updated to the 2024 stable conventions. `isort` has been added to the `dev` installation recipe. (:pull:`1626`).

Bug fixes
^^^^^^^^^
Expand All @@ -48,6 +50,7 @@ Internal changes
* A new GitHub Workflow (``workflow-warning.yml``) has been added to warn maintainers when a forked repository has been used to open a Pull Request that modifies GitHub Workflows.
* `pylint` has been configured to provide some overhead checks of the `xclim` codebase as well as run as part of `xclim`'s `pre-commit` hooks.
* Some small adjustments to code organization to address `pylint` errors.
* `dev` formatting tools (`black`, `blackdoc`, `isort`) are now pinned to their `pre-commit` hook version equivalents in both `pyproject.toml` and `tox.ini`. (:pull:`1626`).

v0.47.0 (2023-12-01)
--------------------
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
[github-[email protected]](mailto:[email protected]).
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
38 changes: 38 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Security Policy

## Supported Versions

`xclim` is in rapid development and receives regular updates every four to six (4-6) weeks. In the event of a security-related bug discovery soon after the release of an `xclim` version, the last supported version will receive a patch release.

## Reporting a Vulnerability

If you believe you have found a security vulnerability in `xclim`, we encourage you to let us know right away. We take all security vulnerabilities seriously and appreciate your efforts to responsibly disclose them.

Please follow these steps to report a security vulnerability:

1. **Email**: Email [[email protected]](mailto:[email protected]) with a detailed description of the vulnerability. If applicable, please include any steps or a proof-of-concept to help us understand and reproduce the issue.

2. **Encryption (Optional)**: If you are concerned about the sensitivity of the information you are sharing, you can use the PGP key found below to encrypt your communication.

3. **Response**: We will acknowledge your email within 48 hours and work with you to understand and confirm the vulnerability.

4. **Fix and Disclosure**: Once the vulnerability is confirmed, we will work to address it promptly. We appreciate your patience as we investigate and implement a fix. Once resolved, we will coordinate the disclosure and provide credit to the reporter unless they prefer to remain anonymous.

## PGP Encryption Key

You can use the following PGP key to encrypt your communications with us:

-----BEGIN PGP PUBLIC KEY BLOCK-----

mDMEZamQrhYJKwYBBAHaRw8BAQdA+saPvmvr1MYe1nQy3n3QDcRE9T7UzTJ1XH31
EI4Zb6u0Mk91cmFub3MgR2l0SHViIFN1cHBvcnQgPGdpdGh1Yi1zdXBwb3J0QG91
cmFub3MuY2E+iJkEExYKAEEWIQSeAu+Cbjupx79jy9VeVFD6o5TVcwUCZamQrgIb
AwUJCWYBgAULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgAAKCRBeVFD6o5TVc4ho
AQDXjDkx0b3A7yl6PQ4hBJ2uYzw0UWbml7mUwVdhMmdZkQD/VJZQNWrCQeOtYEM8
icZJYwR/OsKFOWqlDytusGGtjwa4OARlqZCuEgorBgEEAZdVAQUBAQdAa41Zabjz
P9O+p6tI69Cnft6U5om3+qCcMo8amTqauH0DAQgHiH4EGBYKACYWIQSeAu+Cbjup
x79jy9VeVFD6o5TVcwUCZamQrgIbDAUJCWYBgAAKCRBeVFD6o5TVcwmaAQClDxW6
2gir7lhRXAcO+vmRImpGd29TrkcQVh+ak7VlwQEA706d7Kusiorlf/h8pLSoNMmS
kuLGmHpUJ8NVGppU+wo=
=wuxr
-----END PGP PUBLIC KEY BLOCK-----
1 change: 1 addition & 0 deletions docs/autodoc_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Based on https://github.com/powerline/powerline/blob/83d855d3d73498c47553afeba212415990d95c54/docs/source/powerline_autodoc.py
"""

from __future__ import annotations

from sphinx.domains.python import PyFunction, PyXRefRole
Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"sphinx_autodoc_typehints",
"sphinx_codeautolink",
"sphinx_copybutton",
"sphinx_mdinclude",
"sphinx_rtd_theme",
]

Expand Down Expand Up @@ -248,7 +249,7 @@ class XCStyle(AlphaStyle):
# the built documents.
#
# The short X.Y version.
version = xclim.__version__
version = xclim.__version__.split("-")[0]
# The full version, including alpha/beta/rc tags.
release = xclim.__version__

Expand All @@ -267,6 +268,7 @@ class XCStyle(AlphaStyle):
"Thumbs.db",
".DS_Store",
"notebooks/xclim_training",
"paper/paper.md",
"**.ipynb_checkpoints",
]

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Leveraging xarray and dask, users can easily bias-adjust climate simulations ove

authors
changes
security
references

.. toctree::
Expand Down
1 change: 1 addition & 0 deletions docs/security.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. mdinclude:: ../SECURITY.md
11 changes: 7 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ dependencies:
# Extras
- flox
# Testing and development dependencies
- black >=22.12
- blackdoc
- bump-my-version
- black ==24.1.0
- blackdoc ==0.3.9
# - bump-my-version # The conda package is not as up-to-date as the PyPI package.
- cairosvg
- codespell
- coverage
Expand All @@ -43,6 +43,7 @@ dependencies:
- h5netcdf
- ipykernel
- ipython
- isort ==5.13.2
- matplotlib
- mypy
- nbqa
Expand All @@ -65,14 +66,16 @@ dependencies:
- sphinx-autodoc-typehints
- sphinx-codeautolink
- sphinx-copybutton
- sphinx-mdinclude
- sphinx-rtd-theme >=1.0
- sphinxcontrib-bibtex
- tokenize-rt
- tox
- tox >=4.0
# - tox-conda # Will be added when a [email protected]+ compatible plugin is released.
- xdoctest
- yamllint
- pip
- pip:
- bump-my-version >=0.17.1 # The conda package is not as up-to-date as the PyPI package.
- flake8-alphabetize
- sphinxcontrib-svg2pdfconverter
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ dependencies = [
[project.optional-dependencies]
dev = [
# Dev tools and testing
"black >=23.3.0",
"blackdoc",
"bump-my-version",
"black ==24.1.0",
"blackdoc ==0.3.9",
"bump-my-version >=0.17.1",
"codespell",
"coverage[toml]",
"flake8",
"flake8-alphabetize",
"flake8-rst-docstrings",
"h5netcdf",
"ipython",
"isort ==5.13.2",
"mypy",
"nbqa",
"nbval",
Expand All @@ -83,7 +84,7 @@ dev = [
"pytest-xdist[psutil] >=3.2",
"ruff >=0.1.0",
"tokenize-rt",
"tox",
"tox >=4.0",
# "tox-conda", # Will be added when a [email protected]+ compatible plugin is released.
"xdoctest",
"yamllint",
Expand All @@ -98,6 +99,7 @@ dev = [
"sphinx-autodoc-typehints",
"sphinx-codeautolink",
"sphinx-copybutton",
"sphinx-mdinclude",
"sphinx-rtd-theme >=1.0",
"sphinxcontrib-bibtex",
"sphinxcontrib-svg2pdfconverter[Cairosvg]"
Expand All @@ -124,7 +126,7 @@ target-version = [
]

[tool.bumpversion]
current_version = "0.47.5-dev.9"
current_version = "0.47.5-dev.11"
commit = true
commit_args = "--no-verify"
tag = false
Expand Down
1 change: 1 addition & 0 deletions tests/test_generic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for generic indices."""

from __future__ import annotations

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/test_land.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for indicators in `land` realm."""

from __future__ import annotations

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for statistical indices."""

from __future__ import annotations

import numpy as np
Expand Down
11 changes: 7 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ description = Run code quality compliance tests under {basepython}
skip_install = True
extras =
deps =
codespell
flake8
flake8-alphabetize
flake8-rst-docstrings
black[jupyter]
blackdoc
isort
black[jupyter]==24.1.0
blackdoc==0.3.9
isort==5.13.2
nbqa
ruff
ruff>=0.1.0
yamllint
commands_pre =
commands =
Expand All @@ -38,6 +40,7 @@ commands =
nbqa black --check docs
blackdoc --check --exclude=xclim/indices/__init__.py xclim
blackdoc --check docs
codespell xclim tests docs
yamllint --config-file=.yamllint.yaml xclim
commands_post =

Expand Down
3 changes: 2 additions & 1 deletion xclim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Climate indices computation package based on Xarray."""

from __future__ import annotations

try:
Expand All @@ -15,7 +16,7 @@

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


_module_data = _files("xclim.data")
Expand Down
1 change: 1 addition & 0 deletions xclim/analog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Spatial Analogues module."""

# TODO: Hellinger distance
# TODO: Mahalanobis distance
# TODO: Comment on "significance" of results.
Expand Down
1 change: 1 addition & 0 deletions xclim/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Command Line Interface module
=============================
"""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions xclim/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Core module."""

from __future__ import annotations

from . import missing
1 change: 1 addition & 0 deletions xclim/core/bootstrapping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module comprising the bootstrapping algorithm for indicators."""

from __future__ import annotations

import warnings
Expand Down
23 changes: 14 additions & 9 deletions xclim/core/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Helper function to handle dates, times and different calendars with xarray.
"""

from __future__ import annotations

import datetime as pydt
Expand Down Expand Up @@ -1013,12 +1014,14 @@ def resample_doy(doy: xr.DataArray, arr: xr.DataArray | xr.Dataset) -> xr.DataAr


def time_bnds( # noqa: C901
time: xr.DataArray
| xr.Dataset
| CFTimeIndex
| pd.DatetimeIndex
| DataArrayResample
| DatasetResample,
time: (
xr.DataArray
| xr.Dataset
| CFTimeIndex
| pd.DatetimeIndex
| DataArrayResample
| DatasetResample
),
freq: str | None = None,
precision: str | None = None,
):
Expand Down Expand Up @@ -1768,9 +1771,11 @@ def stack_periods(
periods.append(
slice(
strd_slc.start + win_slc.start,
(strd_slc.start + win_slc.stop)
if win_slc.stop is not None
else da.time.size,
(
(strd_slc.start + win_slc.stop)
if win_slc.stop is not None
else da.time.size
),
)
)

Expand Down
1 change: 1 addition & 0 deletions xclim/core/cfchecks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Utilities designed to verify the compliance of metadata with the CF-Convention.
"""

from __future__ import annotations

import fnmatch
Expand Down
1 change: 1 addition & 0 deletions xclim/core/datachecks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Utilities designed to check the validity of data inputs.
"""

from __future__ import annotations

from typing import Sequence
Expand Down
Loading

0 comments on commit f4e6fca

Please sign in to comment.