Ejemplo n.º 1
0
    def test_random_with_replace(self):
        """Random: test random indexing with replacement"""

        # situation 1: linking
        index_cl1 = Random(n=1000, replace=True, random_state=100)

        pairs1 = index_cl1.index((self.a, self.b))
        assert len(pairs1) == 1000
        assert not pairs1.is_unique

        # situation 2: dedup
        index_cl2 = Random(n=1000, replace=True, random_state=101)

        pairs2 = index_cl2.index(self.a)
        assert len(pairs2) == 1000
        assert not pairs2.is_unique
Ejemplo n.º 2
0
    def test_random_with_replace(self):
        """Random: test random indexing with replacement"""

        # situation 1: linking
        index_cl1 = Random(n=1000, replace=True, random_state=100)

        pairs1 = index_cl1.index((self.a, self.b))
        self.assertEqual(len(pairs1), 1000)
        self.assertFalse(pairs1.is_unique)

        # situation 2: dedup
        index_cl2 = Random(n=1000, replace=True, random_state=101)

        pairs2 = index_cl2.index(self.a)
        self.assertEqual(len(pairs2), 1000)
        self.assertFalse(pairs2.is_unique)
Ejemplo n.º 3
0
    def test_random_seed(self):
        """Random: test seeding random algorithm"""

        # TEST IDENTICAL
        index_cl1 = Random(n=1000, random_state=100)
        index_cl2 = Random(n=1000, random_state=100)
        index_cl3 = Random(n=1000, random_state=101)

        pairs1 = index_cl1.index((self.a, self.b))
        pairs2 = index_cl2.index((self.a, self.b))
        pairs3 = index_cl3.index((self.a, self.b))

        # are pairs1 and pairs2 indentical?
        ptm.assert_index_equal(pairs1, pairs2)

        # are pairs1 and pairs3 not indentical? # numpy workaround
        assert not np.array_equal(pairs1.values, pairs3.values)