Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove logging library from ensembles module #1044

Merged
merged 6 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ repos:
additional_dependencies: [ 'flake8-rst-docstrings' ]
args: [ '--config=setup.cfg' ]
- repo: https://github.com/psf/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
args: [ "--target-version", "py38" ]
additional_dependencies: ['click==8.0.4']
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Bug fixes
Internal changes
^^^^^^^^^^^^^^^^
* `xclim` now uses the ``check-json`` and ``pretty-format-json`` pre-commit checks to validate and format JSON files. (:pull:`1032`).
* The few `logging` artifacts in the ``xclim.ensembles`` module have been replaced with `warnings.warn` calls or removed. (:issue:`1039`, :pull:`1044`).

0.34.0 (25-02-2022)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:
- scipy>=1.2
- xarray>=0.17
# Testing and development dependencies
- black
- black>=22.3
- bump2version
- coverage
- distributed>=2.0
Expand Down
3 changes: 1 addition & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# dev tools and testing
black
black>=22.3
bump2version
click==8.0.4
coverage
flake8
flake8-rst-docstrings
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ opts = -v
skip_install = True
extras =
deps =
click==8.0.4
flake8
flake8-rst-docstrings
black[jupyter]
Expand Down
3 changes: 1 addition & 2 deletions xclim/ensembles/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from xclim.core.calendar import convert_calendar, get_calendar
from xclim.core.formatting import update_history
from xclim.core.utils import calc_perc, logger
from xclim.core.utils import calc_perc


def create_ensemble(
Expand Down Expand Up @@ -302,7 +302,6 @@ def _ens_align_datasets(

ds_all = []
for i, n in enumerate(datasets):
logger.info(f"Accessing {n} of {len(datasets)}")
if mf_flag:
ds = xr.open_mfdataset(n, combine="by_coords", **xr_kwargs)
else:
Expand Down
11 changes: 4 additions & 7 deletions xclim/ensembles/_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,24 @@
order to reduce the volume of computation needed while still covering a good portion of
the simulated climate variability.
"""
import logging
import warnings
from typing import Optional, Tuple, Union
from warnings import warn

import numpy as np
import scipy.stats
import xarray
from scipy.spatial.distance import cdist
from sklearn.cluster import KMeans

logger = logging.getLogger("xclim")

# Avoid having to include matplotlib in xclim requirements
try:
from matplotlib import pyplot as plt

logger.info("Matplotlib installed. Setting make_graph to True.")
warn("Matplotlib installed. Setting make_graph to True.")
MPL_INSTALLED = True

except ImportError:
logger.info("Matplotlib not found. No graph data will be produced.")
warn("Matplotlib not found. No graph data will be produced.")
plt = None
MPL_INSTALLED = False

Expand Down Expand Up @@ -370,7 +367,7 @@ def _get_nclust(method=None, n_sim=None, rsq=None, max_clusters=None):
else:
raise Exception(f"Unknown selection method : {list(method.keys())}")
if n_clusters > max_clusters:
warnings.warn(
warn(
f"{n_clusters} clusters has been found to be the optimal number of clusters, but limiting "
f"to {max_clusters} as required by user provided max_clusters",
UserWarning,
Expand Down