<commit_before>import unittest
import dynetx as dn
import networkx as nx
import dynetx.algorithms as al


def get_netowrk():
    g = dn.DynGraph()
    g.add_interaction("A", "B", 1, 4)
    g.add_interaction("B", "D", 2, 5)
    g.add_interaction("A", "C", 4, 8)
    g.add_interaction("B", "D", 2, 4)
    g.add_interaction("B", "C", 6, 10)
    g.add_interaction("B", "D", 2, 4)
    g.add_interaction("A", "B", 7, 9)
    return g


class AlgorithmsTestCase(unittest.TestCase):

    def test_DAG(self):
        g = get_netowrk()
        DAG, sources, targets, _, _ = al.temporal_dag(g, "D", "C", start=1, end=9)
        self.assertIsInstance(DAG, nx.DiGraph)
        self.assertIsInstance(sources, list)
        self.assertIsInstance(targets, list)

    def test_time_respecting_paths(self):
        g = get_netowrk()
        pts = al.time_respecting_paths(g, "D", "C", start=1, end=9)

        for p in pts:
            self.assertIsInstance(p, list)

        with self.assertRaises(ValueError) as _:
            al.time_respecting_paths(g, "D", "C", start=20, end=40)

    def test_all_time_respecting_paths(self):
        g = get_netowrk()
        pts = al.all_time_respecting_paths(g, start=1, end=9)

        for p in pts:
            self.assertIsInstance(p, tuple)

    def test_annotated_paths(self):
        g = get_netowrk()
        pts = list(al.time_respecting_paths(g, "D", "C", start=1, end=9))
        ann_pts = al.annotate_paths(pts)

        for k, v in ann_pts.items():
            self.assertIn(k, ['shortest', 'fastest', 'foremost', 'fastest_shortest', 'shortest_fastest'])
            self.assertIsInstance(v, list)<commit_msg>:arrow_up: test case<commit_after>import unittest
import dynetx as dn
import networkx as nx
import dynetx.algorithms as al


def get_netowrk():
    g = dn.DynGraph()
    g.add_interaction("A", "B", 1, 4)
    g.add_interaction("B", "D", 2, 5)
    g.add_interaction("A", "C", 4, 8)
    g.add_interaction("B", "D", 2, 4)
    g.add_interaction("B", "C", 6, 10)
    g.add_interaction("B", "D", 2, 4)
    g.add_interaction("A", "B", 7, 9)
    return g


class AlgorithmsTestCase(unittest.TestCase):

    def test_DAG(self):
        g = get_netowrk()
        DAG, sources, targets, _, _ = al.temporal_dag(g, "D", "C", start=1, end=9)
        self.assertIsInstance(DAG, nx.DiGraph)
        self.assertIsInstance(sources, list)
        self.assertIsInstance(targets, list)

    def test_time_respecting_paths(self):
        g = get_netowrk()
        pts = al.time_respecting_paths(g, "D", "C", start=1, end=9)

        for p in pts:
            self.assertIsInstance(p, list)

        self.assertEqual(len(al.time_respecting_paths(g, "D", "C", start=20, end=40)), 0)

    def test_all_time_respecting_paths(self):
        g = get_netowrk()
        pts = al.all_time_respecting_paths(g, start=1, end=9)

        for p in pts:
            self.assertIsInstance(p, tuple)

    def test_annotated_paths(self):
        g = get_netowrk()
        pts = list(al.time_respecting_paths(g, "D", "C", start=2, end=9))
        ann_pts = al.annotate_paths(pts)

        for k, v in ann_pts.items():
            self.assertIn(k, ['shortest', 'fastest', 'foremost', 'fastest_shortest', 'shortest_fastest'])
            self.assertIsInstance(v, list)
{'fraction_non_alphanumeric': 0.14687882496940025, 'fraction_numerical': 0.016829865361077112, 'mean_word_length': 2.93855421686747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2950490', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1211, 'n_words': 261}