Esempio n. 1
0
    def test_index_intersection_c(self) -> None:
        idx1 = Index((10, 20))
        with self.assertRaises(RuntimeError):
            # raises as it identifies labelled data
            _ = idx1.intersection(Series([20, 30]))

        idx2 = idx1.intersection(Series([20, 30]).values)
        self.assertEqual(idx2.values.tolist(), [20])

        idx3 = idx1.intersection([20, 30])
        self.assertEqual(idx3.values.tolist(), [20])
Esempio n. 2
0
    def test_index_intersection_b(self) -> None:

        idx1 = Index(('c', 'b', 'a'))
        idx2 = Index(('c', 'b', 'a'))

        idx3 = idx1.intersection(idx2)
        self.assertEqual(idx3.values.tolist(), ['c', 'b', 'a'])
Esempio n. 3
0
    def test_index_intersection_g(self) -> None:

        idx1 = Index(('c', 'b', 'a'))
        idx2 = Index(('b', 'a', 'r'))
        idx3 = Index(('w', 'b', 'x'))

        idx4 = idx1.intersection(idx2, idx3)
        self.assertEqual(idx4.values.tolist(), ['b'])
Esempio n. 4
0
    def test_index_intersection_a(self) -> None:

        idx1 = Index(('a', 'b', 'c', 'd', 'e'))

        a1 = np.array(['c', 'dd', 'b', 'a'])

        idx2 = idx1.intersection(a1)

        self.assertEqual(idx2.values.tolist(), ['a', 'b', 'c'])
Esempio n. 5
0
    def test_index_intersection_e(self) -> None:

        idx1 = Index((10, 'foo', None, 4.1))
        idx2 = idx1.union(idx1)
        self.assertEqual(id(idx1), id(idx2))
        self.assertTrue(idx1.equals(idx1))

        idx3 = idx1.intersection(idx1)
        self.assertEqual(id(idx1), id(idx3))
        self.assertTrue(idx1.equals(idx3))

        idx4 = idx1.difference(idx1)
        self.assertEqual(len(idx4), 0)
        self.assertEqual(idx4.dtype, np.dtype(object))
Esempio n. 6
0
 def test_index_intersection_d(self) -> None:
     idx1 = Index((10, 20))
     with self.assertRaises(NotImplementedError):
         idx2 = idx1.intersection('b')  #type: ignore
Esempio n. 7
0
 def test_index_intersection_c(self) -> None:
     idx1 = Index((10, 20))
     idx2 = idx1.intersection(Series([20, 30]))
     self.assertEqual(idx2.values.tolist(), [20])
Esempio n. 8
0
 def test_index_intersection_d(self) -> None:
     idx1 = Index((10, 20))
     idx2 = idx1.intersection('b')
     self.assertEqual(len(idx2), 0)