Ejemplo n.º 1
0
    def test_random(self):

        from deepgraph.deepgraph import _triu_indices

        N = np.random.randint(900, 1100)
        n = N * (N - 1) / 2
        start = np.random.randint(0, n)
        end = np.random.randint(start, n)

        indices_true = np.triu_indices(N, k=1)
        sources_true = indices_true[0][start:end]
        targets_true = indices_true[1][start:end]

        indices_test = _triu_indices(N, start, end)
        sources_test = indices_test[0]
        targets_test = indices_test[1]

        assert ((sources_true == sources_test).all()
                and (targets_true == targets_test).all())
Ejemplo n.º 2
0
    def test_random(self):

        from deepgraph.deepgraph import _triu_indices

        N = np.random.randint(900, 1100)
        n = N*(N-1)/2
        start = np.random.randint(0, n)
        end = np.random.randint(start, n)

        indices_true = np.triu_indices(N, k=1)
        sources_true = indices_true[0][start:end]
        targets_true = indices_true[1][start:end]

        indices_test = _triu_indices(N, start, end)
        sources_test = indices_test[0]
        targets_test = indices_test[1]

        assert ((sources_true == sources_test).all() and
                (targets_true == targets_test).all())
Ejemplo n.º 3
0
    def test_border_cases(self):

        from deepgraph.deepgraph import _triu_indices

        Ns = [2, 5, 1004, 1523]
        starts = [0, 0, 0, 9, 9, 9, 9]
        ends = [0, 1, 2, 9, 10, 11, 12]

        for N in Ns:
            for start, end in zip(starts, ends):
                indices_true = np.triu_indices(N, k=1)
                sources_true = indices_true[0][start:end]
                targets_true = indices_true[1][start:end]

                indices_test = _triu_indices(N, start, end)
                sources_test = indices_test[0]
                targets_test = indices_test[1]

                assert ((sources_true == sources_test).all()
                        and (targets_true == targets_test).all())
Ejemplo n.º 4
0
    def test_border_cases(self):

        from deepgraph.deepgraph import _triu_indices

        Ns = [2, 5, 1004, 1523]
        starts = [0, 0, 0, 9, 9, 9, 9]
        ends = [0, 1, 2, 9, 10, 11, 12]

        for N in Ns:
            for start, end in zip(starts, ends):
                indices_true = np.triu_indices(N, k=1)
                sources_true = indices_true[0][start:end]
                targets_true = indices_true[1][start:end]

                indices_test = _triu_indices(N, start, end)
                sources_test = indices_test[0]
                targets_test = indices_test[1]

                assert ((sources_true == sources_test).all() and
                        (targets_true == targets_test).all())