def test_append_na(self): with tm.assert_produces_warning(FutureWarning): arr = self.na_data splist = SparseList() splist.append(arr[:5]) splist.append(arr[5]) splist.append(arr[6:]) sparr = splist.to_array() tm.assert_sp_array_equal(sparr, SparseArray(arr))
def test_append_zero(self): with tm.assert_produces_warning(FutureWarning): arr = self.zero_data splist = SparseList(fill_value=0) splist.append(arr[:5]) splist.append(arr[5]) splist.append(arr[6:]) # list always produces int64, but SA constructor # is platform dtype aware sparr = splist.to_array() exp = SparseArray(arr, fill_value=0) tm.assert_sp_array_equal(sparr, exp, check_dtype=False)
def test_consolidate(self): with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): arr = self.na_data exp_sparr = SparseArray(arr) splist = SparseList() splist.append(arr[:5]) splist.append(arr[5]) splist.append(arr[6:]) consol = splist.consolidate(inplace=False) assert consol.nchunks == 1 assert splist.nchunks == 3 tm.assert_sp_array_equal(consol.to_array(), exp_sparr) splist.consolidate() assert splist.nchunks == 1 tm.assert_sp_array_equal(splist.to_array(), exp_sparr)