MCPcopy Create free account
hub / github.com/dask/dask / test_use_of_weakref_proxy

Function test_use_of_weakref_proxy

dask/dataframe/tests/test_dataframe.py:4969–4997  ·  view source on GitHub ↗

Testing wrapping frames in proxy wrappers

()

Source from the content-addressed store, hash-verified

4967
4968
4969def test_use_of_weakref_proxy():
4970 """Testing wrapping frames in proxy wrappers"""
4971 df = pd.DataFrame({"data": [1, 2, 3]})
4972 df_pxy = weakref.proxy(df)
4973 ser = pd.Series({"data": [1, 2, 3]})
4974 ser_pxy = weakref.proxy(ser)
4975
4976 assert is_dataframe_like(df_pxy)
4977 assert is_series_like(ser_pxy)
4978
4979 assert dask.dataframe.groupby._cov_chunk(df_pxy, "data")
4980 assert isinstance(
4981 dask.dataframe.groupby._groupby_apply_funcs(df_pxy, "data", funcs=[]),
4982 pd.DataFrame,
4983 )
4984
4985 # Test wrapping each Dask dataframe chunk in a proxy
4986 l = []
4987
4988 def f(x):
4989 l.append(x) # Keep `x` alive
4990 return weakref.proxy(x)
4991
4992 d = pd.DataFrame({"g": [0, 0, 1] * 3, "b": [1, 2, 3] * 3})
4993 a = dd.from_pandas(d, npartitions=1)
4994 a = a.map_partitions(f, meta=a._meta)
4995 pxy = weakref.proxy(a)
4996 res = pxy["b"].groupby(pxy["g"]).sum()
4997 isinstance(res.compute(), pd.Series)
4998
4999
5000@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 6

is_dataframe_likeFunction · 0.90
is_series_likeFunction · 0.90
map_partitionsMethod · 0.45
sumMethod · 0.45
groupbyMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected