Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/augmented_examples' into upgradi…
Browse files Browse the repository at this point in the history
…ng_tests
  • Loading branch information
alan-stokes committed Apr 22, 2015
2 parents 7acfb53 + 160bdc9 commit 454423d
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 82 deletions.
7 changes: 1 addition & 6 deletions pacman/model/graph_mapper/graph_mapper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
"""
GraphMapper
"""

# pacman imports
from pacman.model.abstract_classes.abstract_partitioned_edge \
from pacman.model.partitioned_graph.abstract_partitioned_edge \
import AbstractPartitionedEdge
from pacman.model.partitioned_graph.partitioned_vertex import PartitionedVertex
from pacman.exceptions import (PacmanValueError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AbstractPartitionableEdge(AbstractConstrainedEdge):
vertices
"""

def __init__(self, pre_vertex, post_vertex, label=None, constraints=None):
def __init__(self, pre_vertex, post_vertex, constraints=None, label=None):
"""
:param pre_vertex: the vertex at the start of the edge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ def create_subvertex(self, vertex_slice, resources_required, label=None,
constraints.
:type constraints: iterable of\
:py:class:`pacman.model.constraints.abstract_constraint.AbstractConstraint`
:param resources_required: the amount of resources that the given
partitioned vertex is to use.
:type resources_required: pacman.model.resources.resource_container.ResourceContainer
:raise pacman.exceptions.PacmanInvalidParameterException:
* If lo_atom or hi_atom are out of range
* If one of the constraints is invalid
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pacman.model.partitioned_graph.fixed_route_partitioned_edge import \
FixedRoutePartitionedEdge
from pacman.model.partitioned_graph.partitioned_vertex import PartitionedVertex
from pacman.model.abstract_classes.abstract_partitionable_edge \
from pacman.model.partitionable_graph.abstract_partitionable_edge \
import AbstractPartitionableEdge
from pacman import exceptions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pacman.model.partitioned_graph.multi_cast_partitioned_edge import \
MultiCastPartitionedEdge
from pacman.model.partitioned_graph.partitioned_vertex import PartitionedVertex
from pacman.model.abstract_classes.abstract_partitionable_edge import \
from pacman.model.partitionable_graph.abstract_partitionable_edge import \
AbstractPartitionableEdge
from pacman import exceptions

Expand All @@ -28,7 +28,7 @@ def __init__(self, pre_vertex, post_vertex, constraints=None, label=None):
:raise None: Raises no known exceptions
"""
AbstractPartitionableEdge.__init__(self, pre_vertex, post_vertex,
label, constraints)
constraints, label)

def is_partitionable_edge(self):
""" helper method for is instance
Expand Down
4 changes: 2 additions & 2 deletions pacman/model/partitionable_graph/partitionable_graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pacman.model.abstract_classes.abstract_partitionable_vertex \
from pacman.model.partitionable_graph.abstract_partitionable_vertex \
import AbstractPartitionableVertex
from pacman.model.abstract_classes.abstract_partitionable_edge \
from pacman.model.partitionable_graph.abstract_partitionable_edge \
import AbstractPartitionableEdge
from pacman.exceptions import PacmanInvalidParameterException

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pacman.model.abstract_classes.abstract_partitioned_edge import \
from pacman.model.partitioned_graph.abstract_partitioned_edge import \
AbstractPartitionedEdge


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pacman.model.abstract_classes.abstract_partitioned_edge import \
from pacman.model.partitioned_graph.abstract_partitioned_edge import \
AbstractPartitionedEdge


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,11 @@ def _scale_down_resources(self, lo_atom, hi_atom, vertices,

# Scale the resources by the ratio
old_n_atoms = (hi_atom - lo_atom) + 1
new_n_atoms = int(float(old_n_atoms) / ratio)
new_n_atoms = int(float(old_n_atoms) / (ratio * 1.1))

# Avoid infinite looping
if old_n_atoms == new_n_atoms:
new_n_atoms -= 1
else:
# Subtract a tenth of the difference between the old
# and new
possible_new_n_atoms = \
new_n_atoms - int((old_n_atoms - new_n_atoms) / 10.0)
if possible_new_n_atoms > 0:
new_n_atoms = possible_new_n_atoms

# Find the new resource usage
hi_atom = lo_atom + new_n_atoms - 1
Expand Down
2 changes: 1 addition & 1 deletion uinit_test_objects/test_edge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pacman.model.abstract_classes.abstract_partitionable_edge import \
from pacman.model.partitionable_graph.abstract_partitionable_edge import \
AbstractPartitionableEdge
from pacman.model.partitioned_graph.multi_cast_partitioned_edge import \
MultiCastPartitionedEdge
Expand Down
6 changes: 3 additions & 3 deletions uinit_test_objects/test_partitioning_constraint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
test constraint
"""
from pacman.model.constraints.abstract_partitioner_constraint import \
AbstractPartitionerConstraint
from pacman.model.constraints.abstract_constraints\
.abstract_partitioner_constraint import AbstractPartitionerConstraint


class NewPartitionerConstraint(AbstractPartitionerConstraint):
Expand All @@ -23,4 +23,4 @@ def is_constraint(self):
def is_partitioner_constraint(self):
""" Determine if this is a partitioner constraint
"""
return True
return True
2 changes: 1 addition & 1 deletion uinit_test_objects/test_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

# pacman imports
from pacman.model.abstract_classes.abstract_partitionable_vertex import \
from pacman.model.partitionable_graph.abstract_partitionable_vertex import \
AbstractPartitionableVertex
from pacman.model.resources.cpu_cycles_per_tick_resource import \
CPUCyclesPerTickResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# general imports
import unittest
from pacman.model.abstract_classes.abstract_partitioned_edge import \
from pacman.model.partitioned_graph.abstract_partitioned_edge import \
AbstractPartitionedEdge


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

# pacman imports
from pacman.model.abstract_classes.abstract_partitionable_edge \
from pacman.model.partitionable_graph.abstract_partitionable_edge \
import AbstractPartitionableEdge
from pacman.model.partitionable_graph.partitionable_graph \
import PartitionableGraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def test_create_new_subedge_routing_info(self):
sri = SubedgeRoutingInfo(keys_and_masks, sube)
self.assertEqual(sri.subedge, sube)
key_and_mask = sri.keys_and_masks
self.assertEqual(key_and_mask.key, 0x0012)
self.assertEqual(key_and_mask.mask, 0x00ff)
self.assertEqual(key_and_mask[0].key, 0x0012)
self.assertEqual(key_and_mask[0].mask, 0x00ff)

def test_create_new_routing_info(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""

# pacman imports
from pacman.model.constraints.partitioner_same_size_as_vertex_constraint \
from pacman.model.constraints.partitioner_constraints\
.partitioner_same_size_as_vertex_constraint \
import PartitionerSameSizeAsVertexConstraint
from pacman.exceptions import PacmanPartitionException, \
PacmanInvalidParameterException, PacmanValueError
Expand Down Expand Up @@ -44,7 +45,7 @@ def setup(self):
self.vert1 = TestVertex(10, "New AbstractConstrainedVertex 1")
self.vert2 = TestVertex(5, "New AbstractConstrainedVertex 2")
self.vert3 = TestVertex(3, "New AbstractConstrainedVertex 3")
self.edge1 = MultiCastPartitionableEdge(self.vert1, self.vert2,
self.edge1 = MultiCastPartitionableEdge(self.vert1, self.vert2,
None, "First edge")
self.edge2 = MultiCastPartitionableEdge(self.vert2, self.vert1,
None, "Second edge")
Expand Down Expand Up @@ -340,7 +341,7 @@ def test_partition_with_empty_graph(self):
subgraph, mapper = self.bp.partition(self.graph, self.machine)
self.assertEqual(len(subgraph.subvertices), 0)
# # # # # # #

def test_operation_with_same_size_as_vertex_constraint(self):
"""
test that the partition and place partitioner can handle same size as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
from pacman.model.partitioned_graph.partitioned_vertex import PartitionedVertex
from pacman.model.graph_mapper.graph_mapper import GraphMapper
from pacman.model.partitioned_graph.partitioned_graph import PartitionedGraph
from pacman.model.abstract_classes.abstract_partitionable_edge import AbstractPartitionableEdge
from pacman.model.partitionable_graph.abstract_partitionable_edge\
import AbstractPartitionableEdge
from pacman.model.partitionable_graph.partitionable_graph import PartitionableGraph
from pacman.model.abstract_classes.abstract_partitionable_vertex import \
from pacman.model.partitionable_graph.abstract_partitionable_vertex import \
AbstractPartitionableVertex
from pacman.operations.placer_algorithms.radial_placer import RadialPlacer
from spinn_machine.chip import Chip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from pacman.model.resources.resource_container import ResourceContainer
from pacman.model.resources.sdram_resource import SDRAMResource
from pacman.exceptions import PacmanRoutingException
from pacman.model.abstract_classes.abstract_partitioned_edge import AbstractPartitionedEdge
from pacman.model.partitioned_graph.abstract_partitioned_edge import AbstractPartitionedEdge
from pacman.model.partitioned_graph.partitioned_vertex import PartitionedVertex
from pacman.model.placements.placement import Placement
from pacman.model.placements.placements import Placements
from pacman.model.routing_info.routing_info import RoutingInfo
from pacman.model.routing_info.subedge_routing_info import SubedgeRoutingInfo
from pacman.model.abstract_classes.abstract_partitionable_edge \
from pacman.model.partitionable_graph.abstract_partitionable_edge \
import AbstractPartitionableEdge
from pacman.model.partitionable_graph.partitionable_graph \
import PartitionableGraph
Expand All @@ -31,7 +31,7 @@

import unittest

from pacman.model.abstract_classes.abstract_partitionable_vertex import \
from pacman.model.partitionable_graph.abstract_partitionable_vertex import \
AbstractPartitionableVertex


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import unittest

from pacman.model.abstract_classes.abstract_partitioned_edge import \
from pacman.model.partitioned_graph.abstract_partitioned_edge import \
AbstractPartitionedEdge
from pacman.model.partitioned_graph.partitioned_vertex import PartitionedVertex
from pacman.operations.router_algorithms import SteinerTreeWeightedRouting
from pacman.operations.router_algorithms import BasicDijkstraRouting
from pacman.model.abstract_classes.abstract_partitionable_edge \
from pacman.model.partitionable_graph.abstract_partitionable_edge \
import AbstractPartitionableEdge
from pacman.model.partitionable_graph.partitionable_graph \
import PartitionableGraph
Expand All @@ -16,7 +15,7 @@
from pacman.model.routing_info.subedge_routing_info import SubedgeRoutingInfo
from spinn_machine.virutal_machine import VirtualMachine
from pacman.utilities import constants
from pacman.model.abstract_classes.abstract_partitionable_vertex import \
from pacman.model.partitionable_graph.abstract_partitionable_vertex import \
AbstractPartitionableVertex


Expand Down Expand Up @@ -284,8 +283,6 @@ def test_new_router_set_non_default_routing_algorithm(self):
self.assertEqual(self.routing._graph, None)
self.assertEqual(self.routing.report_states, None)
self.assertEqual(self.routing._hostname, None)
self.assertIsInstance(self.routing._router_algorithm,
SteinerTreeWeightedRouting)
self.assertEqual(self.routing._graph_to_subgraph_mappings, None)

def test_run_router(self):
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_allocate_fixed_mask(self):

try:
self._print_keys_and_masks(allocator._allocate_keys_and_masks(
0xFFFFFF00, 20, True))
0xFFFFFF00, None, 20, True))
except:
traceback.print_exc()
self.fail("Unexpected exception is raised when allocating a key!")
Expand All @@ -60,13 +60,14 @@ def test_allocate_n_keys(self):

try:
self._print_keys_and_masks(allocator._allocate_keys_and_masks(
None, 20, True))
None, None, 20, True))
except:
traceback.print_exc()
self.fail("Unexpected exception is raised when allocating a key!")

