Skip to content

Commit

Permalink
Fix CI - Failing due to missing hdf5 and netcdf headers (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger authored Apr 30, 2024
1 parent b11f6b2 commit 0b93f24
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 697 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
python -m pip install --upgrade pip
python -m pip install build
- name: Install hdf5 and netcdf (macOS)
if: runner.os == 'macOS'
run: brew install hdf5 netcdf

- name: Check git status (not Windows)
if: runner.os != 'Windows'
run: |
Expand Down
26 changes: 8 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.4.2
hooks:
- id: ruff
args:
- --preview
- --fix
- --exit-non-zero-on-fix
args: [--fix]
- id: ruff-format
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ["--select=E9,F63,F7,F82", "--show-source", "--statistics"]
- repo: https://github.com/pycqa/pylint
rev: v3.0.3
hooks:
- id: pylint
name: pylint
types: [python]
exclude: ^examples/|^tests/|^setup.py$
args: ["--rcfile=pyproject.toml"]
# - repo: https://github.com/pre-commit/mirrors-mypy # FIXME
# rev: v1.8.0
# hooks:
Expand Down Expand Up @@ -67,16 +57,16 @@ repos:
# - id: rst-inline-touching-normal
- id: rst-directive-colons
- id: text-unicode-replacement-char
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
# - repo: https://github.com/psf/black
# rev: 24.2.0
# hooks:
# - id: black
# - repo: https://github.com/adamchainz/blacken-docs
# rev: 1.16.0
# hooks:
# - id: blacken-docs
# additional_dependencies: [black==23.12.0]
- repo: https://github.com/PyCQA/isort
- repo: https://github.com/PyCQA/isort # TODO: remove as soon as ruff is stable
rev: 5.13.2
hooks:
- id: isort
Expand Down
46 changes: 43 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,60 @@

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

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

**Merged pull requests:**

- Fix typos and update pre-commit hooks [\#64](https://github.com/btschwertfeger/python-cmethods/pull/64) ([btschwertfeger](https://github.com/btschwertfeger))
- 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))
- 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))
- 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))

## [v2.2.1](https://github.com/btschwertfeger/python-cmethods/tree/v2.2.1) (2024-04-10)

[Full Changelog](https://github.com/btschwertfeger/python-cmethods/compare/v2.2.0...v2.2.1)

**Merged pull requests:**

- Fix missing function documentation [\#85](https://github.com/btschwertfeger/python-cmethods/pull/85) ([btschwertfeger](https://github.com/btschwertfeger))

## [v2.2.0](https://github.com/btschwertfeger/python-cmethods/tree/v2.2.0) (2024-04-09)

[Full Changelog](https://github.com/btschwertfeger/python-cmethods/compare/v2.1.0...v2.2.0)

**Implemented enhancements:**

- Add a command-line interface [\#82](https://github.com/btschwertfeger/python-cmethods/issues/82)
- Resolve "Add a command-line interface" [\#83](https://github.com/btschwertfeger/python-cmethods/pull/83) ([btschwertfeger](https://github.com/btschwertfeger))

**Merged pull requests:**

- 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))
- 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))
- Adjust GitHub Action permissions [\#75](https://github.com/btschwertfeger/python-cmethods/pull/75) ([btschwertfeger](https://github.com/btschwertfeger))
- 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))
- 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))
- 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))
- Update the documentation + project maintenance [\#70](https://github.com/btschwertfeger/python-cmethods/pull/70) ([btschwertfeger](https://github.com/btschwertfeger))
- Add `scorecard.yml` workflow [\#69](https://github.com/btschwertfeger/python-cmethods/pull/69) ([btschwertfeger](https://github.com/btschwertfeger))

## [v2.1.0](https://github.com/btschwertfeger/python-cmethods/tree/v2.1.0) (2024-03-10)

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

**Implemented enhancements:**

- 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)
- 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))

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

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

**Merged pull requests:**

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

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

Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ VENV := venv
PYTHON := $(VENV)/bin/python3
TESTS := tests
PYTEST_OPTS := -vv
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

.PHONY: help
help:
Expand Down Expand Up @@ -75,13 +76,14 @@ ruff:
.PHONY: ruff-fix
ruff-fix:
ruff check --fix --preview .
ruff format .

