Skip to content

Commit 0b93f24

Browse files
Fix CI - Failing due to missing hdf5 and netcdf headers (#92)
1 parent b11f6b2 commit 0b93f24

File tree

12 files changed

+92
-697
lines changed

12 files changed

+92
-697
lines changed

.github/workflows/_build.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
python -m pip install --upgrade pip
3838
python -m pip install build
3939
40+
- name: Install hdf5 and netcdf (macOS)
41+
if: runner.os == 'macOS'
42+
run: brew install hdf5 netcdf
43+
4044
- name: Check git status (not Windows)
4145
if: runner.os != 'Windows'
4246
run: |

.pre-commit-config.yaml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.3.5
3+
rev: v0.4.2
44
hooks:
55
- id: ruff
6-
args:
7-
- --preview
8-
- --fix
9-
- --exit-non-zero-on-fix
6+
args: [--fix]
7+
- id: ruff-format
108
- repo: https://github.com/pycqa/flake8
119
rev: 7.0.0
1210
hooks:
1311
- id: flake8
1412
args: ["--select=E9,F63,F7,F82", "--show-source", "--statistics"]
15-
- repo: https://github.com/pycqa/pylint
16-
rev: v3.0.3
17-
hooks:
18-
- id: pylint
19-
name: pylint
20-
types: [python]
21-
exclude: ^examples/|^tests/|^setup.py$
22-
args: ["--rcfile=pyproject.toml"]
2313
# - repo: https://github.com/pre-commit/mirrors-mypy # FIXME
2414
# rev: v1.8.0
2515
# hooks:
@@ -67,16 +57,16 @@ repos:
6757
# - id: rst-inline-touching-normal
6858
- id: rst-directive-colons
6959
- id: text-unicode-replacement-char
70-
- repo: https://github.com/psf/black
71-
rev: 24.2.0
72-
hooks:
73-
- id: black
60+
# - repo: https://github.com/psf/black
61+
# rev: 24.2.0
62+
# hooks:
63+
# - id: black
7464
# - repo: https://github.com/adamchainz/blacken-docs
7565
# rev: 1.16.0
7666
# hooks:
7767
# - id: blacken-docs
7868
# additional_dependencies: [black==23.12.0]
79-
- repo: https://github.com/PyCQA/isort
69+
- repo: https://github.com/PyCQA/isort # TODO: remove as soon as ruff is stable
8070
rev: 5.13.2
8171
hooks:
8272
- id: isort

CHANGELOG.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,60 @@
22

33
## [Unreleased](https://github.com/btschwertfeger/python-cmethods/tree/HEAD)
44

5-
[Full Changelog](https://github.com/btschwertfeger/python-cmethods/compare/v2.0.2...HEAD)
5+
[Full Changelog](https://github.com/btschwertfeger/python-cmethods/compare/v2.2.1...HEAD)
66

77
**Merged pull requests:**
88

9-
- Fix typos and update pre-commit hooks [\#64](https://github.com/btschwertfeger/python-cmethods/pull/64) ([btschwertfeger](https://github.com/btschwertfeger))
9+
- Bump actions/checkout from 4.1.2 to 4.1.4 [\#90](https://github.com/btschwertfeger/python-cmethods/pull/90) ([dependabot[bot]](https://github.com/apps/dependabot))
10+
- Bump actions/upload-artifact from 4.3.1 to 4.3.2 [\#89](https://github.com/btschwertfeger/python-cmethods/pull/89) ([dependabot[bot]](https://github.com/apps/dependabot))
11+
- Bump codecov/codecov-action from 4.2.0 to 4.3.0 [\#87](https://github.com/btschwertfeger/python-cmethods/pull/87) ([dependabot[bot]](https://github.com/apps/dependabot))
12+
13+
## [v2.2.1](https://github.com/btschwertfeger/python-cmethods/tree/v2.2.1) (2024-04-10)
14+
15+
[Full Changelog](https://github.com/btschwertfeger/python-cmethods/compare/v2.2.0...v2.2.1)
16+
17+
**Merged pull requests:**
18+
19+
- Fix missing function documentation [\#85](https://github.com/btschwertfeger/python-cmethods/pull/85) ([btschwertfeger](https://github.com/btschwertfeger))
20+
21+
## [v2.2.0](https://github.com/btschwertfeger/python-cmethods/tree/v2.2.0) (2024-04-09)
22+
23+
[Full Changelog](https://github.com/btschwertfeger/python-cmethods/compare/v2.1.0...v2.2.0)
24+
25+
**Implemented enhancements:**
26+
27+
- Add a command-line interface [\#82](https://github.com/btschwertfeger/python-cmethods/issues/82)
28+
- Resolve "Add a command-line interface" [\#83](https://github.com/btschwertfeger/python-cmethods/pull/83) ([btschwertfeger](https://github.com/btschwertfeger))
29+
30+
**Merged pull requests:**
31+
32+
- Bump codecov/codecov-action from 4.1.0 to 4.2.0 [\#80](https://github.com/btschwertfeger/python-cmethods/pull/80) ([dependabot[bot]](https://github.com/apps/dependabot))
33+
- Bump actions/setup-python from 5.0.0 to 5.1.0 [\#79](https://github.com/btschwertfeger/python-cmethods/pull/79) ([dependabot[bot]](https://github.com/apps/dependabot))
34+
- Adjust GitHub Action permissions [\#75](https://github.com/btschwertfeger/python-cmethods/pull/75) ([btschwertfeger](https://github.com/btschwertfeger))
35+
- Bump actions/upload-artifact from 3.1.0 to 4.3.1 [\#74](https://github.com/btschwertfeger/python-cmethods/pull/74) ([dependabot[bot]](https://github.com/apps/dependabot))
36+
- Bump actions/checkout from 3.1.0 to 4.1.2 [\#72](https://github.com/btschwertfeger/python-cmethods/pull/72) ([dependabot[bot]](https://github.com/apps/dependabot))
37+
- Bump ossf/scorecard-action from 2.1.2 to 2.3.1 [\#71](https://github.com/btschwertfeger/python-cmethods/pull/71) ([dependabot[bot]](https://github.com/apps/dependabot))
38+
- Update the documentation + project maintenance [\#70](https://github.com/btschwertfeger/python-cmethods/pull/70) ([btschwertfeger](https://github.com/btschwertfeger))
39+
- Add `scorecard.yml` workflow [\#69](https://github.com/btschwertfeger/python-cmethods/pull/69) ([btschwertfeger](https://github.com/btschwertfeger))
40+
41+
## [v2.1.0](https://github.com/btschwertfeger/python-cmethods/tree/v2.1.0) (2024-03-10)
42+
43+
[Full Changelog](https://github.com/btschwertfeger/python-cmethods/compare/v2.0.2...v2.1.0)
44+
45+
**Implemented enhancements:**
46+
47+
- Adjustments using `adjust` require the input data of the control period to have the same size for the time dimension [\#66](https://github.com/btschwertfeger/python-cmethods/issues/66)
48+
- Resolve "Adjustments using `adjust` require the input data of the control period to have the same size for the time dimension" [\#67](https://github.com/btschwertfeger/python-cmethods/pull/67) ([btschwertfeger](https://github.com/btschwertfeger))
1049

1150
## [v2.0.2](https://github.com/btschwertfeger/python-cmethods/tree/v2.0.2) (2024-02-02)
1251

1352
[Full Changelog](https://github.com/btschwertfeger/python-cmethods/compare/v2.0.1...v2.0.2)
1453

1554
**Merged pull requests:**
1655

17-
- Update documentation -- QM and QDM formulas [\#62](https://github.com/btschwertfeger/python-cmethods/pull/62) ([btschwertfeger](https://github.com/btschwertfeger))
1856
- Bump GitHub action versions [\#59](https://github.com/btschwertfeger/python-cmethods/pull/59) ([btschwertfeger](https://github.com/btschwertfeger))
57+
- Fix typos and update pre-commit hooks [\#64](https://github.com/btschwertfeger/python-cmethods/pull/64) ([btschwertfeger](https://github.com/btschwertfeger))
58+
- Update documentation -- QM and QDM formulas [\#62](https://github.com/btschwertfeger/python-cmethods/pull/62) ([btschwertfeger](https://github.com/btschwertfeger))
1959

2060
## [v2.0.1](https://github.com/btschwertfeger/python-cmethods/tree/v2.0.1) (2024-02-01)
2161

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ VENV := venv
88
PYTHON := $(VENV)/bin/python3
99
TESTS := tests
1010
PYTEST_OPTS := -vv
11+
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
1112

1213
.PHONY: help
1314
help:
@@ -75,13 +76,14 @@ ruff:
7576
.PHONY: ruff-fix
7677
ruff-fix:
7778
ruff check --fix --preview .
79+
ruff format .
7880

7981
## changelog Create the changelog
8082
##
8183
.PHONY: changelog
8284
changelog:
8385
docker run -it --rm \
84-
-v "$(PWD)":/usr/local/src/your-app/ \
86+
-v $(ROOT_DIR):/usr/local/src/your-app/ \
8587
githubchangeloggenerator/github-changelog-generator \
8688
-u btschwertfeger \
8789
-p python-cmethods \
@@ -104,6 +106,3 @@ clean:
104106
find tests -name "__pycache__" | xargs rm -rf
105107
find cmethods -name "__pycache__" | xargs rm -rf
106108
find examples -name "__pycache__" | xargs rm -rf
107-
108-
# for file in `ls .github/workflows`; do sed -i '' 's/actions\/checkout@v4/actions\/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0/g' .github/workflows/$file; done
109-
# for file in `ls .github/workflows`; do sed -i '' 's/actions\/setup-python@v5/actions\/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0/g' .github/workflows/$file; done

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ https://python-cmethods.readthedocs.io/en/stable/
137137

138138
## 3. Installation
139139

140+
> For optimal compatibility on macOS, ensure that 'hdf5' and 'netcdf' are
141+
> pre-installed using Homebrew (`brew install hdf5 netcdf`).
142+
140143
```bash
141144
python3 -m pip install python-cmethods
142145
```

cmethods/__init__.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
# pylint: disable=consider-using-f-string,logging-not-lazy
77

88
r"""
9-
Module providing the a method named "adjust" to apply different bias
10-
correction techniques to time-series climate data.
11-
12-
Some variables used in this package:
13-
14-
T = Temperatures ($T$)
15-
X = Some climate variable ($X$)
16-
h = historical
17-
p = scenario; future; predicted
18-
obs = observed data ($T_{obs,h}$)
19-
simh = modeled data with same time period as obs ($T_{sim,h}$)
20-
simp = data to correct (predicted simulated data) ($T_{sim,p}$)
21-
F = Cumulative Distribution Function
22-
\mu = mean
23-
\sigma = standard deviation
24-
i = index
25-
_{m} = long-term monthly interval
9+
Module providing the a method named "adjust" to apply different bias
10+
correction techniques to time-series climate data.
11+
12+
Some variables used in this package:
13+
14+
T = Temperatures ($T$)
15+
X = Some climate variable ($X$)
16+
h = historical
17+
p = scenario; future; predicted
18+
obs = observed data ($T_{obs,h}$)
19+
simh = modeled data with same time period as obs ($T_{sim,h}$)
20+
simp = data to correct (predicted simulated data) ($T_{sim,p}$)
21+
F = Cumulative Distribution Function
22+
\mu = mean
23+
\sigma = standard deviation
24+
i = index
25+
_{m} = long-term monthly interval
2626
"""
2727

2828
from __future__ import annotations
@@ -128,9 +128,7 @@
128128
help="Temporal grouping",
129129
),
130130
constraint=If(
131-
Equal("method", "linear_scaling")
132-
& Equal("method", "variance_scaling")
133-
& Equal("method", "delta_method"),
131+
Equal("method", "linear_scaling") & Equal("method", "variance_scaling") & Equal("method", "delta_method"),
134132
then=require_all,
135133
),
136134
)

cmethods/core.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def apply_ufunc(
5757
not isinstance(value, str) for value in kwargs["input_core_dims"].values()
5858
):
5959
raise ValueError(
60-
"input_core_dims must have three key-value pairs like: "
61-
'{"obs": "time", "simh": "time", "simp": "time"}',
60+
'input_core_dims must have three key-value pairs like: {"obs": "time", "simh": "time", "simp": "time"}',
6261
)
6362

6463
input_core_dims = kwargs["input_core_dims"]
@@ -187,9 +186,7 @@ def adjust(
187186
**kwargs,
188187
)
189188

190-
result = (
191-
monthly_result if result is None else xr.merge([result, monthly_result])
192-
)
189+
result = monthly_result if result is None else xr.merge([result, monthly_result])
193190

194191
return result
195192

cmethods/distribution.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ def detrended_quantile_mapping(
159159
xbins,
160160
cdf_simh,
161161
) # Eq. 1
162-
X = (
163-
get_inverse_of_cdf(cdf_obs, epsilon, xbins) + m_simp_mean - m_simh_mean
164-
) # Eq. 1
162+
X = get_inverse_of_cdf(cdf_obs, epsilon, xbins) + m_simp_mean - m_simh_mean # Eq. 1
165163

166164
else: # kind in cls.MULTIPLICATIVE:
167165
epsilon = np.interp( # Eq. 2

cmethods/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self: UnknownMethodError, method: str, available_methods: list):
3232

3333
def check_adjust_called(
3434
function_name: str,
35-
adjust_called: Optional[bool] = None, # noqa: FBT001
35+
adjust_called: Optional[bool] = None,
3636
) -> None:
3737
"""
3838
Displays a user warning in case a correction function was not called via
@@ -55,9 +55,7 @@ def check_xr_types(obs: XRData, simh: XRData, simp: XRData) -> None:
5555
"""
5656
Checks if the parameters are in the correct type. **only used internally**
5757
"""
58-
phrase: str = (
59-
"must be type xarray.core.dataarray.Dataset or xarray.core.dataarray.DataArray"
60-
)
58+
phrase: str = "must be type xarray.core.dataarray.Dataset or xarray.core.dataarray.DataArray"
6159

6260
if not isinstance(obs, XRData_t):
6361
raise TypeError(f"'obs' {phrase}")

doc/getting_started.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Getting Started
99
Installation
1010
------------
1111

12+
(For optimal compatibility on macOS, ensure that 'hdf5' and 'netcdf' are
13+
pre-installed using Homebrew (``brew install hdf5 netcdf``).)
14+
1215
The `python-cmethods`_ module can be installed using the package manager pip:
1316

1417
.. code-block:: bash

0 commit comments

Comments
 (0)