Testing wrapping frames in proxy wrappers
()
| 4949 | |
| 4950 | |
| 4951 | def 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( |
nothing calls this directly
no test coverage detected
searching dependent graphs…