Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
hollymandel committed Nov 3, 2024
1 parent da695ee commit e6725de
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions xarray/tests/test_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

import xarray as xr
from xarray.coding.cftimeindex import _parse_array_of_cftime_strings
from xarray.core.types import InterpnOptions, InterpOptions, Interp1dOptions, InterpolantOptions
from xarray.core.types import (
Interp1dOptions,
InterpnOptions,
InterpolantOptions,
InterpOptions,
)
from xarray.tests import (
assert_allclose,
assert_equal,
Expand All @@ -30,6 +35,7 @@

ALL_1D = get_args(Interp1dOptions) + get_args(InterpolantOptions)


def get_example_data(case: int) -> xr.DataArray:
if case == 0:
# 2D
Expand Down Expand Up @@ -282,16 +288,13 @@ def func(obj, dim, new_x, method):
)
assert_allclose(actual, expected.transpose("z", "w", "y", transpose_coords=True))


@requires_scipy
@pytest.mark.parametrize(
"method", get_args(InterpnOptions)
)
@pytest.mark.parametrize("method", get_args(InterpnOptions))
@pytest.mark.parametrize(
"case", [pytest.param(3, id="no_chunk"), pytest.param(4, id="chunked")]
)
def test_interpolate_nd(
case: int, method: InterpnOptions, nd_interp_coords
) -> None:
def test_interpolate_nd(case: int, method: InterpnOptions, nd_interp_coords) -> None:
if not has_dask and case == 4:
pytest.skip("dask is not installed in the environment.")

Expand Down Expand Up @@ -440,7 +443,7 @@ def func(obj, new_x):
axis=obj.get_axis_num("x"),
bounds_error=False,
fill_value=np.nan,
kind=method
kind=method,
)(new_x)

coords = {"x": xdest, "y": da["y"], "x2": func(da["x2"], xdest)}
Expand Down Expand Up @@ -857,7 +860,7 @@ def test_3641() -> None:

@requires_scipy
# cubic, quintic, pchip omitted because not enough points
@pytest.mark.parametrize("method", ("linear","nearest","slinear"))
@pytest.mark.parametrize("method", ("linear", "nearest", "slinear"))
def test_decompose(method: InterpOptions) -> None:
da = xr.DataArray(
np.arange(6).reshape(3, 2),
Expand All @@ -880,7 +883,7 @@ def test_decompose(method: InterpOptions) -> None:
@requires_dask
# omit quintic because not enough points
# unknown timeout using pchip
@pytest.mark.parametrize("method", ("cubic","linear","slinear"))
@pytest.mark.parametrize("method", ("cubic", "linear", "slinear"))
@pytest.mark.parametrize("chunked", [True, False])
@pytest.mark.parametrize(
"data_ndim,interp_ndim,nscalar",
Expand Down Expand Up @@ -958,7 +961,7 @@ def test_interpolate_chunk_1d(
@requires_scipy
@requires_dask
# quintic omitted because not enough points
@pytest.mark.parametrize("method", ("linear","nearest","slinear","cubic","pchip"))
@pytest.mark.parametrize("method", ("linear", "nearest", "slinear", "cubic", "pchip"))
@pytest.mark.filterwarnings("ignore:Increasing number of chunks")
def test_interpolate_chunk_advanced(method: InterpOptions) -> None:
"""Interpolate nd array with an nd indexer sharing coordinates."""
Expand Down

0 comments on commit e6725de

Please sign in to comment.