Skip to content

Commit 59524af

Browse files
authored
TST: sparse / dummy array comparisons on windows, xref #14140 (#14141)
1 parent 752ba9a commit 59524af

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

pandas/sparse/tests/test_list.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ def test_append_zero(self):
6060
splist.append(arr[5])
6161
splist.append(arr[6:])
6262

63+
# list always produces int64, but SA constructor
64+
# is platform dtype aware
6365
sparr = splist.to_array()
64-
tm.assert_sp_array_equal(sparr, SparseArray(arr, fill_value=0))
66+
exp = SparseArray(arr, fill_value=0)
67+
tm.assert_sp_array_equal(sparr, exp, check_dtype=False)
6568

6669
def test_consolidate(self):
6770
with tm.assert_produces_warning(FutureWarning,

pandas/tests/test_reshape.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def test_dataframe_dummies_prefix_str(self):
323323
[3, 1, 0, 0, 1]],
324324
columns=['C', 'bad_a', 'bad_b', 'bad_b', 'bad_c'],
325325
dtype=np.uint8)
326-
expected = expected.astype({"C": np.int})
326+
expected = expected.astype({"C": np.int64})
327327
assert_frame_equal(result, expected)
328328

329329
def test_dataframe_dummies_subset(self):

pandas/util/testing.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -1385,11 +1385,22 @@ def assert_panelnd_equal(left, right,
13851385
# Sparse
13861386

13871387

1388-
def assert_sp_array_equal(left, right):
1388+
def assert_sp_array_equal(left, right, check_dtype=True):
1389+
"""Check that the left and right SparseArray are equal.
1390+
1391+
Parameters
1392+
----------
1393+
left : SparseArray
1394+
right : SparseArray
1395+
check_dtype : bool, default True
1396+
Whether to check the data dtype is identical.
1397+
"""
1398+
13891399
assertIsInstance(left, pd.SparseArray, '[SparseArray]')
13901400
assertIsInstance(right, pd.SparseArray, '[SparseArray]')
13911401

1392-
assert_numpy_array_equal(left.sp_values, right.sp_values)
1402+
assert_numpy_array_equal(left.sp_values, right.sp_values,
1403+
check_dtype=check_dtype)
13931404

13941405
# SparseIndex comparison
13951406
assertIsInstance(left.sp_index, pd._sparse.SparseIndex, '[SparseIndex]')
@@ -1400,8 +1411,10 @@ def assert_sp_array_equal(left, right):
14001411
left.sp_index, right.sp_index)
14011412

14021413
assert_attr_equal('fill_value', left, right)
1403-
assert_attr_equal('dtype', left, right)
1404-
assert_numpy_array_equal(left.values, right.values)
1414+
if check_dtype:
1415+
assert_attr_equal('dtype', left, right)
1416+
assert_numpy_array_equal(left.values, right.values,
1417+
check_dtype=check_dtype)
14051418

14061419

14071420
def assert_sp_series_equal(left, right, check_dtype=True, exact_indices=True,

0 commit comments

Comments
 (0)