22
22
from modin .tests .test_utils import (
23
23
current_execution_is_native ,
24
24
df_or_series_using_native_execution ,
25
- warns_that_defaulting_to_pandas ,
26
25
warns_that_defaulting_to_pandas_if ,
27
26
)
28
27
from modin .utils import get_current_execution
@@ -276,7 +275,9 @@ def test_merge_asof_suffixes():
276
275
right_index = True ,
277
276
suffixes = (False , False ),
278
277
)
279
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
278
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
279
+ not current_execution_is_native ()
280
+ ):
280
281
pd .merge_asof (
281
282
modin_left ,
282
283
modin_right ,
@@ -297,57 +298,79 @@ def test_merge_asof_bad_arguments():
297
298
pandas .merge_asof (
298
299
pandas_left , pandas_right , on = "a" , by = "b" , left_by = "can't do with by"
299
300
)
300
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
301
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
302
+ not current_execution_is_native ()
303
+ ):
301
304
pd .merge_asof (
302
305
modin_left , modin_right , on = "a" , by = "b" , left_by = "can't do with by"
303
306
)
304
307
with pytest .raises (ValueError ):
305
308
pandas .merge_asof (
306
309
pandas_left , pandas_right , by = "b" , on = "a" , right_by = "can't do with by"
307
310
)
308
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
311
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
312
+ not current_execution_is_native ()
313
+ ):
309
314
pd .merge_asof (
310
315
modin_left , modin_right , by = "b" , on = "a" , right_by = "can't do with by"
311
316
)
312
317
313
318
# Can't mix on with left_on/right_on
314
319
with pytest .raises (ValueError ):
315
320
pandas .merge_asof (pandas_left , pandas_right , on = "a" , left_on = "can't do with by" )
316
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
321
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
322
+ not current_execution_is_native ()
323
+ ):
317
324
pd .merge_asof (modin_left , modin_right , on = "a" , left_on = "can't do with by" )
318
325
with pytest .raises (ValueError ):
319
326
pandas .merge_asof (
320
327
pandas_left , pandas_right , on = "a" , right_on = "can't do with by"
321
328
)
322
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
329
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
330
+ not current_execution_is_native ()
331
+ ):
323
332
pd .merge_asof (modin_left , modin_right , on = "a" , right_on = "can't do with by" )
324
333
325
334
# Can't mix left_index with left_on or on, similarly for right.
326
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
335
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
336
+ not current_execution_is_native ()
337
+ ):
327
338
pd .merge_asof (modin_left , modin_right , on = "a" , right_index = True )
328
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
339
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
340
+ not current_execution_is_native ()
341
+ ):
329
342
pd .merge_asof (
330
343
modin_left , modin_right , left_on = "a" , right_on = "a" , right_index = True
331
344
)
332
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
345
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
346
+ not current_execution_is_native ()
347
+ ):
333
348
pd .merge_asof (modin_left , modin_right , on = "a" , left_index = True )
334
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
349
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
350
+ not current_execution_is_native ()
351
+ ):
335
352
pd .merge_asof (
336
353
modin_left , modin_right , left_on = "a" , right_on = "a" , left_index = True
337
354
)
338
355
339
356
# Need both left and right
340
357
with pytest .raises (Exception ): # Pandas bug, didn't validate inputs sufficiently
341
358
pandas .merge_asof (pandas_left , pandas_right , left_on = "a" )
342
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
359
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
360
+ not current_execution_is_native ()
361
+ ):
343
362
pd .merge_asof (modin_left , modin_right , left_on = "a" )
344
363
with pytest .raises (Exception ): # Pandas bug, didn't validate inputs sufficiently
345
364
pandas .merge_asof (pandas_left , pandas_right , right_on = "a" )
346
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
365
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
366
+ not current_execution_is_native ()
367
+ ):
347
368
pd .merge_asof (modin_left , modin_right , right_on = "a" )
348
369
with pytest .raises (ValueError ):
349
370
pandas .merge_asof (pandas_left , pandas_right )
350
- with pytest .raises (ValueError ), warns_that_defaulting_to_pandas ():
371
+ with pytest .raises (ValueError ), warns_that_defaulting_to_pandas_if (
372
+ not current_execution_is_native ()
373
+ ):
351
374
pd .merge_asof (modin_left , modin_right )
352
375
353
376
@@ -386,7 +409,7 @@ def test_merge_asof_merge_options():
386
409
pandas_quotes , pandas_trades = to_pandas (modin_quotes ), to_pandas (modin_trades )
387
410
388
411
# left_by + right_by
389
- with warns_that_defaulting_to_pandas ( ):
412
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
390
413
modin_result = pd .merge_asof (
391
414
modin_quotes ,
392
415
modin_trades ,
@@ -408,7 +431,7 @@ def test_merge_asof_merge_options():
408
431
# Just by:
409
432
pandas_trades ["ticker" ] = pandas_trades ["ticker2" ]
410
433
modin_trades ["ticker" ] = modin_trades ["ticker2" ]
411
- with warns_that_defaulting_to_pandas ( ):
434
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
412
435
modin_result = pd .merge_asof (
413
436
modin_quotes ,
414
437
modin_trades ,
@@ -426,7 +449,7 @@ def test_merge_asof_merge_options():
426
449
)
427
450
428
451
# Tolerance
429
- with warns_that_defaulting_to_pandas ( ):
452
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
430
453
modin_result = pd .merge_asof (
431
454
modin_quotes ,
432
455
modin_trades ,
@@ -446,7 +469,7 @@ def test_merge_asof_merge_options():
446
469
)
447
470
448
471
# Direction
449
- with warns_that_defaulting_to_pandas ( ):
472
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
450
473
modin_result = pd .merge_asof (
451
474
modin_quotes ,
452
475
modin_trades ,
@@ -466,7 +489,7 @@ def test_merge_asof_merge_options():
466
489
)
467
490
468
491
# Allow exact matches
469
- with warns_that_defaulting_to_pandas ( ):
492
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
470
493
modin_result = pd .merge_asof (
471
494
modin_quotes ,
472
495
modin_trades ,
@@ -643,7 +666,7 @@ def test_value_counts(normalize, bins, dropna):
643
666
)
644
667
df_equals (modin_result , pandas_result )
645
668
646
- with warns_that_defaulting_to_pandas ( ):
669
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
647
670
modin_result = sort_index_for_equal_values (
648
671
pd .value_counts (values , bins = bins , ascending = False ), False
649
672
)
@@ -720,7 +743,7 @@ def test_qcut(retbins):
720
743
modin_series = pd .Series (range (10 ))
721
744
pandas_result = pandas .qcut (pandas_series , 4 , retbins = retbins )
722
745
# NOTE that qcut() defaults to pandas at the API layer.
723
- with warns_that_defaulting_to_pandas ( ):
746
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
724
747
modin_result = pd .qcut (modin_series , 4 , retbins = retbins )
725
748
if retbins :
726
749
df_equals (modin_result [0 ], pandas_result [0 ])
@@ -812,7 +835,7 @@ def test_cut_fallback():
812
835
pandas_result = pandas .cut (range (5 ), 4 )
813
836
# note that we default to pandas at the API layer here, so we warn
814
837
# regardless of whether we are on native execution.
815
- with warns_that_defaulting_to_pandas ( ):
838
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
816
839
modin_result = pd .cut (range (5 ), 4 )
817
840
df_equals (modin_result , pandas_result )
818
841
@@ -930,7 +953,7 @@ def test_default_to_pandas_warning_message(func, regex):
930
953
def test_empty_dataframe ():
931
954
df = pd .DataFrame (columns = ["a" , "b" ])
932
955
# NOTE that we default to pandas at the API layer.
933
- with warns_that_defaulting_to_pandas ( ):
956
+ with warns_that_defaulting_to_pandas_if ( not current_execution_is_native () ):
934
957
df [(df .a == 1 ) & (df .b == 2 )]
935
958
936
959
0 commit comments