MCPcopy Index your code
hub / github.com/pydata/xarray / test_apply_two_outputs

Function test_apply_two_outputs

xarray/tests/test_computation.py:223–257  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

221
222
223def 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
260def test_apply_missing_dims() -> None:

Callers

nothing calls this directly

Calls 5

groupbyMethod · 0.95
groupbyMethod · 0.95
twiceFunction · 0.85
arangeMethod · 0.80
assert_identicalFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…