Skip to content

Commit

Permalink
Remove deprecated mf_file call signatures (#1506)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* The `mf_file` call signature (deprecated in `xclim` v0.43.0) found in
``xclim.ensembles.create_ensemble`` (and
``xclim.ensembles._ens_align_dataset``) has been removed.
* Added a small documentation adjustment for `ruff` in the contributing guide.

### Does this PR introduce a breaking change?

This call signature has been deprecated for some time, so no.
  • Loading branch information
Zeitsperre authored Oct 18, 2023
2 parents d61990c + 67c4b26 commit 3d042f9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Breaking changes
* ``xclim.indices.winter_storm`` renamed to ``xclim.indices.snd_storm_days``. (:pull:`1505`).
* Default threshold in ``xclim.indices.snw_season_{start|length|end}`` changed form `20 kg m-2` to `4 kg m-2`. (:pull:`1505`).
* `xclim` development dependencies now include `ruff`. `pycodestyle` and `pydocstyle` have been replaced by `ruff` and removed from the `dev` installation recipe. (:pull:`1504`).
* The `mf_file` call signature found in ``xclim.ensembles.create_ensemble`` (and ``xclim.ensembles._ens_align_dataset``) has been removed (deprecated since `xclim` v0.43.0). (:pull:`1506`).

Internal changes
^^^^^^^^^^^^^^^^
Expand Down
20 changes: 14 additions & 6 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,21 @@ Ready to contribute? Here's how to set up `xclim` for local development.
# To run pre-commit hooks manually:
$ pre-commit run --all-files

Instead of ``pre-commit``, you could also verify your changes manually with `black`, `flake8`, `flake8-rst-docstrings`, `pydocstyle`, and `yamllint`::
Instead of ``pre-commit``, you can also verify your changes using the `Make` recipe for code linting checks::

$ black --check --target-version py38 xclim tests
$ black --check --target-version py38 --include "\.ipynb$" docs
$ flake8 xclim tests
$ pydocstyle --config=setup.cfg xclim xclim
$ yamllint --config-file .yamllint.yaml xclim
$ make lint

Or, alternatively, you can check individual hooks manually with `black`, `isort`, `ruff`, `flake8`, `flake8-rst-docstrings`, `nbqa`, `blackdoc`, and `yamllint`::

$ black --check xclim tests
$ isort --check xclim tests
$ ruff xclim tests
$ flake8 --config=setup.cfg xclim tests
$ nbqa black --check docs
$ nbqa isort --check docs
$ blackdoc --check --exclude=xclim/indices/__init__.py xclim
$ blackdoc --check docs
$ yamllint --config-file=.yamllint.yaml xclim

6. When features or bug fixes have been contributed, unit tests and doctests have been added, or notebooks have been updated, use ``$ pytest`` to test them::

Expand Down
3 changes: 1 addition & 2 deletions tests/test_ensembles.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ def test_calc_mean_std_min_max(self, ensemble_dataset_objects, open_dataset):
for n in ensemble_dataset_objects["nc_files_simple"]:
ds = open_dataset(n)
ds_all.append(ds)
with pytest.warns(FutureWarning):
ens = ensembles.create_ensemble(ds_all, mf_flag=False)
ens = ensembles.create_ensemble(ds_all, multifile=False)

out1 = ensembles.ensemble_mean_std_max_min(ens)
np.testing.assert_array_equal(
Expand Down
2 changes: 1 addition & 1 deletion xclim/core/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ def injected_parameters(self):

@property
def is_generic(self):
"""Return True if the indicator is "generic", meaning that it can accepts variable with any units."""
"""Return True if the indicator is "generic", meaning that it can accept variables with any units."""
return not hasattr(self.compute, "in_units")

def _show_deprecation_warning(self):
Expand Down
21 changes: 0 additions & 21 deletions xclim/ensembles/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""
from __future__ import annotations

import warnings
from glob import glob
from pathlib import Path
from typing import Any, Sequence
Expand All @@ -24,7 +23,6 @@ def create_ensemble(
calendar: str | None = None,
realizations: Sequence[Any] | None = None,
cal_kwargs: dict | None = None,
mf_flag: bool | str = "UNSET", # noqa
**xr_kwargs,
) -> xr.Dataset:
r"""Create an xarray dataset of an ensemble of climate simulation from a list of netcdf files.
Expand Down Expand Up @@ -104,15 +102,6 @@ def create_ensemble(
"is a glob pattern, as the final order is random."
)

if mf_flag != "UNSET":
warnings.warn(
"The `mf_flag` argument is being deprecated in favour of `multifile` in `create.ensemble()`. "
"This change will be made effective from `xclim>=0.43.0`. Please update your scripts accordingly",
FutureWarning,
stacklevel=3,
)
multifile = mf_flag

ds = _ens_align_datasets(
datasets,
multifile,
Expand Down Expand Up @@ -350,7 +339,6 @@ def _ens_align_datasets(
resample_freq: str | None = None,
calendar: str = "default",
cal_kwargs: dict | None = None,
mf_flag: bool | str = "UNSET", # noqa
**xr_kwargs,
) -> list[xr.Dataset]:
r"""Create a list of aligned xarray Datasets for ensemble Dataset creation.
Expand Down Expand Up @@ -386,15 +374,6 @@ def _ens_align_datasets(
if isinstance(datasets, str):
datasets = glob(datasets)

if mf_flag != "UNSET":
warnings.warn(
"The `mf_flag` argument is being deprecated in favour of `multifile` in `_ens_align_datasets()`. "
"This change will be made effective from `xclim>=0.43.0`. Please update your scripts accordingly",
FutureWarning,
stacklevel=3,
)
multifile = mf_flag

ds_all = []
calendars = []
for i, n in enumerate(datasets):
Expand Down

0 comments on commit 3d042f9

Please sign in to comment.