Changeset 2365


Ignore:
Timestamp:
Feb 17, 2010 1:38:59 PM (10 years ago)
Author:
jwatson
Message:

More output sorting to ensure that tests pass!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/trunk/coopr/pysp/scenariotree.py

    r2363 r2365  
    501501      print "Tree Nodes:"
    502502      print ""
    503       for tree_node_name, tree_node in sorted(self._tree_node_map.iteritems()):
     503      for tree_node_name in sorted(self._tree_node_map.keys()):
     504         tree_node = self._tree_node_map[tree_node_name]
    504505         print "\tName=" + tree_node_name
    505506         if tree_node._stage is not None:
     
    517518         print "\tChildren:"
    518519         if len(tree_node._children) > 0:
    519             #for child_node in sorted(tree_node._children):
    520             for child_node in sorted(tree_node._children, cmp=lambda x,y: cmp(x._name,y._name)):
     520            for child_node in sorted(tree_node._children, cmp=lambda x,y: cmp(x._name, y._name)):
    521521               print "\t\t" + child_node._name
    522522         else:
     
    526526            print "\t\tNone"
    527527         else:
    528             for scenario in tree_node._scenarios:
     528            for scenario in sorted(tree_node._scenarios, cmp=lambda x,y: cmp(x._name, y._name)):
    529529               print "\t\t" + scenario._name
    530530         print ""
    531531      print "----------------------------------------------------"
    532532      print "Stages:"
    533       for stage_name, stage in sorted(self._stage_map.iteritems()):
     533      for stage_name in sorted(self._stage_map.keys()):
     534         stage = self._stage_map[stage_name]
    534535         print "\tName=" + stage_name
    535536         print "\tTree Nodes: "
    536          for tree_node in stage._tree_nodes:
     537         for tree_node in sorted(stage._tree_nodes, cmp=lambda x,y: cmp(x._name, y._name)):
    537538            print "\t\t" + tree_node._name
    538539         print "\tVariables: "
     
    550551      print "----------------------------------------------------"
    551552      print "Scenarios:"
    552       for scenario_name, scenario in sorted(self._scenario_map.iteritems()):
     553      for scenario_name in sorted(self._scenario_map.keys()):
     554         scenario = self._scenario_map[scenario_name]
    553555         print "\tName=" + scenario_name
    554556         print "\tProbability=%4.4f" % scenario._probability
     
    581583      print "Tree Nodes:"
    582584      print ""
    583       for tree_node_name, tree_node in sorted(self._tree_node_map.iteritems()):
     585      for tree_node_name in sorted(self._tree_node_map.keys()):
     586         tree_node = self._tree_node_map[tree_node_name]
    584587         print "\tName=" + tree_node_name
    585588         if tree_node._stage is not None:
     
    597600         print "\tChildren:"
    598601         if len(tree_node._children) > 0:
    599             for child_node in sorted(tree_node._children, cmp=lambda x,y: cmp(x._name,y._name)):
     602            for child_node in sorted(tree_node._children, cmp=lambda x,y: cmp(x._name, y._name)):
    600603               print "\t\t" + child_node._name
    601604         else:
     
    605608            print "\t\tNone"
    606609         else:
    607             for scenario in tree_node._scenarios:
     610            for scenario in sorted(tree_node._scenarios, cmp=lambda x,y: cmp(x._name, y._name)):
    608611               print "\t\t" + scenario._name
    609612         print "\tExpected node cost=%10.4f" % tree_node.computeExpectedNodeCost(scenario_instance_map)
Note: See TracChangeset for help on using the changeset viewer.