35
35
eval_general ,
36
36
indices_keys ,
37
37
indices_values ,
38
- int_arg_keys ,
39
- int_arg_values ,
40
38
name_contains ,
41
39
numeric_dfs ,
42
40
random_state ,
@@ -448,13 +446,17 @@ def test_astype():
448
446
@pytest .mark .parametrize ("errors" , ["raise" , "ignore" ])
449
447
def test_astype_errors (errors ):
450
448
data = {"a" : ["a" , 2 , - 1 ]}
451
- modin_df , pandas_df = pd .DataFrame (data ), pandas .DataFrame (data )
449
+ modin_df , pandas_df = create_test_dfs (data )
450
+ raising_exceptions = None
451
+ if errors == "raise" :
452
+ pytest .xfail (reason = "https://github.com/modin-project/modin/issues/7025" )
452
453
eval_general (
453
454
modin_df ,
454
455
pandas_df ,
455
456
lambda df : df .astype ("int" , errors = errors ),
456
457
# https://github.com/modin-project/modin/issues/5962
457
458
comparator_kwargs = {"check_dtypes" : errors != "ignore" },
459
+ raising_exceptions = raising_exceptions ,
458
460
)
459
461
460
462
@@ -565,8 +567,6 @@ def test_astype_int64_to_astype_category_github_issue_6259():
565
567
index = ["a" , "b" , "c" , "d" , "e" ],
566
568
),
567
569
lambda df : df ["c0" ].astype ("Int64" ).astype ("category" ),
568
- # work around https://github.com/modin-project/modin/issues/6016
569
- raising_exceptions = (Exception ,),
570
570
)
571
571
572
572
@@ -1276,32 +1276,48 @@ def test_dropna_subset(request, data):
1276
1276
@pytest .mark .parametrize ("data" , test_data_values , ids = test_data_keys )
1277
1277
@pytest .mark .parametrize ("axis,subset" , [(0 , list ("EF" )), (1 , [4 , 5 ])])
1278
1278
def test_dropna_subset_error (data , axis , subset ):
1279
- eval_general (* create_test_dfs (data ), lambda df : df .dropna (axis = axis , subset = subset ))
1279
+ eval_general (
1280
+ * create_test_dfs (data ),
1281
+ lambda df : df .dropna (axis = axis , subset = subset ),
1282
+ raising_exceptions = KeyError (["E" , "F" ]),
1283
+ )
1280
1284
1281
1285
1282
1286
@pytest .mark .parametrize ("data" , test_data_values , ids = test_data_keys )
1283
1287
@pytest .mark .parametrize ("astype" , ["category" , "int32" , "float" ])
1284
- def test_insert_dtypes (data , astype ):
1288
+ def test_insert_dtypes (data , astype , request ):
1285
1289
modin_df , pandas_df = pd .DataFrame (data ), pandas .DataFrame (data )
1286
1290
1287
1291
# categories with NaN works incorrect for now
1288
1292
if astype == "category" and pandas_df .iloc [:, 0 ].isnull ().any ():
1289
1293
return
1290
1294
1295
+ raising_exceptions = None
1296
+ if "int32-float_nan_data" in request .node .callspec .id :
1297
+ pytest .xfail (reason = "https://github.com/modin-project/modin/issues/7026" )
1291
1298
eval_insert (
1292
1299
modin_df ,
1293
1300
pandas_df ,
1294
1301
col = "TypeSaver" ,
1295
1302
value = lambda df : df .iloc [:, 0 ].astype (astype ),
1303
+ raising_exceptions = raising_exceptions ,
1296
1304
)
1297
1305
1298
1306
1299
1307
@pytest .mark .parametrize ("data" , test_data_values , ids = test_data_keys )
1300
- @pytest .mark .parametrize ("loc" , int_arg_values , ids = arg_keys ( "loc" , int_arg_keys ) )
1308
+ @pytest .mark .parametrize ("loc" , [ - 3 , 0 , 3 ] )
1301
1309
def test_insert_loc (data , loc ):
1302
1310
modin_df , pandas_df = pd .DataFrame (data ), pandas .DataFrame (data )
1303
-
1304
- eval_insert (modin_df , pandas_df , loc = loc , value = lambda df : df .iloc [:, 0 ])
1311
+ raising_exceptions = None
1312
+ if loc == - 3 :
1313
+ raising_exceptions = ValueError ("unbounded slice" )
1314
+ eval_insert (
1315
+ modin_df ,
1316
+ pandas_df ,
1317
+ loc = loc ,
1318
+ value = lambda df : df .iloc [:, 0 ],
1319
+ raising_exceptions = raising_exceptions ,
1320
+ )
1305
1321
1306
1322
1307
1323
@pytest .mark .parametrize ("data" , test_data_values , ids = test_data_keys )
@@ -1312,18 +1328,14 @@ def test_insert(data):
1312
1328
modin_df , pandas_df , col = "Duplicate" , value = lambda df : df [df .columns [0 ]]
1313
1329
)
1314
1330
eval_insert (modin_df , pandas_df , col = "Scalar" , value = 100 )
1315
- eval_insert (
1316
- pd .DataFrame (columns = list ("ab" )),
1317
- pandas .DataFrame (columns = list ("ab" )),
1318
- col = lambda df : df .columns [0 ],
1319
- value = lambda df : df [df .columns [0 ]],
1320
- )
1321
- eval_insert (
1322
- pd .DataFrame (index = modin_df .index ),
1323
- pandas .DataFrame (index = pandas_df .index ),
1324
- col = lambda df : df .columns [0 ],
1325
- value = lambda df : df [df .columns [0 ]],
1326
- )
1331
+ if StorageFormat .get () != "Hdk" :
1332
+ # FIXME: https://github.com/modin-project/modin/issues/7027
1333
+ eval_insert (
1334
+ pd .DataFrame (columns = list ("ab" )),
1335
+ pandas .DataFrame (columns = list ("ab" )),
1336
+ col = lambda df : df .columns [0 ],
1337
+ value = lambda df : df [df .columns [0 ]],
1338
+ )
1327
1339
eval_insert (
1328
1340
modin_df ,
1329
1341
pandas_df ,
@@ -1358,25 +1370,32 @@ def test_insert(data):
1358
1370
pandas_df ,
1359
1371
col = "Too Short" ,
1360
1372
value = lambda df : list (df [df .columns [0 ]])[:- 1 ],
1373
+ raising_exceptions = ValueError (
1374
+ f"Length of values ({ len (pandas_df )- 1 } ) does not match length of index ({ len (pandas_df )} )"
1375
+ ),
1361
1376
)
1362
1377
eval_insert (
1363
1378
modin_df ,
1364
1379
pandas_df ,
1365
1380
col = lambda df : df .columns [0 ],
1366
1381
value = lambda df : df [df .columns [0 ]],
1382
+ raising_exceptions = ValueError ("cannot insert 2d list insert, already exists" ),
1367
1383
)
1368
1384
eval_insert (
1369
1385
modin_df ,
1370
1386
pandas_df ,
1371
1387
loc = lambda df : len (df .columns ) + 100 ,
1372
1388
col = "Bad Loc" ,
1373
1389
value = 100 ,
1390
+ raising_exceptions = IndexError (
1391
+ f"index { len (pandas_df .columns ) + 100 } is out of bounds for axis 0 with size { len (pandas_df .columns )} "
1392
+ ),
1374
1393
)
1375
1394
1376
1395
1377
1396
def test_insert_4407 ():
1378
1397
data = {"col1" : [1 , 2 , 3 ], "col2" : [2 , 3 , 4 ]}
1379
- modin_df , pandas_df = pd . DataFrame ( data ), pandas . DataFrame (data )
1398
+ modin_df , pandas_df = create_test_dfs (data )
1380
1399
1381
1400
def comparator (df1 , df2 ):
1382
1401
assert_series_equal (df1 .dtypes , df2 .dtypes , check_index = False )
@@ -1385,13 +1404,22 @@ def comparator(df1, df2):
1385
1404
for idx , value in enumerate (
1386
1405
(pandas_df .to_numpy (), np .array ([[1 ]] * 3 ), np .array ([[1 , 2 , 3 ], [4 , 5 , 6 ]]))
1387
1406
):
1407
+ raising_exceptions = None
1408
+ if idx == 0 :
1409
+ raising_exceptions = ValueError (
1410
+ "Expected a 1D array, got an array with shape (3, 2)"
1411
+ )
1412
+ elif idx == 2 :
1413
+ # FIXME: https://github.com/modin-project/modin/issues/7080
1414
+ raising_exceptions = False
1388
1415
eval_insert (
1389
1416
modin_df ,
1390
1417
pandas_df ,
1391
1418
loc = 0 ,
1392
1419
col = f"test_col{ idx } " ,
1393
1420
value = value ,
1394
1421
comparator = lambda df1 , df2 : comparator (df1 , df2 ),
1422
+ raising_exceptions = raising_exceptions ,
1395
1423
)
1396
1424
1397
1425
@@ -1604,7 +1632,9 @@ def test_transpose(data):
1604
1632
def test_update (data , other_data , errors ):
1605
1633
modin_df , pandas_df = create_test_dfs (data )
1606
1634
other_modin_df , other_pandas_df = create_test_dfs (other_data )
1607
-
1635
+ raising_exceptions = None
1636
+ if errors == "raise" :
1637
+ raising_exceptions = ValueError ("Data overlaps." )
1608
1638
eval_general (
1609
1639
modin_df ,
1610
1640
pandas_df ,
@@ -1614,6 +1644,7 @@ def test_update(data, other_data, errors):
1614
1644
else df .update (other_pandas_df , errors = errors )
1615
1645
),
1616
1646
__inplace__ = True ,
1647
+ raising_exceptions = raising_exceptions ,
1617
1648
)
1618
1649
1619
1650
@@ -1633,10 +1664,14 @@ def test___neg__(request, data):
1633
1664
1634
1665
1635
1666
@pytest .mark .parametrize ("data" , test_data_values , ids = test_data_keys )
1636
- def test___invert__ (data ):
1637
- modin_df = pd .DataFrame (data )
1638
- pandas_df = pandas .DataFrame (data )
1639
- eval_general (modin_df , pandas_df , lambda df : ~ df )
1667
+ def test___invert__ (data , request ):
1668
+ raising_exceptions = None
1669
+ if "float_nan_data" in request .node .callspec .id :
1670
+ # FIXME: https://github.com/modin-project/modin/issues/7081
1671
+ raising_exceptions = False
1672
+ eval_general (
1673
+ * create_test_dfs (data ), lambda df : ~ df , raising_exceptions = raising_exceptions
1674
+ )
1640
1675
1641
1676
1642
1677
def test___invert___bool ():
@@ -1648,13 +1683,6 @@ def test___invert___bool():
1648
1683
df_equals (modin_result , pandas_result )
1649
1684
1650
1685
1651
- def test___hash__ ():
1652
- data = test_data_values [0 ]
1653
- pandas_df = pandas .DataFrame (data )
1654
- modin_df = pd .DataFrame (data )
1655
- eval_general (modin_df , pandas_df , hash )
1656
-
1657
-
1658
1686
@pytest .mark .parametrize ("data" , test_data_values , ids = test_data_keys )
1659
1687
def test___delitem__ (request , data ):
1660
1688
modin_df = pd .DataFrame (data )
0 commit comments