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

Function test_apply_warns

dask/dataframe/tests/test_dataframe.py:2907–2925  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2905
2906
2907def test_apply_warns():
2908 df = pd.DataFrame({"x": [1, 2, 3, 4], "y": [10, 20, 30, 40]})
2909 ddf = dd.from_pandas(df, npartitions=2)
2910
2911 func = lambda row: row["x"] + row["y"]
2912
2913 with pytest.warns(UserWarning) as w:
2914 ddf.apply(func, axis=1)
2915 assert len(w) == 1
2916
2917 with warnings.catch_warnings(record=True) as record:
2918 ddf.apply(func, axis=1, meta=(None, int))
2919 assert not record
2920
2921 with pytest.warns(UserWarning) as w:
2922 ddf.apply(lambda x: x, axis=1)
2923 assert len(w) == 1
2924 assert "'x'" in str(w[0].message)
2925 assert "int64" in str(w[0].message)
2926
2927
2928@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

applyMethod · 0.45

Tested by

no test coverage detected