()
| 221 | |
| 222 | |
| 223 | def test_apply_two_outputs() -> None: |
| 224 | array = np.arange(5) |
| 225 | variable = xr.Variable("x", array) |
| 226 | data_array = xr.DataArray(variable, [("x", -array)]) |
| 227 | dataset = xr.Dataset({"y": variable}, {"x": -array}) |
| 228 | |
| 229 | def twice(obj): |
| 230 | def func(x): |
| 231 | return (x, x) |
| 232 | |
| 233 | return apply_ufunc(func, obj, output_core_dims=[[], []]) |
| 234 | |
| 235 | out0, out1 = twice(array) |
| 236 | assert_identical(out0, array) |
| 237 | assert_identical(out1, array) |
| 238 | |
| 239 | out0, out1 = twice(variable) |
| 240 | assert_identical(out0, variable) |
| 241 | assert_identical(out1, variable) |
| 242 | |
| 243 | out0, out1 = twice(data_array) |
| 244 | assert_identical(out0, data_array) |
| 245 | assert_identical(out1, data_array) |
| 246 | |
| 247 | out0, out1 = twice(dataset) |
| 248 | assert_identical(out0, dataset) |
| 249 | assert_identical(out1, dataset) |
| 250 | |
| 251 | out0, out1 = twice(data_array.groupby("x")) |
| 252 | assert_identical(out0, data_array) |
| 253 | assert_identical(out1, data_array) |
| 254 | |
| 255 | out0, out1 = twice(dataset.groupby("x")) |
| 256 | assert_identical(out0, dataset) |
| 257 | assert_identical(out1, dataset) |
| 258 | |
| 259 | |
| 260 | def test_apply_missing_dims() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…