コード例 #1
0
    def test_create_new_vertex_add_constraints(self):
        """
        test that  creating a edge and then adding constraints indivusally
        :return:
        """
        constraint1 = KeyAllocatorContiguousRangeContraint()
        constraint2 = KeyAllocatorContiguousRangeContraint()
        constr = list()
        constr.append(constraint1)
        constr.append(constraint2)
        vert1 = TestVertex(10, "New AbstractConstrainedVertex", 256)
        vert2 = TestVertex(10, "New AbstractConstrainedVertex", 256)
        edge1 = TestPartitionableEdge(vert1, vert2, "edge 1")
        edge1.add_constraint(constraint1)
        edge1.add_constraint(constraint2)

        for constraint in constr:
            self.assertIn(constraint, edge1.constraints)
コード例 #2
0
    def test_create_subvertex_from_vertex_with_previous_constraints(self):
        """
        test the create subedge command given by the
        TestPartitionableEdge actually works and generates a subedge
        with the same constraints mapped over
        :return:
        """
        constraint1 = KeyAllocatorContiguousRangeContraint()
        vert1 = TestVertex(10, "New AbstractConstrainedVertex", 256)
        subv_from_vert1 = vert1.create_subvertex(
            Slice(0, 9),
            vert1.get_resources_used_by_atoms(Slice(0, 9), None))
        vert2 = TestVertex(10, "New AbstractConstrainedVertex", 256)
        subv_from_vert2 = vert2.create_subvertex(
            Slice(0, 9),
            vert2.get_resources_used_by_atoms(Slice(0, 9), None))
        edge1 = TestPartitionableEdge(vert1, vert2, "edge 1")
        edge1.add_constraint(constraint1)

        subedge = edge1.create_subedge(subv_from_vert1, subv_from_vert2)
        self.assertIn(constraint1, subedge.constraints)