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

Fix warnings #1387

Merged
merged 4 commits into from
Nov 11, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyaerocom/plot/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from warnings import warn


Expand Down Expand Up @@ -152,7 +153,9 @@ def __str__(self):
return s


COLOR_THEME = ColorTheme(DEFAULT_THEME)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning, module="pyaerocom")
COLOR_THEME = ColorTheme(DEFAULT_THEME)


def get_color_theme(theme_name="dark"):
Expand Down
4 changes: 3 additions & 1 deletion pyaerocom/plot/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
)
from pyaerocom.region import Region

MPL_PARAMS = custom_mpl()
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning, module="pyaerocom")
MPL_PARAMS = custom_mpl()


def get_cmap_maps_aerocom(color_theme=None, vmin=None, vmax=None):
Expand Down
26 changes: 13 additions & 13 deletions pyproject.toml
magnusuMET marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ log_cli_level = "WARNING"
addopts = ["--failed-first", "--import-mode=importlib"]
xfail_strict = true
testpaths = ["tests"]
## uncomment to raise errors from warnings
#filterwarnings = [
# # all warnings are errors
# "error",
# "ignore::pytest.PytestUnraisableExceptionWarning",
# # except deprecation and future warnings ouside this packege
# 'ignore::PendingDeprecationWarning:^(?!pyaerocom|tests).*:',
# 'ignore::DeprecationWarning:^(?!pyaerocom|tests).*:',
# 'ignore::FutureWarning:^(?!pyaerocom|tests).*:',
# # and not on this list
# "ignore:.*please install Basemap:UserWarning:geonum.*:",
# "ignore:Using DEFAULT_SPHERICAL_EARTH_RADIUS:UserWarning:iris.*:",
#]
filterwarnings = [
# treat warnings as errors
"error",
"ignore::pytest.PytestUnraisableExceptionWarning",
# except deprecation and future warnings ouside this packege
'ignore::PendingDeprecationWarning:^(?!pyaerocom|tests).*:',
'ignore::DeprecationWarning:^(?!pyaerocom|tests).*:',
'ignore::FutureWarning:^(?!pyaerocom|tests).*:',
# Ignore self-deprecation warnings related to plotting
'ignore:matplotlib based plotting is no longer directly supported. This (function|class) may be removed in future versions\.:DeprecationWarning:(pyaerocom|tests):',
# and not on this list
"ignore:Using DEFAULT_SPHERICAL_EARTH_RADIUS:UserWarning:iris.*:", # Issue #1394
]

[tool.coverage.run]
source = ["pyaerocom"]
Expand Down
2 changes: 2 additions & 0 deletions tests/cams2_83/test_cams2_83_cli_mos.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def test_eval_mos_standard(tmp_path: Path, coldata_mos: Path, caplog):


@ignore_warnings(RuntimeWarning, "invalid value encountered in divide")
@ignore_warnings(RuntimeWarning, "Mean of empty slice")
@ignore_warnings(RuntimeWarning, "All-NaN slice encountered")
@pytest.mark.usefixtures("fake_ExperimentProcessor", "reset_cachedir")
def test_eval_mos_medianscores(tmp_path: Path, coldata_mos: Path, caplog):
options = f"season 2024-03-01 2024-03-05 --data-path {tmp_path} --coldata-path {coldata_mos} --cache {tmp_path} --id mos-colocated-data --name 'Test'"
Expand Down
4 changes: 2 additions & 2 deletions tests/stats/mda8/test_mda8.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_data(time, values) -> xr.DataArray:
# https://github.com/metno/pyaerocom/issues/1323
pytest.param(
xr.date_range(start="2024-01-01 06:00:00", periods=30, freq="1h"),
np.arange(30),
np.arange(30, dtype=float),
[np.nan, np.nan],
id="#1323",
),
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_rollingaverage_label():
https://github.com/metno/pyaerocom/issues/1323
"""
data = xr.DataArray(
[[[x] for x in range(24)]],
[[[float(x)] for x in range(24)]],
dims=["data_source", "time", "station_name"],
coords={"time": xr.date_range(start="2024-01-01 00:00", periods=24, freq="1h")},
)
Expand Down
Loading