Testing wrapping frames in proxy wrappers
()
| 4967 | |
| 4968 | |
| 4969 | def 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( |
nothing calls this directly
no test coverage detected