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
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and aaronspring committed Apr 2, 2024
1 parent 128dd50 commit d6cbbd7
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 35 deletions.
6 changes: 3 additions & 3 deletions climpred/bias_removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ def gaussian_bias_removal(
hindcast_train._datasets["initialized"] = hindcast.get_initialized().sel(
init=train_time_init
)
hindcast_test._datasets[
"initialized"
] = hindcast.get_initialized().drop_sel(init=train_time_init)
hindcast_test._datasets["initialized"] = (
hindcast.get_initialized().drop_sel(init=train_time_init)
)
else:
assert train_test_split in ["unfair", "unfair-cv"]
hindcast_train = hindcast
Expand Down
6 changes: 3 additions & 3 deletions climpred/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ def resample_skill_loop(self, iterations, resample_dim, verify_kwargs):
# resample uninitialized
if not self.get_uninitialized():
# warn not found and therefore generate
self_for_loop._datasets[
"uninitialized"
] = self.generate_uninitialized().get_uninitialized()
self_for_loop._datasets["uninitialized"] = (
self.generate_uninitialized().get_uninitialized()
)
else:
self_for_loop._datasets["uninitialized"] = _resample(
self.get_uninitialized(), "member"
Expand Down
36 changes: 20 additions & 16 deletions climpred/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,9 +1456,11 @@ def verify(
reference = _check_valid_reference(reference)
input_dict = {
"ensemble": self._datasets["initialized"],
"control": self._datasets["control"]
if isinstance(self._datasets["control"], xr.Dataset)
else None,
"control": (
self._datasets["control"]
if isinstance(self._datasets["control"], xr.Dataset)
else None
),
"init": True,
}
result = self._apply_climpred_function(
Expand Down Expand Up @@ -1535,9 +1537,11 @@ def _compute_uninitialized(
)
input_dict = {
"ensemble": self._datasets["uninitialized"],
"control": self._datasets["control"]
if isinstance(self._datasets["control"], xr.Dataset)
else None,
"control": (
self._datasets["control"]
if isinstance(self._datasets["control"], xr.Dataset)
else None
),
"init": False,
}
if dim is None:
Expand Down Expand Up @@ -1664,9 +1668,11 @@ def _compute_climatology(
"""
input_dict = {
"ensemble": self._datasets["initialized"],
"control": self._datasets["control"]
if isinstance(self._datasets["control"], xr.Dataset)
else None,
"control": (
self._datasets["control"]
if isinstance(self._datasets["control"], xr.Dataset)
else None
),
"init": True,
}
if dim is None:
Expand Down Expand Up @@ -2877,11 +2883,9 @@ def remove_bias(
if len(self.get_initialized().coords["valid_time"].dims) == 1 and set(
["init", "lead"]
).issubset(set(self.get_initialized().dims)):
self._datasets["initialized"].coords[
"valid_time"
] = add_time_from_init_lead(
self.get_initialized().drop("valid_time")
).coords[
"valid_time"
]
self._datasets["initialized"].coords["valid_time"] = (
add_time_from_init_lead(
self.get_initialized().drop("valid_time")
).coords["valid_time"]
)
return self
8 changes: 5 additions & 3 deletions climpred/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,11 @@ def _verif_dates_xr(hindcast, alignment, reference, date2num_units):
hindcast.get_observations(),
alignment,
reference=reference,
hist=hindcast.get_uninitialized()
if isinstance(hindcast.get_uninitialized(), xr.Dataset)
else None,
hist=(
hindcast.get_uninitialized()
if isinstance(hindcast.get_uninitialized(), xr.Dataset)
else None
),
)

verif_dates_xr = xr.concat(
Expand Down
1 change: 1 addition & 0 deletions climpred/tests/test_bias_removal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test bias_removal.py."""

import copy

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions climpred/tests/test_graphics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test graphics.py and PredictionEnsemble.plot()."""

import pytest

from climpred import HindcastEnsemble, PerfectModelEnsemble
Expand Down
8 changes: 5 additions & 3 deletions climpred/tests/test_metrics_perfect.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ def f(x):
skill = he.verify(
metric=metric,
comparison="m2o",
dim=["member", "init"]
if metric in probabilistic_metrics_requiring_more_than_member_dim
else "member",
dim=(
["member", "init"]
if metric in probabilistic_metrics_requiring_more_than_member_dim
else "member"
),
alignment=alignment,
**metric_kwargs,
).SST
Expand Down
1 change: 0 additions & 1 deletion climpred/tests/test_perfect_model_prediction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Test compute_perfect_model."""


import pytest
import xarray as xr

Expand Down
1 change: 1 addition & 0 deletions climpred/tests/test_relative_entropy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test relative_entropy.py"""

import pytest

from climpred.graphics import plot_relative_entropy
Expand Down
1 change: 1 addition & 0 deletions climpred/tests/test_uninitialized.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test compute_uninitialized."""

import pytest

from climpred.constants import VALID_ALIGNMENTS
Expand Down
12 changes: 6 additions & 6 deletions climpred/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def assign_attrs(
skill[v].attrs.update(ds[v].attrs)

# climpred info
skill.attrs[
"prediction_skill_software"
] = "climpred https://climpred.readthedocs.io/"
skill.attrs["prediction_skill_software"] = (
"climpred https://climpred.readthedocs.io/"
)
if function_name:
skill.attrs["skill_calculated_by_function"] = function_name
if "init" in ds.coords and "init" not in skill.dims:
Expand Down Expand Up @@ -138,9 +138,9 @@ def assign_attrs(
if "pers_sig" in kwargs:
if kwargs["pers_sig"] is not None:
_, ci_low_pers, ci_high_pers = _p_ci_from_sig(kwargs["pers_sig"])
kwargs[
"confidence_interval_levels_persistence"
] = f"{ci_high_pers}-{ci_low_pers}"
kwargs["confidence_interval_levels_persistence"] = (
f"{ci_high_pers}-{ci_low_pers}"
)
# check for none attrs and remove
del_list = []
for key, value in kwargs.items():
Expand Down

0 comments on commit d6cbbd7

Please sign in to comment.