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

Offer a fixture for unifying DataArray & Dataset tests #8533

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
No commit message
  • Loading branch information
max-sixty committed Dec 8, 2023
commit db2a141bb841b8331b1ed858db4f873ee00b6cb6
12 changes: 6 additions & 6 deletions xarray/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ def d(request, backend, type) -> DataArray | Dataset:
if request.param == 1:
ds = Dataset(
dict(
a=(["x", "y"], np.arange(16).reshape(8, 2)),
b=(["y", "z"], np.arange(12, 32).reshape(2, 10).astype(np.float64)),
a=(["x", "z"], np.arange(24).reshape(2, 12)),
b=(["y", "z"], np.arange(100, 136).reshape(3, 12).astype(np.float64)),
),
dict(
x=("x", np.linspace(0, 1.0, 8)),
y=range(2),
z=("z", np.linspace(0, 1.0, 10)),
w=("y", ["a", "b"]),
x=("x", np.linspace(0, 1.0, 2)),
y=range(3),
z=("z", pd.date_range("2000-01-01", periods=12)),
w=("x", ["a", "b"]),
),
)
if type == DataArray:
Expand Down
10 changes: 5 additions & 5 deletions xarray/tests/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ def compute_backend(request):


@pytest.mark.parametrize("func", ["mean", "sum"])
@pytest.mark.parametrize("min_periods", [1, 20])
@pytest.mark.parametrize("min_periods", [1, 10])
def test_cumulative(d, func, min_periods) -> None:
# One dim
result = getattr(d.cumulative("x", min_periods=min_periods), func)()
expected = getattr(d.rolling(x=d["x"].size, min_periods=min_periods), func)()
result = getattr(d.cumulative("z", min_periods=min_periods), func)()
expected = getattr(d.rolling(z=d["z"].size, min_periods=min_periods), func)()
assert_identical(result, expected)

# Multiple dim
result = getattr(d.cumulative(["x", "y"], min_periods=min_periods), func)()
result = getattr(d.cumulative(["z", "x"], min_periods=min_periods), func)()
expected = getattr(
d.rolling(x=d["x"].size, y=d["y"].size, min_periods=min_periods),
d.rolling(z=d["z"].size, x=d["x"].size, min_periods=min_periods),
func,
)()
assert_identical(result, expected)
Expand Down
Loading