## changelog Create the changelog
##
.PHONY: changelog
changelog:
docker run -it --rm \
-v "$(PWD)":/usr/local/src/your-app/ \
-v $(ROOT_DIR):/usr/local/src/your-app/ \
githubchangeloggenerator/github-changelog-generator \
-u btschwertfeger \
-p python-cmethods \
Expand All @@ -104,6 +106,3 @@ clean:
find tests -name "__pycache__" | xargs rm -rf
find cmethods -name "__pycache__" | xargs rm -rf
find examples -name "__pycache__" | xargs rm -rf

# for file in `ls .github/workflows`; do sed -i '' 's/actions\/checkout@v4/actions\/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0/g' .github/workflows/$file; done
# 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ https://python-cmethods.readthedocs.io/en/stable/

## 3. Installation

> For optimal compatibility on macOS, ensure that 'hdf5' and 'netcdf' are
> pre-installed using Homebrew (`brew install hdf5 netcdf`).
```bash
python3 -m pip install python-cmethods
```
Expand Down
38 changes: 18 additions & 20 deletions cmethods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
# pylint: disable=consider-using-f-string,logging-not-lazy

r"""
Module providing the a method named "adjust" to apply different bias
correction techniques to time-series climate data.
Some variables used in this package:
T = Temperatures ($T$)
X = Some climate variable ($X$)
h = historical
p = scenario; future; predicted
obs = observed data ($T_{obs,h}$)
simh = modeled data with same time period as obs ($T_{sim,h}$)
simp = data to correct (predicted simulated data) ($T_{sim,p}$)
F = Cumulative Distribution Function
\mu = mean
\sigma = standard deviation
i = index
_{m} = long-term monthly interval
Module providing the a method named "adjust" to apply different bias
correction techniques to time-series climate data.
Some variables used in this package:
T = Temperatures ($T$)
X = Some climate variable ($X$)
h = historical
p = scenario; future; predicted
obs = observed data ($T_{obs,h}$)
simh = modeled data with same time period as obs ($T_{sim,h}$)
simp = data to correct (predicted simulated data) ($T_{sim,p}$)
F = Cumulative Distribution Function
\mu = mean
\sigma = standard deviation
i = index
_{m} = long-term monthly interval
"""

from __future__ import annotations
Expand Down Expand Up @@ -128,9 +128,7 @@
help="Temporal grouping",
),
constraint=If(
Equal("method", "linear_scaling")
& Equal("method", "variance_scaling")
& Equal("method", "delta_method"),
Equal("method", "linear_scaling") & Equal("method", "variance_scaling") & Equal("method", "delta_method"),
then=require_all,
),
)
Expand Down
7 changes: 2 additions & 5 deletions cmethods/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def apply_ufunc(
not isinstance(value, str) for value in kwargs["input_core_dims"].values()
):
raise ValueError(
"input_core_dims must have three key-value pairs like: "
'{"obs": "time", "simh": "time", "simp": "time"}',
'input_core_dims must have three key-value pairs like: {"obs": "time", "simh": "time", "simp": "time"}',
)

input_core_dims = kwargs["input_core_dims"]
Expand Down Expand Up @@ -187,9 +186,7 @@ def adjust(
**kwargs,
)

result = (
monthly_result if result is None else xr.merge([result, monthly_result])
)
result = monthly_result if result is None else xr.merge([result, monthly_result])

return result

Expand Down
4 changes: 1 addition & 3 deletions cmethods/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ def detrended_quantile_mapping(
xbins,
cdf_simh,
) # Eq. 1
X = (
get_inverse_of_cdf(cdf_obs, epsilon, xbins) + m_simp_mean - m_simh_mean
) # Eq. 1
X = get_inverse_of_cdf(cdf_obs, epsilon, xbins) + m_simp_mean - m_simh_mean # Eq. 1

else: # kind in cls.MULTIPLICATIVE:
epsilon = np.interp( # Eq. 2
Expand Down
6 changes: 2 additions & 4 deletions cmethods/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self: UnknownMethodError, method: str, available_methods: list):

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

if not isinstance(obs, XRData_t):
raise TypeError(f"'obs' {phrase}")
Expand Down
3 changes: 3 additions & 0 deletions doc/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Getting Started
Installation
------------

(For optimal compatibility on macOS, ensure that 'hdf5' and 'netcdf' are
pre-installed using Homebrew (``brew install hdf5 netcdf``).)

The `python-cmethods`_ module can be installed using the package manager pip:

.. code-block:: bash
Expand Down
Loading

0 comments on commit 0b93f24

Please sign in to comment.