Skip to content

Commit 6062e35

Browse files
authored
More xarray testing (#288)
* More xarray testing * Update .github/workflows/ci.yaml * Update .github/workflows/ci.yaml
1 parent 19db5b3 commit 6062e35

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ jobs:
119119
environment-name: xarray-tests
120120
init-shell: bash
121121
cache-environment: true
122-
create-args: |
123-
python=3.10
122+
create-args: >-
123+
python=3.11
124+
pint>=0.22
124125
- name: Install xarray
125126
run: |
126127
python -m pip install --no-deps .
@@ -144,4 +145,7 @@ jobs:
144145
id: status
145146
run: |
146147
set -euo pipefail
147-
python -m pytest -n auto xarray/tests/test_groupby.py
148+
python -m pytest -n auto \
149+
xarray/tests/test_groupby.py \
150+
xarray/tests/test_units.py::TestDataArray::test_computation_objects \
151+
xarray/tests/test_units.py::TestDataset::test_computation_objects

tests/test_xarray.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,25 @@ def test_fill_value_xarray_behaviour():
576576
}
577577
)
578578

579-
expected_time = pd.date_range("2000-01-01", freq="3H", periods=19)
580-
expected = ds.reindex(time=expected_time)
581-
expected = ds.resample(time="3H").sum()
579+
pd.date_range("2000-01-01", freq="3H", periods=19)
580+
with xr.set_options(use_flox=False):
581+
expected = ds.resample(time="3H").sum()
582582
with xr.set_options(use_flox=True):
583583
actual = ds.resample(time="3H").sum()
584584
xr.testing.assert_identical(expected, actual)
585+
586+
587+
def test_fill_value_xarray_binning():
588+
array = np.linspace(0, 10, 5 * 10, dtype=int).reshape(5, 10)
589+
590+
x = np.array([0, 0, 1, 2, 2])
591+
y = np.arange(array.shape[1]) * 3
592+
u = np.linspace(0, 1, 5)
593+
594+
data_array = xr.DataArray(data=array, coords={"x": x, "y": y, "u": ("x", u)}, dims=("x", "y"))
595+
with xr.set_options(use_flox=False):
596+
expected = data_array.groupby_bins("y", bins=4).mean()
597+
with xr.set_options(use_flox=True):
598+
actual = data_array.groupby_bins("y", bins=4).mean()
599+
600+
xr.testing.assert_identical(expected, actual)

0 commit comments

Comments
 (0)