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:4990–5018  ·  view source on GitHub ↗

Testing wrapping frames in proxy wrappers

()

Source from the content-addressed store, hash-verified

4988
4989
4990def test_use_of_weakref_proxy():
4991 """Testing wrapping frames in proxy wrappers"""
4992 df = pd.DataFrame({"data": [1, 2, 3]})
4993 df_pxy = weakref.proxy(df)
4994 ser = pd.Series({"data": [1, 2, 3]})
4995 ser_pxy = weakref.proxy(ser)
4996
4997 assert is_dataframe_like(df_pxy)
4998 assert is_series_like(ser_pxy)
4999
5000 assert dask.dataframe.groupby._cov_chunk(df_pxy, "data")
5001 assert isinstance(
5002 dask.dataframe.groupby._groupby_apply_funcs(df_pxy, "data", funcs=[]),
5003 pd.DataFrame,
5004 )
5005
5006 # Test wrapping each Dask dataframe chunk in a proxy
5007 l = []
5008
5009 def f(x):
5010 l.append(x) # Keep `x` alive
5011 return weakref.proxy(x)
5012
5013 d = pd.DataFrame({"g": [0, 0, 1] * 3, "b": [1, 2, 3] * 3})
5014 a = dd.from_pandas(d, npartitions=1)
5015 a = a.map_partitions(f, meta=a._meta)
5016 pxy = weakref.proxy(a)
5017 res = pxy["b"].groupby(pxy["g"]).sum()
5018 isinstance(res.compute(), pd.Series)
5019
5020
5021@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