

def construct(self, total_leaves):
    depth = (np.log(total_leaves) / np.log(2))
    assert depth.is_integer(), 'The total leaves must be a power of two'
    queue = [HAMNode(tree=self, left=None, right=None) for leaf in xrange(total_leaves)]
    self.leaves = [leaf for leaf in queue]
    self.nodes = [leaf for leaf in queue]
    while (len(queue) > 1):
        (l, r) = (queue.pop(0), queue.pop(0))
        node = HAMNode(tree=self, left=l, right=r)
        queue.append(node)
        self.nodes.append(node)
    self.root = queue[0]

dataset/ETHPy150Open Smerity/tf-ham/ham.py HAMTree.construct/original