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

Method test_groupby_fillna

xarray/tests/test_groupby.py:1849–1863  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1847 assert_identical(actual, expected)
1848
1849 def test_groupby_fillna(self) -> None:
1850 a = DataArray([np.nan, 1, np.nan, 3], coords={"x": range(4)}, dims="x")
1851 fill_value = DataArray([0, 1], dims="y")
1852 actual = a.fillna(fill_value)
1853 expected = DataArray(
1854 [[0, 1], [1, 1], [0, 1], [3, 3]], coords={"x": range(4)}, dims=("x", "y")
1855 )
1856 assert_identical(expected, actual)
1857
1858 b = DataArray(range(4), coords={"x": range(4)}, dims="x")
1859 expected = b.copy()
1860 for target in [a, expected]:
1861 target.coords["b"] = ("x", [0, 0, 1, 1])
1862 actual = a.groupby("b").fillna(DataArray([0, 2], dims="b"))
1863 assert_identical(expected, actual)
1864
1865 @pytest.mark.parametrize("use_flox", [True, False])
1866 def test_groupby_fastpath_for_monotonic(self, use_flox: bool) -> None:

Callers

nothing calls this directly

Calls 6

fillnaMethod · 0.95
copyMethod · 0.95
groupbyMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90
fillnaMethod · 0.45

Tested by

no test coverage detected