Example #1
0
 def rmttest_inherit_003(self):
     "Topological sort check"
     mg = create_test_graph_01()
     tsort = topological_sort(mg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ['C', 'B', 'A'], \
         "incorrect topological sort"
Example #2
0
 def test_tsort_004(self):
     "More complex digraph"
     dg = Digraph( {"A": ["B", "C"], "B": ["C", "E"], "C": ["D", "E"],
                    "D": [], "E": [] } )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['D', 'E', 'C', 'B', 'A'], "incorrect")
Example #3
0
 def test_inherit_003(self):
     "Topological sort check"
     mg = create_test_graph_01()
     tsort = topological_sort(mg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A'],
                      "incorrect topological sort")
Example #4
0
    def output_reqset(self, reqset, reqscont):

        # Because of a problem with the current OpenOffice versions,
        # there is the need to sometimes arrange requirements as rows
        # and sometimes as columns:
        # It is not possible to define the range of a list input as a
        # row: it must be a column.
        # The order dictionary holds the number - which can be
        # computed in a row or column.
        def create_reqs_index(srqes):
            sreqs_index = {}
            cnt = 0
            for req in sreqs:
                sreqs_index[req] = cnt
                cnt += 1
            return sreqs_index

        # The topological sort is needed.
        sreqs = topological_sort(self.topic_set.reqset)

        # Create the row / column index of each requirement
        self.sreqs_index = create_reqs_index(sreqs)

        # Create and save the document
        calcdoc = OpenDocumentSpreadsheet()
        self.create_meta(calcdoc, reqscont)
        self.create_styles(calcdoc)
        self.create_costs_sheet(calcdoc, sreqs)
        self.create_deps_sheet(calcdoc, sreqs)
        self.create_sums_sheet(calcdoc, sreqs)
        self.create_constants_sheet(calcdoc)
        self.create_result_sheet(calcdoc, sreqs)
        calcdoc.save(self.output_filename, True)
Example #5
0
    def requirement_set_pre(self, requirement_set):
        '''The output of all the content.'''

        # Because of a problem with the current OpenOffice versions,
        # there is the need to sometimes arrange requirements as rows
        # and sometimes as columns:
        # It is not possible to define the range of a list input as a
        # row: it must be a column.
        # The order dictionary holds the number - which can be
        # computed in a row or column.
        def create_reqs_index(srqes):
            sreqs_index = {}
            cnt = 0
            for req in sreqs:
                sreqs_index[req] = cnt
                cnt += 1
            return sreqs_index

        sreqs = topological_sort(requirement_set)

        # Create the row / column index of each requirement
        self.sreqs_index = create_reqs_index(sreqs)

        # Create and save the document
        self.__create_costs_sheet(sreqs)
        self.__create_deps_sheet(sreqs)
        self.__create_sums_sheet(sreqs)
        self.__create_constants_sheet()
        self.__create_result_sheet(sreqs)
Example #6
0
 def rmttest_inherit_003(self):
     "Topological sort check"
     mg = create_test_graph_01()
     tsort = topological_sort(mg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ['C', 'B', 'A'], \
         "incorrect topological sort"
Example #7
0
 def test_tsort_005(self):
     "Digraph with two components"
     dg = digraph_create_from_dict( {"A": ["B", "C"], "B": ["C"], "C": [],
                    "D": ["E"], "E": [] } )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A', 'E', 'D'], "incorrect")
Example #8
0
 def unite_ce3s(self, reqset, ce3set):
     # The ce3s must be executed in topological order.
     ce3tsort = topological_sort(reqset)
     for r in ce3tsort:
         # Have a look for incoming nodes
         ince3s = []
         for i in r.outgoing:
             ince3s.append(ce3set.get(i.get_id()))
         lce3 = ce3set.get(r.get_id())
         lce3.unite(ince3s)
Example #9
0
 def cmad(self, reqscont, ofile):
     # Because the variables must be defined before they can be
     # accessed, the topological sort is needed here.
     tsort = topological_sort(self)
     for t in tsort:
         ofile.write("%s: %s.tic" % (self.create_makefile_name(t.name), os.path.join(self.topic_dir, t.name)))
         # Path the dependency handling of the requirements to the
         # Topic object itself.
         t.cmad(reqscont, ofile, self.name)
         ofile.write("\n")
Example #10
0
    def rmttest_tsort_005(self):
        "Digraph with two components"
        dg = Digraph({"A": ["B", "C"], "B": ["C"], "C": [],
                      "D": ["E"], "E": []})
        tsort = topological_sort(dg)
        tnames = node_list_to_node_name_list(tsort)

        # There is no 'fixed' result - depending on the python
        # implementation different correct values are computed.
        assert self.__list_order(tnames, "B", "A")
        assert self.__list_order(tnames, "C", "A")
        assert self.__list_order(tnames, "E", "D")
Example #11
0
 def test_tsort_005(self):
     "Digraph with two components"
     dg = digraph_create_from_dict({
         "A": ["B", "C"],
         "B": ["C"],
         "C": [],
         "D": ["E"],
         "E": []
     })
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A', 'E', 'D'], "incorrect")
Example #12
0
 def test_tsort_004(self):
     "More complex digraph"
     dg = digraph_create_from_dict({
         "A": ["B", "C"],
         "B": ["C", "E"],
         "C": ["D", "E"],
         "D": ["E"],
         "E": []
     })
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['E', 'D', 'C', 'B', 'A'], "incorrect")
Example #13
0
    def rmttest_tsort_005(self):
        "Digraph with two components"
        dg = Digraph({"A": ["B", "C"], "B": ["C"], "C": [],
                      "D": ["E"], "E": []})
        tsort = topological_sort(dg)
        tnames = node_list_to_node_name_list(tsort)

        # There is no 'fixed' result - depending on the python
        # implementation different correct values are computed.
        assert self.__list_order(tnames, "B", "A")
        assert self.__list_order(tnames, "C", "A")
        assert self.__list_order(tnames, "E", "D")
