MCPcopy Index your code
hub / github.com/dask/dask / test_use_of_weakref_proxy

Function test_use_of_weakref_proxy

dask/dataframe/tests/test_dataframe.py:4951–4979  ·  view source on GitHub ↗

Testing wrapping frames in proxy wrappers

()

Source from the content-addressed store, hash-verified

4949
4950
4951def test_use_of_weakref_proxy():
4952 """Testing wrapping frames in proxy wrappers"""
4953 df = pd.DataFrame({"data": [1, 2, 3]})
4954 df_pxy = weakref.proxy(df)
4955 ser = pd.Series({"data": [1, 2, 3]})
4956 ser_pxy = weakref.proxy(ser)
4957
4958 assert is_dataframe_like(df_pxy)
4959 assert is_series_like(ser_pxy)
4960
4961 assert dask.dataframe.groupby._cov_chunk(df_pxy, "data")
4962 assert isinstance(
4963 dask.dataframe.groupby._groupby_apply_funcs(df_pxy, "data", funcs=[]),
4964 pd.DataFrame,
4965 )
4966
4967 # Test wrapping each Dask dataframe chunk in a proxy
4968 l = []
4969
4970 def f(x):
4971 l.append(x) # Keep `x` alive
4972 return weakref.proxy(x)
4973
4974 d = pd.DataFrame({"g": [0, 0, 1] * 3, "b": [1, 2, 3] * 3})
4975 a = dd.from_pandas(d, npartitions=1)
4976 a = a.map_partitions(f, meta=a._meta)
4977 pxy = weakref.proxy(a)
4978 res = pxy["b"].groupby(pxy["g"]).sum()
4979 isinstance(res.compute(), pd.Series)
4980
4981
4982@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

Used in the wild real call sites across dependent graphs

searching dependent graphs…