Skip to content

Commit

Permalink
Merge branch 'main' into fix-1694
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal authored May 1, 2024
2 parents 8928bf0 + 9050a19 commit b203e2f
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 92 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 @@ -17,7 +17,7 @@ jobs:
repository-projects: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cache-cleaner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- 'python'
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/first-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/label-on-approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- "3.9"
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
python-version: "3.9"
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
os: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: block
allowed-endpoints: >
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
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 @@ -25,7 +25,7 @@ jobs:
environment: production
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testdata-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow-warning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ New indicators
Breaking changes
^^^^^^^^^^^^^^^^
* The previously deprecated functions ``xclim.sdba.processing.construct_moving_yearly_window`` and ``xclim.sdba.processing.unpack_moving_yearly_window`` have been removed. These functions have been replaced by ``xclim.core.calendar.stack_periods`` and ``xclim.core.calendar.unstack_periods``. (:pull:`1717`).
* The previously deprecated function ``xclim.ensembles.change_significance`` has been removed. (:pull:`1737`).
* Indicators ``snw_season_length`` and ``snd_season_length`` have been modified, see above.
* The `hargeaves85`/`hg85` method for the ``potential_evapotranspiration`` indicator and indice has been modified for precision and consistency with recent academic literature. (:issue:`1710`, :pull:`1723`).


Bug fixes
^^^^^^^^^
* Fixed an bug in sdba's ``map_groups`` that prevented passing DataArrays with cftime coordinates if the ``sdba_encode_cf`` option was True. (:issue:`1673`, :pull:`1674`).
Expand Down
3 changes: 0 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ Ensembles Module
.. autofunction:: xclim.ensembles.robustness_categories
:noindex:

.. autofunction:: xclim.ensembles.change_significance
:noindex:

.. autofunction:: xclim.ensembles.robustness_coefficient
:noindex:

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ target-version = [
]

[tool.bumpversion]
current_version = "0.48.3-dev.13"
current_version = "0.48.3-dev.14"
commit = true
commit_args = "--no-verify"
tag = false
Expand Down
2 changes: 1 addition & 1 deletion xclim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

__author__ = """Travis Logan"""
__email__ = "[email protected]"
__version__ = "0.48.3-dev.13"
__version__ = "0.48.3-dev.14"


_module_data = _files("xclim.data")
Expand Down
1 change: 0 additions & 1 deletion xclim/ensembles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
plot_rsqprofile,
)
from ._robustness import (
change_significance,
robustness_categories,
robustness_coefficient,
robustness_fractions,
Expand Down
69 changes: 3 additions & 66 deletions xclim/ensembles/_robustness.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from __future__ import annotations

import warnings
from inspect import Parameter, signature

import numpy as np
Expand All @@ -20,7 +19,6 @@
from xclim.indices.generic import compare, detrend

__all__ = [
"change_significance",
"robustness_categories",
"robustness_coefficient",
"robustness_fractions",
Expand All @@ -33,7 +31,7 @@
New tests must be decorated with :py:func:`significance_test` and fulfill the following requirements:
- Function name should begin by "_", registered test name is the function name without its first character and with _ replaced by -.
- Function must accept 2 positional arguments : fut and ref (see :py:func:`change_significance` for definitions)
- Function must accept 2 positional arguments : fut and ref (see :py:func:`robustness_fractions` for definitions)
- Function may accept other keyword-only arguments.
- Function must return 2 values :
+ `changed` : 1D boolean array along `realization`. True for realization with significant change.
Expand All @@ -42,7 +40,7 @@


def significance_test(func):
"""Register a significance test for use in :py:func:`change_significance`.
"""Register a significance test for use in :py:func:`robustness_fractions`.
See :py:data:`SIGNIFICANCE_TESTS`.
"""
Expand Down Expand Up @@ -294,67 +292,6 @@ def robustness_fractions( # noqa: C901
return out


def change_significance( # noqa: C901
fut: xr.DataArray | xr.Dataset,
ref: xr.DataArray | xr.Dataset,
test: str | None = "ttest",
weights: xr.DataArray | None = None,
p_vals: bool = False,
**kwargs,
) -> (
tuple[xr.DataArray | xr.Dataset, xr.DataArray | xr.Dataset]
| tuple[
xr.DataArray | xr.Dataset,
xr.DataArray | xr.Dataset,
xr.DataArray | xr.Dataset | None,
]
):
"""Backwards-compatible implementation of :py:func:`robustness_fractions`."""
warnings.warn(
(
"Function change_significance is deprecated as of xclim 0.47 and will be removed in 0.49. "
"Please use robustness_fractions instead."
),
FutureWarning,
)

if isinstance(fut, xr.Dataset):
outs = {
v: robustness_fractions(
fut[v],
ref[v] if isinstance(ref, xr.Dataset) else ref,
test=test,
weights=weights[v] if isinstance(weights, xr.Dataset) else weights,
**kwargs,
)
for v in fut.data_vars.keys()
}
change_frac = xr.merge([fracs.changed.rename(v) for v, fracs in outs.items()])
pos_frac = xr.merge(
[
(fracs.changed_positive / fracs.changed).rename(v)
for v, fracs in outs.items()
]
)
if p_vals:
if "pvals" in list(outs.values())[0]:
pvals = xr.merge([fracs.pvals.rename(v) for v, fracs in outs.items()])
else:
pvals = None
return change_frac, pos_frac, pvals
return change_frac, pos_frac

fracs = robustness_fractions(fut, ref, test=test, weights=weights, **kwargs)
# different def.
# Old "pos_frac" is fraction of change_frac that is positive
# New change_pos_frac is fraction of all that is both positive and significant
pos_frac = fracs.changed_positive / fracs.changed

if p_vals:
return fracs.changed, pos_frac, fracs.pvals if "pvals" in fracs else None
return fracs.changed, pos_frac


def robustness_categories(
changed_or_fractions: xr.Dataset | xr.DataArray,
agree: xr.DataArray | None = None,
Expand Down Expand Up @@ -667,7 +604,7 @@ def _ipcc_ar6_c(fut, ref, *, ref_pi=None):
return changed, None


# Add doc of each significance test to the `change_significance` output.
# Add doc of each significance test to `robustness_fractions` output's doc.
def _gen_test_entry(namefunc):
name, func = namefunc
doc = func.__doc__.replace("\n ", "\n\t\t").rstrip()
Expand Down

0 comments on commit b203e2f

Please sign in to comment.