Skip to content

Commit b8b4512

Browse files
committed
TST: separate out skips for sparseseries indexing
1 parent 88449c0 commit b8b4512

File tree

2 files changed

+113
-102
lines changed

2 files changed

+113
-102
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import pytest
2+
import numpy as np
3+
from pandas import SparseSeries, Series
4+
from pandas.util import testing as tm
5+
6+
7+
pytestmark = pytest.mark.skip("Wrong SparseBlock initialization (GH 17386)")
8+
9+
10+
@pytest.mark.parametrize('data', [
11+
[1, 1, 2, 2, 3, 3, 4, 4, 0, 0],
12+
[1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, np.nan, np.nan],
13+
[
14+
1.0, 1.0 + 1.0j,
15+
2.0 + 2.0j, 2.0,
16+
3.0, 3.0 + 3.0j,
17+
4.0 + 4.0j, 4.0,
18+
np.nan, np.nan
19+
]
20+
])
21+
@pytest.mark.xfail(reason='Wrong SparseBlock initialization '
22+
'(GH 17386)')
23+
def test_where_with_numeric_data(data):
24+
# GH 17386
25+
lower_bound = 1.5
26+
27+
sparse = SparseSeries(data)
28+
result = sparse.where(sparse > lower_bound)
29+
30+
dense = Series(data)
31+
dense_expected = dense.where(dense > lower_bound)
32+
sparse_expected = SparseSeries(dense_expected)
33+
34+
tm.assert_series_equal(result, dense_expected)
35+
tm.assert_sp_series_equal(result, sparse_expected)
36+
37+
38+
@pytest.mark.parametrize('data', [
39+
[1, 1, 2, 2, 3, 3, 4, 4, 0, 0],
40+
[1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, np.nan, np.nan],
41+
[
42+
1.0, 1.0 + 1.0j,
43+
2.0 + 2.0j, 2.0,
44+
3.0, 3.0 + 3.0j,
45+
4.0 + 4.0j, 4.0,
46+
np.nan, np.nan
47+
]
48+
])
49+
@pytest.mark.parametrize('other', [
50+
True,
51+
-100,
52+
0.1,
53+
100.0 + 100.0j
54+
])
55+
@pytest.mark.skip(reason='Wrong SparseBlock initialization '
56+
'(Segfault) '
57+
'(GH 17386)')
58+
def test_where_with_numeric_data_and_other(data, other):
59+
# GH 17386
60+
lower_bound = 1.5
61+
62+
sparse = SparseSeries(data)
63+
result = sparse.where(sparse > lower_bound, other)
64+
65+
dense = Series(data)
66+
dense_expected = dense.where(dense > lower_bound, other)
67+
sparse_expected = SparseSeries(dense_expected, fill_value=other)
68+
69+
tm.assert_series_equal(result, dense_expected)
70+
tm.assert_sp_series_equal(result, sparse_expected)
71+
72+
73+
@pytest.mark.xfail(reason='Wrong SparseBlock initialization '
74+
'(GH 17386)')
75+
def test_where_with_bool_data():
76+
# GH 17386
77+
data = [False, False, True, True, False, False]
78+
cond = True
79+
80+
sparse = SparseSeries(data)
81+
result = sparse.where(sparse == cond)
82+
83+
dense = Series(data)
84+
dense_expected = dense.where(dense == cond)
85+
sparse_expected = SparseSeries(dense_expected)
86+
87+
tm.assert_series_equal(result, dense_expected)
88+
tm.assert_sp_series_equal(result, sparse_expected)
89+
90+
91+
@pytest.mark.parametrize('other', [
92+
True,
93+
0,
94+
0.1,
95+
100.0 + 100.0j
96+
])
97+
@pytest.mark.skip(reason='Wrong SparseBlock initialization '
98+
'(Segfault) '
99+
'(GH 17386)')
100+
def test_where_with_bool_data_and_other(other):
101+
# GH 17386
102+
data = [False, False, True, True, False, False]
103+
cond = True
104+
105+
sparse = SparseSeries(data)
106+
result = sparse.where(sparse == cond, other)
107+
108+
dense = Series(data)
109+
dense_expected = dense.where(dense == cond, other)
110+
sparse_expected = SparseSeries(dense_expected, fill_value=other)
111+
112+
tm.assert_series_equal(result, dense_expected)
113+
tm.assert_sp_series_equal(result, sparse_expected)

