@@ -190,11 +190,6 @@ test_that("%in% works", {
190190 test_df | > filter(Species %in% c(" setosa" , " virginica" ))
191191 )
192192
193- expect_equal_lazy(
194- test_pl | > filter(Species %in% c(" setosa" , " virginica" )),
195- test_df | > filter(Species %in% c(" setosa" , " virginica" ))
196- )
197-
198193 test_df <- tibble(x = c(1 , 2 , 3 ), y = c(1 , 3 , 2 ))
199194 test_pl <- pl $ LazyFrame(x = c(1 , 2 , 3 ), y = c(1 , 3 , 2 ))
200195
@@ -214,6 +209,69 @@ test_that("%in% works with NA", {
214209 )
215210})
216211
212+ test_that(" %notin% works" , {
213+ test_df <- as_tibble(mtcars )
214+ test_pl <- as_polars_lf(test_df )
215+
216+ expect_equal_lazy(
217+ filter(test_pl , cyl %notin % 4 : 5 ),
218+ filter(test_df , cyl %notin % 4 : 5 )
219+ )
220+
221+ expect_equal_lazy(
222+ filter(test_pl , cyl %notin % 4 : 5 & am %notin % 1 ),
223+ filter(test_df , cyl %notin % 4 : 5 & am %notin % 1 )
224+ )
225+
226+ expect_equal_lazy(
227+ filter(test_pl , cyl %notin % 4 : 5 , am %notin % 1 ),
228+ filter(test_df , cyl %notin % 4 : 5 , am %notin % 1 )
229+ )
230+
231+ expect_equal_lazy(
232+ filter(test_pl , cyl %notin % 4 : 5 | am %notin % 1 ),
233+ filter(test_df , cyl %notin % 4 : 5 | am %notin % 1 )
234+ )
235+
236+ expect_equal_lazy(
237+ filter(test_pl , cyl %notin % 4 : 5 , vs == 1 ),
238+ filter(test_df , cyl %notin % 4 : 5 , vs == 1 )
239+ )
240+
241+ expect_equal_lazy(
242+ filter(test_pl , cyl %notin % 4 : 5 | carb == 4 ),
243+ filter(test_df , cyl %notin % 4 : 5 | carb == 4 )
244+ )
245+
246+ test_df <- as_tibble(iris )
247+ # TODO: this shouldn't be necessary
248+ test_df $ Species <- as.character(test_df $ Species )
249+ test_pl <- as_polars_lf(test_df )
250+
251+ expect_equal_lazy(
252+ test_pl | > filter(Species %notin % c(" setosa" , " virginica" )),
253+ test_df | > filter(Species %notin % c(" setosa" , " virginica" ))
254+ )
255+
256+ test_df <- tibble(x = c(1 , 2 , 3 ), y = c(1 , 3 , 2 ))
257+ test_pl <- pl $ LazyFrame(x = c(1 , 2 , 3 ), y = c(1 , 3 , 2 ))
258+
259+ expect_equal_lazy(
260+ test_pl | > filter(x %notin % y ),
261+ test_df | > filter(x %notin % y )
262+ )
263+ })
264+
265+ test_that(" %notin% works with NA" , {
266+ test_df <- tibble(x = c(1 , 2 , NA ))
267+ test_pl <- as_polars_lf(test_df )
268+
269+ expect_equal_lazy(
270+ test_pl | > filter(x %notin % c(1 , NA )),
271+ test_df | > filter(x %notin % c(1 , NA ))
272+ )
273+ })
274+
217275test_that(" between() works" , {
218276 test_df <- as_tibble(iris )
219277 # TODO: this shouldn't be necessary
0 commit comments