From cb8616db066a5e6a1f572994a3944864b9148b06 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 11 Mar 2019 11:36:38 +0100 Subject: [PATCH 1/2] TST: fix failing sparse test for scipy master --- pandas/tests/arrays/sparse/test_array.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/tests/arrays/sparse/test_array.py b/pandas/tests/arrays/sparse/test_array.py index 9c13a20726553..61c195430aedd 100644 --- a/pandas/tests/arrays/sparse/test_array.py +++ b/pandas/tests/arrays/sparse/test_array.py @@ -1088,9 +1088,9 @@ def test_get_attributes(self, attr): def test_from_coo(self): sparse = pytest.importorskip("scipy.sparse") - row = [0, 3, 1, 0] - col = [0, 3, 1, 2] - data = [4, 5, 7, 9] + row = np.array([0, 3, 1, 0]) + col = np.array([0, 3, 1, 2]) + data = np.array([4, 5, 7, 9]) sp_array = sparse.coo_matrix(data, (row, col)) result = pd.Series.sparse.from_coo(sp_array) From e61d5a74f22c2b26189b0e0325602805df59abb7 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 11 Mar 2019 11:49:50 +0100 Subject: [PATCH 2/2] actually fix the test --- pandas/tests/arrays/sparse/test_array.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/tests/arrays/sparse/test_array.py b/pandas/tests/arrays/sparse/test_array.py index 61c195430aedd..11b5bcf702e75 100644 --- a/pandas/tests/arrays/sparse/test_array.py +++ b/pandas/tests/arrays/sparse/test_array.py @@ -1088,14 +1088,14 @@ def test_get_attributes(self, attr): def test_from_coo(self): sparse = pytest.importorskip("scipy.sparse") - row = np.array([0, 3, 1, 0]) - col = np.array([0, 3, 1, 2]) - data = np.array([4, 5, 7, 9]) - sp_array = sparse.coo_matrix(data, (row, col)) + row = [0, 3, 1, 0] + col = [0, 3, 1, 2] + data = [4, 5, 7, 9] + sp_array = sparse.coo_matrix((data, (row, col))) result = pd.Series.sparse.from_coo(sp_array) - index = pd.MultiIndex.from_product([[0], [0, 1, 2, 3]]) - expected = pd.Series(data, index=index, dtype='Sparse[int]') + index = pd.MultiIndex.from_arrays([[0, 0, 1, 3], [0, 2, 1, 3]]) + expected = pd.Series([4, 9, 7, 5], index=index, dtype='Sparse[int]') tm.assert_series_equal(result, expected) def test_to_coo(self):