Example #14
0
 def __unite_ce3s(self):
     '''Execute the unification of the CE3s:
        From the list of all incoming nodes and the value of the
        current node compute the new value of the current node
        The ce3s must be executed in topological order.'''
     ce3tsort = topological_sort(self)
     for ce3node in ce3tsort:
         # Have a look for incoming nodes
         ince3s = []
         for i in ce3node.incoming:
             ince3s.append(self.__ce3set.get(i.get_id()))
         lce3 = self.__ce3set.get(ce3node.get_id())
         lce3.unite(ince3s)
Example #15
0
 def __unite_ce3s(self):
     '''Execute the unification of the CE3s:
        From the list of all incoming nodes and the value of the 
        current node compute the new value of the current node
        The ce3s must be executed in topological order.'''
     ce3tsort = topological_sort(self)
     for r in ce3tsort:
         # TODO Outgoing
         # Have a look for incoming nodes
         ince3s = []
         for i in r.get_iter_incoming():
             ince3s.append(self.__ce3set.get(i.get_requirement().get_id()))
         lce3 = self.__ce3set.get(r.get_requirement().get_id())
         lce3.unite(ince3s)
Example #16
0
 def __unite_ce3s(self):
     '''Execute the unification of the CE3s:
        From the list of all incoming nodes and the value of the 
        current node compute the new value of the current node
        The ce3s must be executed in topological order.'''
     ce3tsort = topological_sort(self)
     for r in ce3tsort:
         # TODO Outgoing
         # Have a look for incoming nodes
         ince3s = []
         for i in r.get_iter_incoming():
             ince3s.append(self.__ce3set.get(i.get_requirement().get_id()))
         lce3 = self.__ce3set.get(r.get_requirement().get_id())
         lce3.unite(ince3s)
Example #17
0
 def rmttest_tsort_004(self):
     "More complex digraph"
     dg = Digraph({
         "A": ["B", "C"],
         "B": ["C", "E"],
         "C": ["D", "E"],
         "D": [],
         "E": []
     })
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     # There is no 'fixed' result - depending on the python
     # implementation different correct values are computed.
     self.assertTrue(self.__list_order(tnames, "D", "C"))
     self.assertTrue(self.__list_order(tnames, "E", "C"))
     self.assertTrue(self.__list_order(tnames, "E", "B"))
     self.assertTrue(self.__list_order(tnames, "C", "B"))
     self.assertTrue(self.__list_order(tnames, "C", "A"))
     self.assertTrue(self.__list_order(tnames, "B", "A"))
Example #18
0
 def rmttest_tsort_001(self):
     "Simple three node digraph"
     dg = Digraph({"A": ["B", "C"], "B": ["C"], "C": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ['C', 'B', 'A'], "incorrect"
Example #19
0
 def test_tsort_002(self):
     "Zero node digraph"
     dg = digraph_create_from_dict( {} )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, [], "incorrect")
Example #20
0
 def test_tsort_003(self):
     "One node digraph"
     dg = digraph_create_from_dict( {"A": [] } )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ["A"], "incorrect")
Example #21
0
 def test_tsort_001(self):
     "Simple three node digraph"
     dg = digraph_create_from_dict({"A": ["B", "C"], "B": ["C"], "C": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A'], "incorrect")
Example #22
0
 def test_tsort_001(self):
     "Simple three node digraph"
     dg = digraph_create_from_dict( {"A": ["B", "C"], "B": ["C"], "C": [] } )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A'], "incorrect")
Example #23
0
 def __topological_sort(self):
     '''Do a topological sort on the reqdeps modules.'''
     self.__reqdeps_sorted = topological_sort(self)
Example #24
0
 def test_tsort_002(self):
     "Zero node digraph"
     dg = digraph_create_from_dict({})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, [], "incorrect")
Example #25
0
 def rmttest_tsort_003(self):
     "One node digraph"
     dg = Digraph({"A": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ["A"], "incorrect"
Example #26
0
 def test_tsort_003(self):
     "One node digraph"
     dg = digraph_create_from_dict({"A": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ["A"], "incorrect")
Example #27
0
 def rmttest_tsort_001(self):
     "Simple three node digraph"
     dg = Digraph({"A": ["B", "C"], "B": ["C"], "C": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ['C', 'B', 'A'], "incorrect"
Example #28
0
 def rmttest_tsort_002(self):
     "Zero node digraph"
     dg = Digraph({})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == [], "incorrect"
Example #29
0
 def topological_sort(self):
     # Do a topoligical sort on the reqdeps modules.
     self.reqdeps_sorted = topological_sort(self)
Example #30
0
 def test_inherit_003(self):
     "Topological sort check"
     mg = create_test_graph_01()
     tsort = topological_sort(mg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A'], "incorrect topological sort")
Example #31
0
 def __topological_sort(self):
     '''Do a topological sort on the reqdeps modules.'''
     self.__reqdeps_sorted = topological_sort(self)
Example #32
0
 def rmttest_tsort_003(self):
     "One node digraph"
     dg = Digraph({"A": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ["A"], "incorrect"
Example #33
0
 def rmttest_tsort_002(self):
     "Zero node digraph"
     dg = Digraph({})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == [], "incorrect"