Exemplo n.º 1
0
    def test_simple3(self):
        """example with 2 triangles and 1 edge"""

        simplices = [ array([[0],[1],[2],[3],[4]]),
                      array([[0, 1],
                             [0, 2],
                             [0, 3],
                             [1, 2],
                             [2, 3],
                             [2, 4]]),
                      array([[0, 1, 2],
                             [0, 2, 3]]) ]

        expected = [ array([[ 0, 0, 0, 0, 0]]),
                     array([[-1,-1,-1, 0, 0, 0],
                            [ 1, 0, 0,-1, 0, 0],
                            [ 0, 1, 0, 1,-1,-1],
                            [ 0, 0, 1, 0, 1, 0],
                            [ 0, 0, 0, 0, 0, 1]]),
                     array([[ 1, 0],
                            [-1, 1],
                            [ 0,-1],
                            [ 1, 0],
                            [ 0, 1],
                            [ 0, 0]]) ]
        
        result = rips_chain_complex( simplices )
        
        for r,e in zip(result,expected):
            assert_equal(r.todense(),e)
Exemplo n.º 2
0
    def test_simple1(self):
        """example with 1 edge and 1 point"""

        simplices = [array([[0], [1], [2]]), array([[0, 2]])]

        expected = [matrix([[0, 0, 0]]), matrix([[-1], [0], [1]])]

        result = rips_chain_complex(simplices)

        for r, e in zip(result, expected):
            assert_equal(r.todense(), e)
Exemplo n.º 3
0
    def test_simple1(self):
        """example with 1 edge and 1 point"""

        simplices = [ array([[0],[1],[2]]),
                      array([[0,2]]) ]

        expected = [ matrix([[0,0,0]]),
                     matrix([[-1],[ 0],[ 1]]) ]

        result = rips_chain_complex(simplices)

        for r,e in zip(result,expected):
            assert_equal(r.todense(),e)
Exemplo n.º 4
0
    def test_simple2(self):
        """example with 1 triangle"""

        simplices = [ array([[0],[1],[2]]),
                      array([[0,1],[0,2],[1,2]]),
                      array([[0,1,2]]) ]

        expected = [ matrix([[0,0,0]]),
                     matrix([[-1,-1, 0],
                             [ 1, 0,-1],
                             [ 0, 1, 1]]),
                     matrix([[ 1],[-1],[ 1]]) ]

        result = rips_chain_complex(simplices)

        for r,e in zip(result,expected):
            assert_equal(r.todense(),e)
Exemplo n.º 5
0
    def test_simple2(self):
        """example with 1 triangle"""

        simplices = [
            array([[0], [1], [2]]),
            array([[0, 1], [0, 2], [1, 2]]),
            array([[0, 1, 2]])
        ]

        expected = [
            matrix([[0, 0, 0]]),
            matrix([[-1, -1, 0], [1, 0, -1], [0, 1, 1]]),
            matrix([[1], [-1], [1]])
        ]

        result = rips_chain_complex(simplices)

        for r, e in zip(result, expected):
            assert_equal(r.todense(), e)
Exemplo n.º 6
0
    def test_simple3(self):
        """example with 2 triangles and 1 edge"""

        simplices = [
            array([[0], [1], [2], [3], [4]]),
            array([[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [2, 4]]),
            array([[0, 1, 2], [0, 2, 3]])
        ]

        expected = [
            array([[0, 0, 0, 0, 0]]),
            array([[-1, -1, -1, 0, 0, 0], [1, 0, 0, -1, 0, 0],
                   [0, 1, 0, 1, -1, -1], [0, 0, 1, 0, 1, 0],
                   [0, 0, 0, 0, 0, 1]]),
            array([[1, 0], [-1, 1], [0, -1], [1, 0], [0, 1], [0, 0]])
        ]

        result = rips_chain_complex(simplices)

        for r, e in zip(result, expected):
            assert_equal(r.todense(), e)