MCPcopy
hub / github.com/pydata/xarray / test_reduce_only_one_axis

Method test_reduce_only_one_axis

xarray/tests/test_dataset.py:6363–6377  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6361 assert_identical(expected, actual)
6362
6363 def test_reduce_only_one_axis(self) -> None:
6364 def mean_only_one_axis(x, axis):
6365 if not isinstance(axis, integer_types):
6366 raise TypeError("non-integer axis")
6367 return x.mean(axis)
6368
6369 ds = Dataset({"a": (["x", "y"], [[0, 1, 2, 3, 4]])})
6370 expected = Dataset({"a": ("x", [2])})
6371 actual = ds.reduce(mean_only_one_axis, "y")
6372 assert_identical(expected, actual)
6373
6374 with pytest.raises(
6375 TypeError, match=r"missing 1 required positional argument: 'axis'"
6376 ):
6377 ds.reduce(mean_only_one_axis)
6378
6379 def test_reduce_no_axis(self) -> None:
6380 def total_sum(x):

Callers

nothing calls this directly

Calls 3

reduceMethod · 0.95
DatasetClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected