@@ -1403,69 +1403,17 @@ def test_where_with_int_data(self):
1403
1403
tm .assert_frame_equal (result , dense_expected )
1404
1404
tm .assert_sp_frame_equal (result , sparse_expected )
1405
1405
1406
+ @pytest .mark .parametrize ('other' , [
1407
+ True ,
1408
+ - 100 ,
1409
+ 0.1 ,
1410
+ 100.0 + 100.0j
1411
+ ])
1406
1412
@pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1407
1413
'(GH 17386)' )
1408
- def test_where_with_int_data_and_int_other (self ):
1414
+ def test_where_with_int_data_and_other (self , other ):
1409
1415
# GH 17386
1410
1416
data = [[1 , 1 ], [2 , 2 ], [3 , 3 ], [4 , 4 ], [0 , 0 ]]
1411
- other = - 100
1412
- lower_bound = 2.5
1413
-
1414
- sparse = SparseDataFrame (data )
1415
- result = sparse .where (sparse > lower_bound , other )
1416
-
1417
- dense = DataFrame (data )
1418
- dense_expected = dense .where (dense > lower_bound , other )
1419
- sparse_expected = SparseDataFrame (dense_expected ,
1420
- default_fill_value = other )
1421
-
1422
- tm .assert_frame_equal (result , dense_expected )
1423
- tm .assert_sp_frame_equal (result , sparse_expected )
1424
-
1425
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1426
- '(GH 17386)' )
1427
- def test_where_with_int_data_and_float_other (self ):
1428
- # GH 17386
1429
- data = [[1 , 1 ], [2 , 2 ], [3 , 3 ], [4 , 4 ], [0 , 0 ]]
1430
- other = 0.1
1431
- lower_bound = 2.5
1432
-
1433
- sparse = SparseDataFrame (data )
1434
- result = sparse .where (sparse > lower_bound , other )
1435
-
1436
- dense = DataFrame (data )
1437
- dense_expected = dense .where (dense > lower_bound , other )
1438
- sparse_expected = SparseDataFrame (dense_expected ,
1439
- default_fill_value = other )
1440
-
1441
- tm .assert_frame_equal (result , dense_expected )
1442
- tm .assert_sp_frame_equal (result , sparse_expected )
1443
-
1444
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1445
- '(GH 17386)' )
1446
- def test_where_with_int_data_and_complex_other (self ):
1447
- # GH 17386
1448
- data = [[1 , 1 ], [2 , 2 ], [3 , 3 ], [4 , 4 ], [0 , 0 ]]
1449
- other = 100.0 + 100.0j
1450
- lower_bound = 2.5
1451
-
1452
- sparse = SparseDataFrame (data )
1453
- result = sparse .where (sparse > lower_bound , other )
1454
-
1455
- dense = DataFrame (data )
1456
- dense_expected = dense .where (dense > lower_bound , other )
1457
- sparse_expected = SparseDataFrame (dense_expected ,
1458
- default_fill_value = other )
1459
-
1460
- tm .assert_frame_equal (result , dense_expected )
1461
- tm .assert_sp_frame_equal (result , sparse_expected )
1462
-
1463
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1464
- '(GH 17386)' )
1465
- def test_where_with_int_data_and_bool_other (self ):
1466
- # GH 17386
1467
- data = [[1 , 1 ], [2 , 2 ], [3 , 3 ], [4 , 4 ], [0 , 0 ]]
1468
- other = True
1469
1417
lower_bound = 2.5
1470
1418
1471
1419
sparse = SparseDataFrame (data )
@@ -1496,69 +1444,17 @@ def test_where_with_float_data(self):
1496
1444
tm .assert_frame_equal (result , dense_expected )
1497
1445
tm .assert_sp_frame_equal (result , sparse_expected )
1498
1446
1447
+ @pytest .mark .parametrize ('other' , [
1448
+ True ,
1449
+ 0 ,
1450
+ 0.1 ,
1451
+ 100.0 + 100.0j
1452
+ ])
1499
1453
@pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1500
1454
'(GH 17386)' )
1501
- def test_where_with_float_data_and_int_other (self ):
1502
- # GH 17386
1503
- data = [[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ], [nan , nan ]]
1504
- other = 0
1505
- lower_bound = 2.5
1506
-
1507
- sparse = SparseDataFrame (data )
1508
- result = sparse .where (sparse > lower_bound , other )
1509
-
1510
- dense = DataFrame (data )
1511
- dense_expected = dense .where (dense > lower_bound , other )
1512
- sparse_expected = SparseDataFrame (dense_expected ,
1513
- default_fill_value = other )
1514
-
1515
- tm .assert_frame_equal (result , dense_expected )
1516
- tm .assert_sp_frame_equal (result , sparse_expected )
1517
-
1518
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1519
- '(GH 17386)' )
1520
- def test_where_with_float_data_and_float_other (self ):
1521
- # GH 17386
1522
- data = [[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ], [nan , nan ]]
1523
- other = 0.1
1524
- lower_bound = 2.5
1525
-
1526
- sparse = SparseDataFrame (data )
1527
- result = sparse .where (sparse > lower_bound , other )
1528
-
1529
- dense = DataFrame (data )
1530
- dense_expected = dense .where (dense > lower_bound , other )
1531
- sparse_expected = SparseDataFrame (dense_expected ,
1532
- default_fill_value = other )
1533
-
1534
- tm .assert_frame_equal (result , dense_expected )
1535
- tm .assert_sp_frame_equal (result , sparse_expected )
1536
-
1537
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1538
- '(GH 17386)' )
1539
- def test_where_with_float_data_and_complex_other (self ):
1540
- # GH 17386
1541
- data = [[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ], [nan , nan ]]
1542
- other = 100.0 - 100j
1543
- lower_bound = 2.5
1544
-
1545
- sparse = SparseDataFrame (data )
1546
- result = sparse .where (sparse > lower_bound , other )
1547
-
1548
- dense = DataFrame (data )
1549
- dense_expected = dense .where (dense > lower_bound , other )
1550
- sparse_expected = SparseDataFrame (dense_expected ,
1551
- default_fill_value = other )
1552
-
1553
- tm .assert_frame_equal (result , dense_expected )
1554
- tm .assert_sp_frame_equal (result , sparse_expected )
1555
-
1556
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1557
- '(GH 17386)' )
1558
- def test_where_with_float_data_and_bool_other (self ):
1455
+ def test_where_with_float_data_and_other (self , other ):
1559
1456
# GH 17386
1560
1457
data = [[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ], [nan , nan ]]
1561
- other = True
1562
1458
lower_bound = 2.5
1563
1459
1564
1460
sparse = SparseDataFrame (data )
@@ -1593,39 +1489,21 @@ def test_where_with_complex_data(self):
1593
1489
tm .assert_frame_equal (result , dense_expected )
1594
1490
tm .assert_sp_frame_equal (result , sparse_expected )
1595
1491
1492
+ @pytest .mark .parametrize ('other' , [
1493
+ True ,
1494
+ 0 ,
1495
+ 0.1 ,
1496
+ 100.0 + 100.0j
1497
+ ])
1596
1498
@pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1597
1499
'(GH 17386)' )
1598
- def test_where_with_complex_data_and_int_other (self ):
1599
- # GH 17386
1600
- data = [[1.0 , 1.0 + 1.0j ],
1601
- [2.0 + 2.0j , 2.0 ],
1602
- [3.0 , 3.0 + 3.0j ],
1603
- [4.0 + 4.0j , 4.0 ],
1604
- [nan , nan ]]
1605
- other = 0
1606
- lower_bound = 1.5
1607
-
1608
- sparse = SparseDataFrame (data )
1609
- result = sparse .where (sparse > lower_bound , other )
1610
-
1611
- dense = DataFrame (data )
1612
- dense_expected = dense .where (dense > lower_bound , other )
1613
- sparse_expected = SparseDataFrame (dense_expected ,
1614
- default_fill_value = other )
1615
-
1616
- tm .assert_frame_equal (result , dense_expected )
1617
- tm .assert_sp_frame_equal (result , sparse_expected )
1618
-
1619
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1620
- '(GH 17386)' )
1621
- def test_where_with_complex_data_and_float_other (self ):
1500
+ def test_where_with_complex_data_and_other (self , other ):
1622
1501
# GH 17386
1623
1502
data = [[1.0 , 1.0 + 1.0j ],
1624
1503
[2.0 + 2.0j , 2.0 ],
1625
1504
[3.0 , 3.0 + 3.0j ],
1626
1505
[4.0 + 4.0j , 4.0 ],
1627
1506
[nan , nan ]]
1628
- other = 0.1
1629
1507
lower_bound = 1.5
1630
1508
1631
1509
sparse = SparseDataFrame (data )
@@ -1639,52 +1517,6 @@ def test_where_with_complex_data_and_float_other(self):
1639
1517
tm .assert_frame_equal (result , dense_expected )
1640
1518
tm .assert_sp_frame_equal (result , sparse_expected )
1641
1519
1642
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1643
- '(GH 17386)' )
1644
- def test_where_with_complex_data_and_complex_other (self ):
1645
- # GH 17386
1646
- data = [[1.0 , 1.0 + 1.0j ],
1647
- [2.0 + 2.0j , 2.0 ],
1648
- [3.0 , 3.0 + 3.0j ],
1649
- [4.0 + 4.0j , 4.0 ],
1650
- [nan , nan ]]
1651
- other = 100.0 - 100.0j
1652
- lower_bound = 1.5
1653
-
1654
- sparse = SparseDataFrame (data )
1655
- result = sparse .where (sparse > lower_bound , other )
1656
-
1657
- dense = DataFrame (data )
1658
- dense_expected = dense .where (dense > lower_bound , other )
1659
- sparse_expected = SparseDataFrame (dense_expected ,
1660
- default_fill_value = other )
1661
-
1662
- tm .assert_frame_equal (result , dense_expected )
1663
- tm .assert_sp_frame_equal (result , sparse_expected )
1664
-
1665
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1666
- '(GH 17386)' )
1667
- def test_where_with_complex_data_and_bool_other (self ):
1668
- # GH 17386
1669
- data = [[1.0 , 1.0 + 1.0j ],
1670
- [2.0 + 2.0j , 2.0 ],
1671
- [3.0 , 3.0 + 3.0j ],
1672
- [4.0 + 4.0j , 4.0 ],
1673
- [nan , nan ]]
1674
- other = True
1675
- lower_bound = 2.5
1676
-
1677
- sparse = SparseDataFrame (data )
1678
- result = sparse .where (sparse > lower_bound , other )
1679
-
1680
- dense = DataFrame (data )
1681
- dense_expected = dense .where (dense > lower_bound , other )
1682
- sparse_expected = SparseDataFrame (dense_expected ,
1683
- default_fill_value = other )
1684
-
1685
- tm .assert_frame_equal (result , dense_expected )
1686
- tm .assert_sp_frame_equal (result , sparse_expected )
1687
-
1688
1520
@pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1689
1521
'(GH 17386)' )
1690
1522
def test_where_with_bool_data (self ):
@@ -1702,31 +1534,17 @@ def test_where_with_bool_data(self):
1702
1534
tm .assert_frame_equal (result , dense_expected )
1703
1535
tm .assert_sp_frame_equal (result , sparse_expected )
1704
1536
1537
+ @pytest .mark .parametrize ('other' , [
1538
+ True ,
1539
+ 0 ,
1540
+ 0.1 ,
1541
+ 100.0 + 100.0j
1542
+ ])
1705
1543
@pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1706
1544
'(GH 17386)' )
1707
- def test_where_with_bool_data_and_bool_other (self ):
1708
- # GH 17386
1709
- data = [[False , False ], [True , True ], [False , False ]]
1710
- other = True
1711
- cond = True
1712
-
1713
- sparse = SparseDataFrame (data )
1714
- result = sparse .where (sparse == cond , other )
1715
-
1716
- dense = DataFrame (data )
1717
- dense_expected = dense .where (dense == cond , other )
1718
- sparse_expected = SparseDataFrame (dense_expected ,
1719
- default_fill_value = other )
1720
-
1721
- tm .assert_frame_equal (result , dense_expected )
1722
- tm .assert_sp_frame_equal (result , sparse_expected )
1723
-
1724
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1725
- '(GH 17386)' )
1726
- def test_where_with_bool_data_and_complex_other (self ):
1545
+ def test_where_with_bool_data_and_other (self , other ):
1727
1546
# GH 17386
1728
1547
data = [[False , False ], [True , True ], [False , False ]]
1729
- other = 100.0 + 100.0j
1730
1548
cond = True
1731
1549
1732
1550
sparse = SparseDataFrame (data )
0 commit comments