()
| 975 | |
| 976 | |
| 977 | def test_groupby_math_more() -> None: |
| 978 | ds = create_test_data() |
| 979 | grouped = ds.groupby("numbers") |
| 980 | zeros = DataArray([0, 0, 0, 0], [("numbers", range(4))]) |
| 981 | expected = (ds + Variable("dim3", np.zeros(10))).transpose( |
| 982 | "dim3", "dim1", "dim2", "time" |
| 983 | ) |
| 984 | actual = grouped + zeros |
| 985 | assert_equal(expected, actual) |
| 986 | |
| 987 | actual = zeros + grouped |
| 988 | assert_equal(expected, actual) |
| 989 | |
| 990 | with pytest.raises(ValueError, match=r"incompat.* grouped binary"): |
| 991 | grouped + ds |
| 992 | with pytest.raises(ValueError, match=r"incompat.* grouped binary"): |
| 993 | ds + grouped |
| 994 | with pytest.raises(TypeError, match=r"only support binary ops"): |
| 995 | grouped + 1 # type: ignore[operator] |
| 996 | with pytest.raises(TypeError, match=r"only support binary ops"): |
| 997 | grouped + grouped # type: ignore[operator] |
| 998 | with pytest.raises(TypeError, match=r"in-place operations"): |
| 999 | ds += grouped # type: ignore[arg-type] |
| 1000 | |
| 1001 | ds = Dataset( |
| 1002 | { |
| 1003 | "x": ("time", np.arange(100)), |
| 1004 | "time": pd.date_range("2000-01-01", periods=100), |
| 1005 | } |
| 1006 | ) |
| 1007 | with pytest.raises(ValueError, match=r"incompat.* grouped binary"): |
| 1008 | ds + ds.groupby("time.month") |
| 1009 | |
| 1010 | |
| 1011 | def test_groupby_math_bitshift() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…