pandas/tests/sparse/series/test_series.py

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,108 +1419,6 @@ def test_deprecated_reindex_axis(self):
14191419
self.bseries.reindex_axis([0, 1, 2])
14201420
assert 'reindex' in str(m[0].message)
14211421

1422-
@pytest.mark.parametrize('data', [
1423-
[1, 1, 2, 2, 3, 3, 4, 4, 0, 0],
1424-
[1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, nan, nan],
1425-
[
1426-
1.0, 1.0 + 1.0j,
1427-
2.0 + 2.0j, 2.0,
1428-
3.0, 3.0 + 3.0j,
1429-
4.0 + 4.0j, 4.0,
1430-
nan, nan
1431-
]
1432-
])
1433-
@pytest.mark.xfail(reason='Wrong SparseBlock initialization '
1434-
'(GH 17386)')
1435-
def test_where_with_numeric_data(self, data):
1436-
# GH 17386
1437-
lower_bound = 1.5
1438-
1439-
sparse = SparseSeries(data)
1440-
result = sparse.where(sparse > lower_bound)
1441-
1442-
dense = Series(data)
1443-
dense_expected = dense.where(dense > lower_bound)
1444-
sparse_expected = SparseSeries(dense_expected)
1445-
1446-
tm.assert_series_equal(result, dense_expected)
1447-
tm.assert_sp_series_equal(result, sparse_expected)
1448-
1449-
@pytest.mark.parametrize('data', [
1450-
[1, 1, 2, 2, 3, 3, 4, 4, 0, 0],
1451-
[1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, nan, nan],
1452-
[
1453-
1.0, 1.0 + 1.0j,
1454-
2.0 + 2.0j, 2.0,
1455-
3.0, 3.0 + 3.0j,
1456-
4.0 + 4.0j, 4.0,
1457-
nan, nan
1458-
]
1459-
])
1460-
@pytest.mark.parametrize('other', [
1461-
True,
1462-
-100,
1463-
0.1,
1464-
100.0 + 100.0j
1465-
])
1466-
@pytest.mark.skip(reason='Wrong SparseBlock initialization '
1467-
'(Segfault) '
1468-
'(GH 17386)')
1469-
def test_where_with_numeric_data_and_other(self, data, other):
1470-
# GH 17386
1471-
lower_bound = 1.5
1472-
1473-
sparse = SparseSeries(data)
1474-
result = sparse.where(sparse > lower_bound, other)
1475-
1476-
dense = Series(data)
1477-
dense_expected = dense.where(dense > lower_bound, other)
1478-
sparse_expected = SparseSeries(dense_expected, fill_value=other)
1479-
1480-
tm.assert_series_equal(result, dense_expected)
1481-
tm.assert_sp_series_equal(result, sparse_expected)
1482-
1483-
@pytest.mark.xfail(reason='Wrong SparseBlock initialization '
1484-
'(GH 17386)')
1485-
def test_where_with_bool_data(self):
1486-
# GH 17386
1487-
data = [False, False, True, True, False, False]
1488-
cond = True
1489-
1490-
sparse = SparseSeries(data)
1491-
result = sparse.where(sparse == cond)
1492-
1493-
dense = Series(data)
1494-
dense_expected = dense.where(dense == cond)
1495-
sparse_expected = SparseSeries(dense_expected)
1496-
1497-
tm.assert_series_equal(result, dense_expected)
1498-
tm.assert_sp_series_equal(result, sparse_expected)
1499-
1500-
@pytest.mark.parametrize('other', [
1501-
True,
1502-
0,
1503-
0.1,
1504-
100.0 + 100.0j
1505-
])
1506-
@pytest.mark.skip(reason='Wrong SparseBlock initialization '
1507-
'(Segfault) '
1508-
'(GH 17386)')
1509-
def test_where_with_bool_data_and_other(self, other):
1510-
# GH 17386
1511-
data = [False, False, True, True, False, False]
1512-
cond = True
1513-
1514-
sparse = SparseSeries(data)
1515-
result = sparse.where(sparse == cond, other)
1516-
1517-
dense = Series(data)
1518-
dense_expected = dense.where(dense == cond, other)
1519-
sparse_expected = SparseSeries(dense_expected, fill_value=other)
1520-
1521-
tm.assert_series_equal(result, dense_expected)
1522-
tm.assert_sp_series_equal(result, sparse_expected)
1523-
15241422

15251423
@pytest.mark.parametrize(
15261424
'datetime_type', (np.datetime64,

0 commit comments

Comments
 (0)