示例#1
0
    def test_mean(self):
        rhtype = RateHetType.GAMMA_EQ_CAT_MEAN
        rhm = RateHetManager(shape=0.5, num_categories=4, rate_het_type=rhtype)
        expected = [0.03338775, 0.25191592, 0.82026848, 2.89442785]
        assert_list_eq(self, rhm.rates, expected)
        self.assertEqual(rhm.num_categories, 4)
        self.assertTrue(abs(rhm.shape - 0.5) < 1.0e-5)

        rhm.set_shape(4.2)
        expected = [0.46502269, 0.78185321, 1.08432009, 1.66880400]
        assert_list_eq(self, rhm.rates, expected)
        self.assertEqual(rhm.num_categories, 4)
        self.assertEqual(rhm.shape, 4.2)
        self.assertTrue(abs(rhm.shape - 4.2) < 1.0e-5)

        rhm = RateHetManager(shape=0.53, num_categories=10, rate_het_type=rhtype)
        expected = [
            0.00680095,
            0.04407109,
            0.11615143,
            0.22625412,
            0.38203227,
            0.59769745,
            0.90010946,
            1.34639481,
            2.09367223,
            4.28681618,
        ]
        assert_list_eq(self, rhm.rates, expected)
        self.assertEqual(rhm.num_categories, 10)
        self.assertTrue(abs(rhm.shape - 0.53) < 1.0e-5)
示例#2
0
    def test_median(self):
        rhtype = RateHetType.GAMMA_EQ_CAT_MEDIAN
        rhm = RateHetManager(shape=0.5, num_categories=4, rate_het_type=rhtype)
        expected = [0.02907775, 0.28071453, 0.92477307, 2.76543465]
        assert_list_eq(self, rhm.rates, expected)

        rhm.set_shape(4.2)
        expected = [0.49655820, 0.79929783, 1.10263121, 1.60151276]
        assert_list_eq(self, rhm.rates, expected)
示例#3
0
 def test_hashing(self):
     rhm = RateHetManager(shape=0.5, num_categories=4, rate_het_type=RateHetType.GAMMA_EQ_CAT_MEAN)
     h1 = rhm.state_hash
     rhm.shape = 0.6
     h2 = rhm.state_hash
     self.assertNotEqual(h1, h2)