error = ("Allocation has not resulted in the expected free space"
" being available")

print allocator._free_space_tracker
self.assertEqual(len(allocator._free_space_tracker), 1, error)
self.assertEqual(allocator._free_space_tracker[0].start_address, 32,
Expand All @@ -83,27 +84,27 @@ def test_allocate_mixed_keys(self):

allocator._allocate_fixed_keys_and_masks(
[KeyAndMask(0x800, 0xFFFFF800)], None)
print allocator._free_space_tracker

for mask, keys in zip(fixed_masks, n_keys):
self._print_keys_and_masks(
allocator._allocate_keys_and_masks(mask, keys, True))
print allocator._free_space_tracker
allocator._allocate_keys_and_masks(mask, None, keys, True))

print allocator._free_space_tracker

error = ("Allocation has not resulted in the expected free space"
" being available")
self.assertEqual(len(allocator._free_space_tracker), 3, error)
self.assertEqual(allocator._free_space_tracker[0].start_address, 288,
error)
self.assertEqual(allocator._free_space_tracker[0].size, 224,
self.assertEqual(allocator._free_space_tracker[0].size, 1760,
error)
self.assertEqual(allocator._free_space_tracker[1].start_address,
768, error)
self.assertEqual(allocator._free_space_tracker[1].size, 1280,
0x1100, error)
self.assertEqual(allocator._free_space_tracker[1].size, 0x1FFF00,
error)
self.assertEqual(allocator._free_space_tracker[2].start_address,
6144, error)
self.assertEqual(allocator._free_space_tracker[2].size, 0xFFFFE800,
0x201800, error)
self.assertEqual(allocator._free_space_tracker[2].size, 0xFFDFE800,
error)

if __name__ == '__main__':
Expand Down

0 comments on commit 454423d

Please sign in to comment.