(as_dataset)
| 2956 | |
| 2957 | @pytest.mark.parametrize("as_dataset", [True, False]) |
| 2958 | def test_multiple_groupers_string(as_dataset) -> None: |
| 2959 | obj = DataArray( |
| 2960 | np.array([1, 2, 3, 0, 2, np.nan]), |
| 2961 | dims="d", |
| 2962 | coords=dict( |
| 2963 | labels1=("d", np.array(["a", "b", "c", "c", "b", "a"])), |
| 2964 | labels2=("d", np.array(["x", "y", "z", "z", "y", "x"])), |
| 2965 | ), |
| 2966 | name="foo", |
| 2967 | ) |
| 2968 | |
| 2969 | if as_dataset: |
| 2970 | obj = obj.to_dataset() # type: ignore[assignment] |
| 2971 | |
| 2972 | expected = obj.groupby(labels1=UniqueGrouper(), labels2=UniqueGrouper()).mean() |
| 2973 | actual = obj.groupby(("labels1", "labels2")).mean() |
| 2974 | assert_identical(expected, actual) |
| 2975 | |
| 2976 | # Passes `"labels2"` to squeeze; will raise an error around kwargs rather than the |
| 2977 | # warning & type error in the future |
| 2978 | with pytest.warns(FutureWarning): |
| 2979 | with pytest.raises(TypeError): |
| 2980 | obj.groupby("labels1", "labels2") # type: ignore[arg-type, misc] |
| 2981 | with pytest.raises(ValueError): |
| 2982 | obj.groupby("labels1", foo="bar") # type: ignore[arg-type] |
| 2983 | with pytest.raises(ValueError): |
| 2984 | obj.groupby("labels1", foo=UniqueGrouper()) |
| 2985 | |
| 2986 | |
| 2987 | @pytest.mark.parametrize("shuffle", [True, False]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…