Ejemplo n.º 1
0
def test_node_expandability(basic_tree: Tree, use_normalized_rmsd):
    basic_tree.use_normalized_rmsd = use_normalized_rmsd
    basic_tree.create_root_node()
    parent_node = basic_tree.nodes[0]
    parent_metric = basic_tree.get_metric(parent_node)
    # deactivate relative improvement check
    basic_tree.min_relative_improvement = 1

    node = basic_tree.create_node(0)
    node_metric = parent_metric - 0.5 * basic_tree.min_absolute_improvement
    node.nrmsd = node.rmsd = node_metric
    assert basic_tree.is_expandable(node) is False

    node_metric = parent_metric - 1.5 * basic_tree.min_absolute_improvement
    node.nrmsd = node.rmsd = node_metric
    assert basic_tree.is_expandable(node) is True

    # deactivate absolute improvement check and reactivate relative
    basic_tree.min_absolute_improvement = parent_metric
    basic_tree.min_relative_improvement = 0.1

    node_metric = parent_metric * (1 -
                                   0.5 * basic_tree.min_relative_improvement)
    node.nrmsd = node.rmsd = node_metric
    assert basic_tree.is_expandable(node) is False

    node_metric = parent_metric * (1 -
                                   1.5 * basic_tree.min_relative_improvement)
    node.nrmsd = node.rmsd = node_metric
    assert basic_tree.is_expandable(node) is True
Ejemplo n.º 2
0
def test_tree_expandability(use_normalized_rmsd, basic_tree: Tree):
    basic_tree.use_normalized_rmsd = use_normalized_rmsd
    basic_tree.max_children = 2
    basic_tree.max_depth = 1
    basic_tree.create_root_node()
    node = basic_tree.create_node(0)
    node.rmsd = basic_tree.nodes[0].rmsd + 1
    node.nrmsd = basic_tree.nodes[0].nrmsd + 1
    basic_tree.max_nodes = 1
    assert basic_tree.can_grow() is False
    basic_tree.max_nodes = 500
    assert basic_tree.can_grow()
    node = basic_tree.create_node_from_candidate()
    node.rmsd = basic_tree.nodes[0].rmsd + 1
    node.nrmsd = basic_tree.nodes[0].nrmsd + 1
    assert basic_tree.can_grow() is False
Ejemplo n.º 3
0
def test_tree_has_converged(use_normalized_rmsd, basic_tree: Tree):
    basic_tree.use_normalized_rmsd = use_normalized_rmsd
    basic_tree.create_root_node()
    assert basic_tree.has_converged() is False
    basic_tree.nodes[0].nrmsd = basic_tree.nodes[0].rmsd = 0.2
    assert basic_tree.has_converged() is True