Skip to content

Commit 4e4a7d9

Browse files
committed
COMPAT/TST: sparse formatting test for platform, xref #13163
1 parent 62bed0e commit 4e4a7d9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pandas/sparse/tests/test_format.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ class TestSeriesFormatting(tm.TestCase):
1717

1818
_multiprocess_can_split_ = True
1919

20+
@property
21+
def dtype_format_for_platform(self):
22+
return '' if use_32bit_repr else ', dtype=int32'
23+
2024
def test_sparse_max_row(self):
2125
s = pd.Series([1, np.nan, np.nan, 3, np.nan]).to_sparse()
2226
result = repr(s)
23-
dtype = '' if use_32bit_repr else ', dtype=int32'
27+
dfm = self.dtype_format_for_platform
2428
exp = ("0 1.0\n1 NaN\n2 NaN\n3 3.0\n"
2529
"4 NaN\ndtype: float64\nBlockIndex\n"
2630
"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))
2832
self.assertEqual(result, exp)
2933

3034
with option_context("display.max_rows", 3):
@@ -33,7 +37,7 @@ def test_sparse_max_row(self):
3337
exp = ("0 1.0\n ... \n4 NaN\n"
3438
"dtype: float64\nBlockIndex\n"
3539
"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))
3741
self.assertEqual(result, exp)
3842

3943
def test_sparse_mi_max_row(self):
@@ -42,19 +46,19 @@ def test_sparse_mi_max_row(self):
4246
s = pd.Series([1, np.nan, np.nan, 3, np.nan, np.nan],
4347
index=idx).to_sparse()
4448
result = repr(s)
45-
dtype = '' if use_32bit_repr else ', dtype=int32'
49+
dfm = self.dtype_format_for_platform
4650
exp = ("A 0 1.0\n 1 NaN\nB 0 NaN\n"
4751
"C 0 3.0\n 1 NaN\n 2 NaN\n"
4852
"dtype: float64\nBlockIndex\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))
5155
self.assertEqual(result, exp)
5256

5357
with option_context("display.max_rows", 3):
5458
# GH 13144
5559
result = repr(s)
5660
exp = ("A 0 1.0\n ... \nC 2 NaN\n"
5761
"dtype: float64\nBlockIndex\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))
6064
self.assertEqual(result, exp)

0 commit comments

Comments
 (0)