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

Function test_groupby_grouping_errors

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

Source from the content-addressed store, hash-verified

741
742
743def 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
774def test_groupby_reduce_dimension_error(array) -> None:

Callers

nothing calls this directly

Calls 4

groupby_binsMethod · 0.95
to_dataarrayMethod · 0.95
groupbyMethod · 0.95
UniqueGrouperClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…