Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
coxipi committed Aug 1, 2024
1 parent 25ed32b commit 52546bc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/xsdba/_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from .options import set_options
from .processing import escore, jitter_under_thresh, reordering, standardize
from .units import convert_units_to, units

from .xclim_submodules.stats import _fitfunc_1d


Expand Down Expand Up @@ -716,7 +715,7 @@ def npdf_transform(ds: xr.Dataset, **kwargs) -> xr.Dataset:
Notes
-----
If `n_escore` is negative, `escores` will be filled with NaNs.
"""
ref = ds.ref.rename(time_hist="time")
hist = ds.hist.rename(time_hist="time")
Expand Down
6 changes: 2 additions & 4 deletions src/xsdba/adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
from xsdba.utils import uses_dask

from ._adjustment import (
extremes_adjust,
extremes_train,
dqm_adjust,
dqm_train,
eqm_train,
extremes_adjust,
extremes_train,
loci_adjust,
loci_train,
mbcn_adjust,
Expand All @@ -45,10 +45,8 @@
pc_matrix,
rand_rot_matrix,
)

from .xclim_submodules import stats


__all__ = [
"LOCI",
"BaseAdjustment",
Expand Down
1 change: 0 additions & 1 deletion src/xsdba/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def pint_multiply(
}



def ensure_absolute_temperature(units: str):
"""Convert temperature units to their absolute counterpart, assuming they represented a difference (delta).
Expand Down
8 changes: 4 additions & 4 deletions tests/test_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from xsdba import adjustment
from xsdba.adjustment import (
ExtremeValues,
LOCI,
DetrendedQuantileMapping,
EmpiricalQuantileMapping,
ExtremeValues,
PrincipalComponents,
QuantileDeltaMapping,
Scaling,
Expand Down Expand Up @@ -765,14 +765,14 @@ def gen_testdata(c, s):

@pytest.mark.slow
def test_real_data(self, open_dataset):
dsim = open_dataset("sdba/CanESM2_1950-2100.nc")#.chunk()
dref = open_dataset("sdba/ahccd_1950-2013.nc")#.chunk()
dsim = open_dataset("sdba/CanESM2_1950-2100.nc") # .chunk()
dref = open_dataset("sdba/ahccd_1950-2013.nc") # .chunk()
ref = dref.sel(time=slice("1950", "2009")).pr
hist = dsim.sel(time=slice("1950", "2009")).pr
# TODO: Do we want to include standard conversions in xsdba tests?
# this is just convenient for now to keep those tests
hist = pint_multiply(hist, "1e-03 m^3/kg")
hist = convert_units_to(hist,ref)
hist = convert_units_to(hist, ref)

quantiles = np.linspace(0.01, 0.99, num=50)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_ecdf(timeseries, random):
r = dist.rvs(10000, random_state=random)
q = [0.01, 0.5, 0.99]
x = xr.DataArray(dist.ppf(q), dims=("q",))
np.testing.assert_allclose(u.ecdf(timeseries(r, units="K" ), x), q, 3)
np.testing.assert_allclose(u.ecdf(timeseries(r, units="K"), x), q, 3)

# With NaNs
r[:2000] = np.nan
Expand All @@ -31,8 +31,8 @@ def test_map_cdf(timeseries, random):
x_value = u.map_cdf(
xr.Dataset(
dict(
x=timeseries(xd.rvs(n, random_state=random), units = "kg / m^2 / s"),
y=timeseries(yd.rvs(n, random_state=random), units = "kg / m^2 / s"),
x=timeseries(xd.rvs(n, random_state=random), units="kg / m^2 / s"),
y=timeseries(yd.rvs(n, random_state=random), units="kg / m^2 / s"),
)
),
y_value=yd.ppf(q),
Expand Down

0 comments on commit 52546bc

Please sign in to comment.