()
| 741 | |
| 742 | |
| 743 | def test_groupby_grouping_errors() -> None: |
| 744 | dataset = xr.Dataset({"foo": ("x", [1, 1, 1])}, {"x": [1, 2, 3]}) |
| 745 | with pytest.raises( |
| 746 | ValueError, match=r"None of the data falls within bins with edges" |
| 747 | ): |
| 748 | dataset.groupby_bins("x", bins=[0.1, 0.2, 0.3]) |
| 749 | |
| 750 | with pytest.raises( |
| 751 | ValueError, match=r"None of the data falls within bins with edges" |
| 752 | ): |
| 753 | dataset.to_dataarray().groupby_bins("x", bins=[0.1, 0.2, 0.3]) |
| 754 | |
| 755 | with pytest.raises(ValueError, match=r"All bin edges are NaN."): |
| 756 | dataset.groupby_bins("x", bins=[np.nan, np.nan, np.nan]) |
| 757 | |
| 758 | with pytest.raises(ValueError, match=r"All bin edges are NaN."): |
| 759 | dataset.to_dataarray().groupby_bins("x", bins=[np.nan, np.nan, np.nan]) |
| 760 | |
| 761 | with pytest.raises(ValueError, match=r"Failed to group data."): |
| 762 | dataset.groupby(dataset.foo * np.nan) |
| 763 | |
| 764 | with pytest.raises(ValueError, match=r"Failed to group data."): |
| 765 | dataset.to_dataarray().groupby(dataset.foo * np.nan) |
| 766 | |
| 767 | with pytest.raises(TypeError, match=r"Cannot group by a Grouper object"): |
| 768 | dataset.groupby(UniqueGrouper(labels=[1, 2, 3])) # type: ignore[arg-type] |
| 769 | |
| 770 | with pytest.raises(TypeError, match=r"got multiple values for argument"): |
| 771 | UniqueGrouper(dataset.x, labels=[1, 2, 3]) # type: ignore[misc] |
| 772 | |
| 773 | |
| 774 | def test_groupby_reduce_dimension_error(array) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…