treetime/treeregression.py
def _calculate_averages(self):
        """
        calculate the weighted sums of the tip and branch values and
        their second moments.
        """
        for n in self.tree.get_nonterminals(order='postorder'):
            Q = np.zeros(6, dtype=float)
            for c in n:
                tv = self.tip_value(c)
                bv = self.branch_value(c)
                var = self.branch_variance(c)
                Q += self.propagate_averages(c, tv, bv, var)
            n.Q=Q

        for n in self.tree.find_clades(order='preorder'):
            O = np.zeros(6, dtype=float)
            if n==self.tree.root:
                n.Qtot = n.Q
                continue

            for c in n.up:
                if c==n:
                    continue

                tv = self.tip_value(c)
                bv = self.branch_value(c)
                var = self.branch_variance(c)
                O += self.propagate_averages(c, tv, bv, var)

            if n.up!=self.tree.root:
                c = n.up
                tv = self.tip_value(c)
                bv = self.branch_value(c)
                var = self.branch_variance(c)
                O += self.propagate_averages(c, tv, bv, var, outgroup=True)
            n.O = O

            if not n.is_terminal():
                tv = self.tip_value(n)
                bv = self.branch_value(n)
                var = self.branch_variance(n)
                n.Qtot = n.Q + self.propagate_averages(n, tv, bv, var, outgroup=True)
def _calculate_averages(self):
        for n in self.tree.get_nonterminals(order='postorder'):
            Q = np.zeros(6, dtype=float)
            for c in n:
                tv = self.tip_value(c)
                bv = self.branch_value(c)
                var = self.branch_variance(c)
                Q += self.propagate_averages(c, tv, bv, var)
            n.Q=Q

        for n in self.tree.find_clades(order='preorder'):
            O = np.zeros(6, dtype=float)
            if n==self.tree.root:
                n.Qtot = n.Q
                continue

            for c in n.up:
                if c==n:
                    continue

                tv = self.tip_value(c)
                bv = self.branch_value(c)
                var = self.branch_variance(c)
                O += self.propagate_averages(c, tv, bv, var)

            if n.up!=self.tree.root:
                c = n.up
                tv = self.tip_value(c)
                bv = self.branch_value(c)
                var = self.branch_variance(c)
                O += self.propagate_averages(c, tv, bv, var, outgroup=True)
            n.O = O

            if not n.is_terminal():
                tv = self.tip_value(n)
                bv = self.branch_value(n)
                var = self.branch_variance(n)
                n.Qtot = n.Q + self.propagate_averages(n, tv, bv, var, outgroup=True)
def _calculate_averages ( self ) : for n in self . tree . get_nonterminals ( order = 'postorder' ) : Q = np . zeros ( 6 , dtype = float ) for c in n : tv = self . tip_value ( c ) bv = self . branch_value ( c ) var = self . branch_variance ( c ) Q += self . propagate_averages ( c , tv , bv , var ) n . Q = Q for n in self . tree . find_clades ( order = 'preorder' ) : O = np . zeros ( 6 , dtype = float ) if n == self . tree . root : n . Qtot = n . Q continue for c in n . up : if c == n : continue tv = self . tip_value ( c ) bv = self . branch_value ( c ) var = self . branch_variance ( c ) O += self . propagate_averages ( c , tv , bv , var ) if n . up != self . tree . root : c = n . up tv = self . tip_value ( c ) bv = self . branch_value ( c ) var = self . branch_variance ( c ) O += self . propagate_averages ( c , tv , bv , var , outgroup = True ) n . O = O if not n . is_terminal ( ) : tv = self . tip_value ( n ) bv = self . branch_value ( n ) var = self . branch_variance ( n ) n . Qtot = n . Q + self . propagate_averages ( n , tv , bv , var , outgroup = True )
calculate the weighted sums of the tip and branch values and
        their second moments.
calculate the weighted sums of the tip and branch values and their second moments .