Skip to content

Commit c4a3646

Browse files
authored
Merge pull request #11 from jhnnsrs/main
xarray test and compatibility with latest xarray
2 parents 0cd1a70 + cb4e08b commit c4a3646

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ MANIFEST.in
3838
.venv
3939
/releases/*
4040
pip-wheel-metadata
41-
/poetry.toml
41+
/poetry.toml
42+
/venv

src/xarray_multiscale/multiscale.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ def downscale(
330330
to_downscale.data, reduction, scale_factors, **kwargs
331331
)
332332
downscaled_coords = downscale_coords(to_downscale, scale_factors)
333-
return DataArray(downscaled_data, downscaled_coords, attrs=array.attrs)
333+
return DataArray(
334+
downscaled_data, downscaled_coords, attrs=array.attrs, dims=array.dims
335+
)
334336

335337

336338
def downscale_coords(

tests/test_doc.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from xarray_multiscale import multiscale
2+
from xarray_multiscale.reducers import windowed_mean
3+
import numpy as np
4+
import xarray as xr
5+
6+
7+
def test_xarray_example():
8+
data = xr.DataArray(np.zeros((1024, 1024)), dims=("x", "y"))
9+
scaled_data = multiscale(data, windowed_mean, (2, 2))
10+
assert len(scaled_data) == 11, "Incorrect number of arrays returned"

0 commit comments

Comments
 (0)