22
33from typing import TYPE_CHECKING
44
5- import pandas as pd
65import pytest
76
87import narwhals as nw
9- import narwhals .stable .v1 as nw_v1
108from narwhals .exceptions import InvalidOperationError
11- from tests .utils import assert_equal_data
129
1310if TYPE_CHECKING :
1411 from tests .utils import Constructor
@@ -29,35 +26,3 @@ def test_order_dependent_raises_in_lazy(constructor: Constructor) -> None:
2926 for agg in ["any" , "all" ]:
3027 with pytest .raises (InvalidOperationError , match = "Order-dependent expressions" ):
3128 lf .select (getattr ((nw .col ("a" ).diff () > 0 ), agg )())
32-
33-
34- def test_dask_order_dependent_ops () -> None :
35- # Preserve these for narwhals.stable.v1, even though they
36- # raise after stable.v1.
37- pytest .importorskip ("dask" )
38- import dask .dataframe as dd
39-
40- df = nw_v1 .from_native (dd .from_pandas (pd .DataFrame ({"a" : [1 , 2 , 3 ]})))
41- result = df .select (
42- a = nw .col ("a" ).cum_sum (),
43- b = nw .col ("a" ).cum_count (),
44- c = nw .col ("a" ).cum_prod (),
45- d = nw .col ("a" ).cum_max (),
46- e = nw .col ("a" ).cum_min (),
47- f = nw .col ("a" ).shift (1 ),
48- g = nw .col ("a" ).diff (),
49- h = nw .col ("a" ).is_first_distinct (),
50- i = nw .col ("a" ).is_last_distinct (),
51- )
52- expected = {
53- "a" : [1 , 3 , 6 ],
54- "b" : [1 , 2 , 3 ],
55- "c" : [1 , 2 , 6 ],
56- "d" : [1 , 2 , 3 ],
57- "e" : [1 , 1 , 1 ],
58- "f" : [None , 1.0 , 2.0 ],
59- "g" : [None , 1.0 , 1.0 ],
60- "h" : [True , True , True ],
61- "i" : [True , True , True ],
62- }
63- assert_equal_data (result , expected )
0 commit comments