@@ -17,14 +17,18 @@ class TestSeriesFormatting(tm.TestCase):
17
17
18
18
_multiprocess_can_split_ = True
19
19
20
+ @property
21
+ def dtype_format_for_platform (self ):
22
+ return '' if use_32bit_repr else ', dtype=int32'
23
+
20
24
def test_sparse_max_row (self ):
21
25
s = pd .Series ([1 , np .nan , np .nan , 3 , np .nan ]).to_sparse ()
22
26
result = repr (s )
23
- dtype = '' if use_32bit_repr else ', dtype=int32'
27
+ dfm = self . dtype_format_for_platform
24
28
exp = ("0 1.0\n 1 NaN\n 2 NaN\n 3 3.0\n "
25
29
"4 NaN\n dtype: float64\n BlockIndex\n "
26
30
"Block locations: array([0, 3]{0})\n "
27
- "Block lengths: array([1, 1]{0})" .format (dtype ))
31
+ "Block lengths: array([1, 1]{0})" .format (dfm ))
28
32
self .assertEqual (result , exp )
29
33
30
34
with option_context ("display.max_rows" , 3 ):
@@ -33,7 +37,7 @@ def test_sparse_max_row(self):
33
37
exp = ("0 1.0\n ... \n 4 NaN\n "
34
38
"dtype: float64\n BlockIndex\n "
35
39
"Block locations: array([0, 3]{0})\n "
36
- "Block lengths: array([1, 1]{0})" .format (dtype ))
40
+ "Block lengths: array([1, 1]{0})" .format (dfm ))
37
41
self .assertEqual (result , exp )
38
42
39
43
def test_sparse_mi_max_row (self ):
@@ -42,19 +46,19 @@ def test_sparse_mi_max_row(self):
42
46
s = pd .Series ([1 , np .nan , np .nan , 3 , np .nan , np .nan ],
43
47
index = idx ).to_sparse ()
44
48
result = repr (s )
45
- dtype = '' if use_32bit_repr else ', dtype=int32'
49
+ dfm = self . dtype_format_for_platform
46
50
exp = ("A 0 1.0\n 1 NaN\n B 0 NaN\n "
47
51
"C 0 3.0\n 1 NaN\n 2 NaN\n "
48
52
"dtype: float64\n BlockIndex\n "
49
- "Block locations: array([0, 3], dtype=int32 )\n "
50
- "Block lengths: array([1, 1]{0})" .format (dtype ))
53
+ "Block locations: array([0, 3]{0} )\n "
54
+ "Block lengths: array([1, 1]{0})" .format (dfm ))
51
55
self .assertEqual (result , exp )
52
56
53
57
with option_context ("display.max_rows" , 3 ):
54
58
# GH 13144
55
59
result = repr (s )
56
60
exp = ("A 0 1.0\n ... \n C 2 NaN\n "
57
61
"dtype: float64\n BlockIndex\n "
58
- "Block locations: array([0, 3], dtype=int32 )\n "
59
- "Block lengths: array([1, 1]{0})" .format (dtype ))
62
+ "Block locations: array([0, 3]{0} )\n "
63
+ "Block lengths: array([1, 1]{0})" .format (dfm ))
60
64
self .assertEqual (result , exp )
0 commit comments