34
34
generate_multiindex ,
35
35
random_state ,
36
36
rotate_decimal_digits_or_symbols ,
37
+ sort_if_range_partitioning ,
37
38
test_data ,
38
39
test_data_keys ,
39
40
test_data_values ,
@@ -247,10 +248,6 @@ def test_join_6602():
247
248
],
248
249
)
249
250
def test_merge (test_data , test_data2 ):
250
- # RangePartitioning merge always produces sorted result, so we have to sort
251
- # pandas' result as well in order them to match
252
- comparator = df_equals_and_sort if RangePartitioning .get () else df_equals
253
-
254
251
modin_df = pd .DataFrame (
255
252
test_data ,
256
253
columns = ["col{}" .format (i ) for i in range (test_data .shape [1 ])],
@@ -283,7 +280,7 @@ def test_merge(test_data, test_data2):
283
280
pandas_result = pandas_df .merge (
284
281
pandas_df2 , how = hows [i ], on = ons [j ], sort = sorts [j ]
285
282
)
286
- comparator (modin_result , pandas_result )
283
+ sort_if_range_partitioning (modin_result , pandas_result )
287
284
288
285
modin_result = modin_df .merge (
289
286
modin_df2 ,
@@ -299,7 +296,7 @@ def test_merge(test_data, test_data2):
299
296
right_on = "key" ,
300
297
sort = sorts [j ],
301
298
)
302
- comparator (modin_result , pandas_result )
299
+ sort_if_range_partitioning (modin_result , pandas_result )
303
300
304
301
# Test for issue #1771
305
302
modin_df = pd .DataFrame ({"name" : np .arange (40 )})
@@ -308,7 +305,7 @@ def test_merge(test_data, test_data2):
308
305
pandas_df2 = pandas .DataFrame ({"name" : [39 ], "position" : [0 ]})
309
306
modin_result = modin_df .merge (modin_df2 , on = "name" , how = "inner" )
310
307
pandas_result = pandas_df .merge (pandas_df2 , on = "name" , how = "inner" )
311
- comparator (modin_result , pandas_result )
308
+ sort_if_range_partitioning (modin_result , pandas_result )
312
309
313
310
frame_data = {
314
311
"col1" : [0 , 1 , 2 , 3 ],
@@ -329,7 +326,7 @@ def test_merge(test_data, test_data2):
329
326
# Defaults
330
327
modin_result = modin_df .merge (modin_df2 , how = how )
331
328
pandas_result = pandas_df .merge (pandas_df2 , how = how )
332
- comparator (modin_result , pandas_result )
329
+ sort_if_range_partitioning (modin_result , pandas_result )
333
330
334
331
# left_on and right_index
335
332
modin_result = modin_df .merge (
@@ -338,7 +335,7 @@ def test_merge(test_data, test_data2):
338
335
pandas_result = pandas_df .merge (
339
336
pandas_df2 , how = how , left_on = "col1" , right_index = True
340
337
)
341
- comparator (modin_result , pandas_result )
338
+ sort_if_range_partitioning (modin_result , pandas_result )
342
339
343
340
# left_index and right_on
344
341
modin_result = modin_df .merge (
@@ -347,7 +344,7 @@ def test_merge(test_data, test_data2):
347
344
pandas_result = pandas_df .merge (
348
345
pandas_df2 , how = how , left_index = True , right_on = "col1"
349
346
)
350
- comparator (modin_result , pandas_result )
347
+ sort_if_range_partitioning (modin_result , pandas_result )
351
348
352
349
# left_on and right_on col1
353
350
modin_result = modin_df .merge (
@@ -356,7 +353,7 @@ def test_merge(test_data, test_data2):
356
353
pandas_result = pandas_df .merge (
357
354
pandas_df2 , how = how , left_on = "col1" , right_on = "col1"
358
355
)
359
- comparator (modin_result , pandas_result )
356
+ sort_if_range_partitioning (modin_result , pandas_result )
360
357
361
358
# left_on and right_on col2
362
359
modin_result = modin_df .merge (
@@ -365,7 +362,7 @@ def test_merge(test_data, test_data2):
365
362
pandas_result = pandas_df .merge (
366
363
pandas_df2 , how = how , left_on = "col2" , right_on = "col2"
367
364
)
368
- comparator (modin_result , pandas_result )
365
+ sort_if_range_partitioning (modin_result , pandas_result )
369
366
370
367
# left_index and right_index
371
368
modin_result = modin_df .merge (
@@ -374,7 +371,7 @@ def test_merge(test_data, test_data2):
374
371
pandas_result = pandas_df .merge (
375
372
pandas_df2 , how = how , left_index = True , right_index = True
376
373
)
377
- comparator (modin_result , pandas_result )
374
+ sort_if_range_partitioning (modin_result , pandas_result )
378
375
379
376
# Cannot merge a Series without a name
380
377
ps = pandas .Series (frame_data2 .get ("col1" ))
@@ -383,7 +380,7 @@ def test_merge(test_data, test_data2):
383
380
modin_df ,
384
381
pandas_df ,
385
382
lambda df : df .merge (ms if isinstance (df , pd .DataFrame ) else ps ),
386
- comparator = comparator ,
383
+ comparator = sort_if_range_partitioning ,
387
384
expected_exception = ValueError ("Cannot merge a Series without a name" ),
388
385
)
389
386
@@ -394,7 +391,7 @@ def test_merge(test_data, test_data2):
394
391
modin_df ,
395
392
pandas_df ,
396
393
lambda df : df .merge (ms if isinstance (df , pd .DataFrame ) else ps ),
397
- comparator = comparator ,
394
+ comparator = sort_if_range_partitioning ,
398
395
)
399
396
400
397
with pytest .raises (TypeError ):
0 commit comments