|
1 | 1 | import matplotlib as mpl
|
2 | 2 | import matplotlib.pyplot as plt
|
3 |
| -import numpy as np |
4 | 3 | import pytest
|
5 | 4 | import xarray as xr
|
6 | 5 | from xarray.testing import assert_identical
|
7 | 6 |
|
8 | 7 | import cf_xarray # noqa
|
9 | 8 |
|
10 | 9 | from . import raise_if_dask_computes
|
11 |
| -from .datasets import airds, anc, ds_no_attrs, popds |
| 10 | +from .datasets import airds, anc, ds_no_attrs, multiple, popds |
12 | 11 |
|
13 | 12 | mpl.use("Agg")
|
14 | 13 |
|
@@ -119,25 +118,16 @@ def test_kwargs_methods(obj):
|
119 | 118 |
|
120 | 119 | def test_kwargs_expand_key_to_multiple_keys():
|
121 | 120 |
|
122 |
| - ds = xr.Dataset() |
123 |
| - ds.coords["x1"] = ("x1", range(30), {"axis": "X"}) |
124 |
| - ds.coords["y1"] = ("y1", range(20), {"axis": "Y"}) |
125 |
| - ds.coords["x2"] = ("x2", range(10), {"axis": "X"}) |
126 |
| - ds.coords["y2"] = ("y2", range(5), {"axis": "Y"}) |
127 |
| - |
128 |
| - ds["v1"] = (("x1", "y1"), np.ones((30, 20)) * 15) |
129 |
| - ds["v2"] = (("x2", "y2"), np.ones((10, 5)) * 15) |
130 |
| - |
131 |
| - actual = ds.cf.isel(X=5, Y=3) |
132 |
| - expected = ds.isel(x1=5, y1=3, x2=5, y2=3) |
| 121 | + actual = multiple.cf.isel(X=5, Y=3) |
| 122 | + expected = multiple.isel(x1=5, y1=3, x2=5, y2=3) |
133 | 123 | assert_identical(actual, expected)
|
134 | 124 |
|
135 |
| - actual = ds.cf.mean("X") |
136 |
| - expected = ds.mean(["x1", "x2"]) |
| 125 | + actual = multiple.cf.mean("X") |
| 126 | + expected = multiple.mean(["x1", "x2"]) |
137 | 127 | assert_identical(actual, expected)
|
138 | 128 |
|
139 |
| - actual = ds.cf.coarsen(X=10, Y=5) |
140 |
| - expected = ds.coarsen(x1=10, y1=5, x2=10, y2=5) |
| 129 | + actual = multiple.cf.coarsen(X=10, Y=5) |
| 130 | + expected = multiple.coarsen(x1=10, y1=5, x2=10, y2=5) |
141 | 131 | assert_identical(actual.mean(), expected.mean())
|
142 | 132 |
|
143 | 133 |
|
|
0 commit comments