Ejemplo n.º 1
0
def test_create_tree_exception_1():
    adj = csr_matrix(
        ([1] * 9, ([0, 0, 1, 1, 2, 3, 4, 5, 0], [1, 2, 3, 4, 5, 6, 7, 8, 4])),
        shape=(9, 9),
    )
    with raises(ValueError):
        Tree(adj, 0)
Ejemplo n.º 2
0
    def __init__(self,
                 adjacency_array_appearance=None,
                 gaussian_per_patch=True,
                 adjacency_array_deformation=None,
                 root_vertex_deformation=None,
                 adjacency_array_shape=None,
                 features=no_op,
                 patch_shape=(17, 17),
                 normalization_diagonal=None,
                 n_levels=2,
                 downscale=2,
                 scaled_shape_models=False,
                 use_procrustes=True,
                 max_shape_components=None,
                 n_appearance_parameters=None):
        # check parameters
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)
        checks.check_normalization_diagonal(normalization_diagonal)
        max_shape_components = checks.check_max_components(
            max_shape_components, n_levels, 'max_shape_components')
        features = checks.check_features(features, n_levels)
        n_appearance_parameters = _check_n_parameters(
            n_appearance_parameters, n_levels, 'n_appearance_parameters')

        # appearance graph
        if adjacency_array_appearance is None:
            self.graph_appearance = None
        elif adjacency_array_appearance == 'yorgos':
            self.graph_appearance = 'yorgos'
        else:
            self.graph_appearance = UndirectedGraph(adjacency_array_appearance)

        # shape graph
        if adjacency_array_shape is None:
            self.graph_shape = None
        else:
            self.graph_shape = UndirectedGraph(adjacency_array_shape)

        # check adjacency_array_deformation, root_vertex_deformation
        if adjacency_array_deformation is None:
            self.graph_deformation = None
            if root_vertex_deformation is None:
                self.root_vertex = 0
        else:
            if root_vertex_deformation is None:
                self.graph_deformation = DirectedGraph(
                    adjacency_array_deformation)
            else:
                self.graph_deformation = Tree(adjacency_array_deformation,
                                              root_vertex_deformation)

        # store parameters
        self.features = features
        self.patch_shape = patch_shape
        self.normalization_diagonal = normalization_diagonal
        self.n_levels = n_levels
        self.downscale = downscale
        self.scaled_shape_models = scaled_shape_models
        self.max_shape_components = max_shape_components
        self.n_appearance_parameters = n_appearance_parameters
        self.use_procrustes = use_procrustes
        self.gaussian_per_patch = gaussian_per_patch
Ejemplo n.º 3
0
def test_create_tree_exception_2():
    with raises(ValueError):
        Tree(adj_tree, 20)
Ejemplo n.º 4
0
def test_create_tree_exception_3():
    adj = csr_matrix(
        ([1] * 8, ([0, 0, 1, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 7, 8])), shape=(10, 10)
    )
    with raises(ValueError):
        Tree(adj, 0)
Ejemplo n.º 5
0
# Define tree and pointtree
adj_tree = np.array(
    [
        [0, 1, 1, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 1, 1, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 1, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 1, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 1, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 1],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
    ]
)
g_tree = Tree(adj_tree, 0)
pg_tree = PointTree(points2, adj_tree, 0)

# Define undirected graph and pointgraph with isolated vertices
adj_isolated = csr_matrix(
    ([1] * 6, ([0, 2, 2, 4, 3, 4], [2, 0, 4, 2, 4, 3])), shape=(6, 6)
)
g_isolated = UndirectedGraph(adj_isolated)
pg_isolated = PointUndirectedGraph(points, adj_isolated)

# Define undirected graph and pointgraph with a single vertex
adj_single = np.array([[0]])
g_single = DirectedGraph(adj_single)
pg_single = PointDirectedGraph(point, adj_single)

Ejemplo n.º 6
0
def test_create_tree_exception_3():
    adj = csr_matrix(
        ([1] * 8, ([0, 0, 1, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 7, 8])),
        shape=(10, 10))
    Tree(adj, 0)
Ejemplo n.º 7
0
def test_create_tree_exception_2():
    Tree(adj_tree, 20)
Ejemplo n.º 8
0
def test_create_tree_exception_1():
    adj = csr_matrix(
        ([1] * 8, ([0, 0, 1, 1, 2, 3, 4, 5, 0], [1, 2, 3, 4, 5, 6, 7, 8, 4])),
        shape=(9, 9))
    Tree(adj, 0)
Ejemplo n.º 9
0
def test_create_tree_exception_1():
    adj = np.array([[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 7],
                    [5, 8], [0, 4]])
    Tree(adj, 0)