Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Mar 19, 2024
1 parent cc45566 commit 7170579
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions doc/source/dev/ci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ icclim continuous integration (CI) aims to assist development by:
These goals are reached using multiple tools:
- pre-commit CI enforces the code style rules. It is run on new pull requests
and may commit automatically to fix the source code.
If it fails to fix the code base, it woill block the PR from being merged.
If it fails to fix the code base, it woill block the PR from being merged.
The relevant configuration file is ``.pre-commit-config.yaml``.

- readthedocs, it serves our documentation on https://icclim.readthedocs.io/en/stable/.
It is configured with ``.readthedocs.yml`` and runs the generation of the
It is configured with ``.readthedocs.yml`` and runs the generation of the
documentation on each new pull request.

- github actions are used to run unit tests and report the results
Expand Down
1 change: 0 additions & 1 deletion doc/source/references/ecad_functions_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ For example to use this new API with the index `su` you can do:
import icclim
summer_days = icclim.su(in_files=glob.glob("netcdf_files/tasmax*.nc"))
1 change: 0 additions & 1 deletion doc/source/references/generic_functions_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ For more details on threshold and how to personalize them, see
:ref:`threshold` documentation. We also prepared a few examples on
:ref:`generic_indices_recipes` so that you get an idea of the
capabilities of these generic indices.

2 changes: 1 addition & 1 deletion doc/source/references/icclim_index_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on how to use `icclim.index`.

.. autofunction:: icclim.index(**kwargs)
:noindex:

.. note::

For the variable names see the :ref:`correspondence table "index -
Expand Down
2 changes: 1 addition & 1 deletion doc/source/tutorials/notebooks/.jukit/.jukit_info.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"import_complete": 0, "terminal": "nvimterm"}
{"import_complete": 0, "terminal": "nvimterm"}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/source/tutorials/notebooks/averaged_tas_anomaly.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
r"""°°°
# Calculate the Averaged Temperature Anomaly
# Calculate the Averaged Temperature Anomaly
## Averaged Temperature Anomaly 2081-2100 vs 1971-2000 SSP585
Expand Down
2 changes: 1 addition & 1 deletion src/icclim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
ClimateVariable,
build_climate_vars,
)
from icclim.pre_processing.input_parsing import build_input_dict
from icclim.models.constants import (
RESAMPLE_METHOD,
UNITS_KEY,
Expand All @@ -52,6 +51,7 @@
QuantileInterpolationRegistry,
)
from icclim.models.standard_index import StandardIndex
from icclim.pre_processing.input_parsing import build_input_dict
from icclim.user_indices import parse
from icclim.utils import read_date

Expand Down
11 changes: 6 additions & 5 deletions src/icclim/models/climate_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A climate variable is a structure that contains all the pre-processed input varaible to compute a climate index.
A climate index may require one or more climate variables to be computed.
"""

from __future__ import annotations

from collections.abc import Sequence
Expand All @@ -22,7 +23,6 @@
build_reference_da,
build_studied_data,
guess_input_type,
guess_var_names,
read_dataset,
)

Expand All @@ -34,7 +34,7 @@

from icclim.generic_indices.standard_variable import StandardVariable
from icclim.generic_indices.thresholds.models import Threshold
from icclim.icclim_types import InFileBaseType, InFileLike
from icclim.icclim_types import InFileBaseType
from icclim.models.global_metadata import GlobalMetadata
from icclim.models.standard_index import StandardIndex
from icclim.pre_processing.in_file_dictionary import InFileDictionary
Expand All @@ -45,7 +45,7 @@ class ClimateVariable:
"""
ClimateVariable is a dataclass that represents a variable used to compute a climate index.
It groups together the input variable (studied_data), its associated metadata (standard_var)
It groups together the input variable (studied_data), its associated metadata (standard_var)
if any, the threshold it must be compared to.
Attributes
Expand Down Expand Up @@ -77,7 +77,7 @@ def build_indicator_metadata(
) -> dict[str, str | dict]:
"""
Build the metadata for the indicator that will be computed with this variable.
Parameters
----------
src_freq: Frequency
Expand Down Expand Up @@ -145,7 +145,7 @@ def build_climate_vars(
Returns
-------
list of ClimateVariable that will be used to compute the climate index.
list of ClimateVariable that will be used to compute the climate index.
"""
if standard_index is not None and len(standard_index.input_variables) > len(
climate_vars_dict
Expand Down Expand Up @@ -249,6 +249,7 @@ def _build_reference_variable(
is_reference=True,
)


def build_climate_var(
climate_var_name: str,
climate_var_data: InFileDictionary | InFileBaseType,
Expand Down
1 change: 1 addition & 0 deletions src/icclim/models/global_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class GlobalMetadata(TypedDict):
"""Global metadata model."""

history: str | None
source: str | None
time_encoding: dict | None # to be read from ds.time.encoding
2 changes: 1 addition & 1 deletion src/icclim/pre_processing/in_file_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InFileDictionary(TypedDict):
in_files = {
"tasmax": {
"study": "tasmax-store.zarr",
"threshold": build_threshold(operator=">", value=["per-1.nc", "per-2.nc"]),
"threshold": build_threshold(operator=">", value=["per-1.nc", "per-2.nc"]),
},
"pr": "pr.nc",
"tasmin": {"study": "tasmin.nc"},
Expand Down
8 changes: 4 additions & 4 deletions src/icclim/pre_processing/input_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@

from pint import Quantity

from icclim.icclim_types import InFileBaseType
from icclim.generic_indices.thresholds.models import Threshold
from icclim.icclim_types import InFileBaseType, InFileLike
from icclim.models.standard_index import StandardIndex
from icclim.pre_processing.in_file_dictionary import InFileDictionary
from icclim.generic_indices.thresholds.models import Threshold
from icclim.icclim_types import InFileLike


DEFAULT_INPUT_FREQUENCY = "days"
Expand Down Expand Up @@ -121,7 +120,7 @@ def guess_var_names(
Returns
-------
list[Hashable]
The list of guessed variable names.
The list of guessed variable names.
"""
if var_names is None:
return _guess_dataset_var_names(ds=ds, standard_index=standard_index)
Expand Down Expand Up @@ -293,6 +292,7 @@ def _build_in_file_dict(
}
return {var_name: {"study": input_dataset[var_name]} for var_name in var_names}


def _read_dataarray(
data: DataArray,
standard_var: StandardVariable | None = None,
Expand Down
5 changes: 4 additions & 1 deletion tests/test_ecad_indices.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import pytest
from icclim.ecad.ecad_indices import EcadIndexRegistry, DcscIndexRegistry
from icclim.ecad.ecad_indices import DcscIndexRegistry, EcadIndexRegistry
from icclim.icclim_exceptions import InvalidIcclimArgumentError
from icclim.models.standard_index import StandardIndex


def test_listing():
res = EcadIndexRegistry.to_list()
indices = [
k for k, v in EcadIndexRegistry.__dict__.items() if isinstance(v, StandardIndex)
]
assert len(res) == len(indices)


class TestIndexFromString:
def test_simple(self):
res = EcadIndexRegistry.lookup("SU")
Expand All @@ -23,6 +25,7 @@ def test_error(self):
with pytest.raises(InvalidIcclimArgumentError):
EcadIndexRegistry.lookup("cacahuête")


def test_dcsc_index_registry():
# Test the length of the index registry
assert len(DcscIndexRegistry.to_list()) == 24
Expand Down

0 comments on commit 7170579

Please sign in to comment.