Exemplo n.º 1
0
    def test_constructor(self):
        with tm.assert_produces_warning(FutureWarning):
            lst1 = SparseList(self.na_data[:5])
        with tm.assert_produces_warning(FutureWarning):
            exp = SparseList()

        exp.append(self.na_data[:5])
        tm.assert_sp_list_equal(lst1, exp)
Exemplo n.º 2
0
    def test_constructor(self):
        with tm.assert_produces_warning(FutureWarning):
            lst1 = SparseList(self.na_data[:5])
        with tm.assert_produces_warning(FutureWarning):
            exp = SparseList()

        exp.append(self.na_data[:5])
        tm.assert_sp_list_equal(lst1, exp)
Exemplo n.º 3
0
    def test_append_na(self):
        arr = self.na_data
        splist = SparseList()
        splist.append(arr[:5])
        splist.append(arr[5])
        splist.append(arr[6:])

        sparr = splist.to_array()
        assert_sp_array_equal(sparr, SparseArray(arr))
Exemplo n.º 4
0
    def test_append_zero(self):
        arr = self.zero_data
        splist = SparseList(fill_value=0)
        splist.append(arr[:5])
        splist.append(arr[5])
        splist.append(arr[6:])

        sparr = splist.to_array()
        assert_sp_array_equal(sparr, SparseArray(arr, fill_value=0))
Exemplo n.º 5
0
    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:])

            sparr = splist.to_array()
            tm.assert_sp_array_equal(sparr, SparseArray(arr, fill_value=0))
Exemplo n.º 6
0
    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))
Exemplo n.º 7
0
 def test_len(self):
     arr = self.na_data
     splist = SparseList()
     splist.append(arr[:5])
     self.assertEquals(len(splist), 5)
     splist.append(arr[5])
     self.assertEquals(len(splist), 6)
     splist.append(arr[6:])
     self.assertEquals(len(splist), 10)
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
 def test_len(self):
     with tm.assert_produces_warning(FutureWarning):
         arr = self.na_data
         splist = SparseList()
         splist.append(arr[:5])
         self.assertEqual(len(splist), 5)
         splist.append(arr[5])
         self.assertEqual(len(splist), 6)
         splist.append(arr[6:])
         self.assertEqual(len(splist), 10)
Exemplo n.º 10
0
    def test_getitem(self):
        arr = self.na_data
        splist = SparseList()
        splist.append(arr[:5])
        splist.append(arr[5])
        splist.append(arr[6:])

        for i in range(len(arr)):
            assert_almost_equal(splist[i], arr[i])
            assert_almost_equal(splist[-i], arr[-i])
Exemplo n.º 11
0
    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:])

            sparr = splist.to_array()
            tm.assert_sp_array_equal(sparr, SparseArray(arr, fill_value=0))
Exemplo n.º 12
0
    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))
Exemplo n.º 13
0
    def test_getitem(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:])

            for i in range(len(arr)):
                tm.assert_almost_equal(splist[i], arr[i])
                tm.assert_almost_equal(splist[-i], arr[-i])
Exemplo n.º 14
0
    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)
Exemplo n.º 15
0
 def test_len(self):
     with tm.assert_produces_warning(FutureWarning):
         arr = self.na_data
         splist = SparseList()
         splist.append(arr[:5])
         self.assertEqual(len(splist), 5)
         splist.append(arr[5])
         self.assertEqual(len(splist), 6)
         splist.append(arr[6:])
         self.assertEqual(len(splist), 10)
Exemplo n.º 16
0
    def test_getitem(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:])

            for i in range(len(arr)):
                tm.assert_almost_equal(splist[i], arr[i])
                tm.assert_almost_equal(splist[-i], arr[-i])
Exemplo n.º 17
0
    def test_copy(self):
        arr = self.na_data
        exp_sparr = SparseArray(arr)

        splist = SparseList()
        splist.append(arr[:5])
        splist.append(arr[5])

        cp = splist.copy()
        cp.append(arr[6:])
        self.assertEquals(splist.nchunks, 2)
        assert_sp_array_equal(cp.to_array(), exp_sparr)
Exemplo n.º 18
0
    def test_copy(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])

            cp = splist.copy()
            cp.append(arr[6:])
            self.assertEqual(splist.nchunks, 2)
            tm.assert_sp_array_equal(cp.to_array(), exp_sparr)
Exemplo n.º 19
0
    def test_copy(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])

            cp = splist.copy()
            cp.append(arr[6:])
            self.assertEqual(splist.nchunks, 2)
            tm.assert_sp_array_equal(cp.to_array(), exp_sparr)
Exemplo n.º 20
0
    def test_consolidate(self):
        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)
        self.assertEqual(consol.nchunks, 1)
        self.assertEqual(splist.nchunks, 3)
        assert_sp_array_equal(consol.to_array(), exp_sparr)

        splist.consolidate()
        self.assertEqual(splist.nchunks, 1)
        assert_sp_array_equal(splist.to_array(), exp_sparr)
Exemplo n.º 21
0
 def test_deprecation(self):
     # see gh-13784
     with tm.assert_produces_warning(FutureWarning):
         SparseList()
Exemplo n.º 22
0
    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)
            self.assertEqual(consol.nchunks, 1)
            self.assertEqual(splist.nchunks, 3)
            tm.assert_sp_array_equal(consol.to_array(), exp_sparr)

            splist.consolidate()
            self.assertEqual(splist.nchunks, 1)
            tm.assert_sp_array_equal(splist.to_array(), exp_sparr)
Exemplo n.º 23
0
 def test_constructor(self):
     lst1 = SparseList(self.na_data[:5])
     exp = SparseList()
     exp.append(self.na_data[:5])
     assert_sp_list_equal(lst1, exp)
Exemplo n.º 24
0
    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)
            self.assertEqual(consol.nchunks, 1)
            self.assertEqual(splist.nchunks, 3)
            tm.assert_sp_array_equal(consol.to_array(), exp_sparr)

            splist.consolidate()
            self.assertEqual(splist.nchunks, 1)
            tm.assert_sp_array_equal(splist.to_array(), exp_sparr)