MCPcopy Create free account
hub / github.com/pydata/xarray / test_groupby_dataset_math

Function test_groupby_dataset_math

xarray/tests/test_groupby.py:950–974  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

948
949
950def test_groupby_dataset_math() -> None:
951 def reorder_dims(x):
952 return x.transpose("dim1", "dim2", "dim3", "time")
953
954 ds = create_test_data()
955 ds["dim1"] = ds["dim1"]
956 grouped = ds.groupby("dim1")
957
958 expected = reorder_dims(ds + ds.coords["dim1"])
959 actual = grouped + ds.coords["dim1"]
960 assert_identical(expected, reorder_dims(actual))
961
962 # Order matters for attrs - coord + grouped will not have attrs
963 # since coord has no attrs and binary ops keep attrs from first operand
964 expected_reversed = reorder_dims(ds.coords["dim1"] + ds)
965 actual = ds.coords["dim1"] + grouped
966 assert_identical(expected_reversed, reorder_dims(actual))
967
968 ds2 = 2 * ds
969 expected = reorder_dims(ds + ds2)
970 actual = grouped + ds2
971 assert_identical(expected, reorder_dims(actual))
972
973 actual = ds2 + grouped
974 assert_identical(expected, reorder_dims(actual))
975
976
977def test_groupby_math_more() -> None:

Callers

nothing calls this directly

Calls 4

create_test_dataFunction · 0.90
assert_identicalFunction · 0.90
reorder_dimsFunction · 0.85
groupbyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…