[Avida-cvs] [Avida2-svn] r68 - trunk/source/python/AvidaGui2

kaben at myxo.css.msu.edu kaben at myxo.css.msu.edu
Thu Mar 24 09:10:59 PST 2005


Author: kaben
Date: 2005-03-24 12:10:58 -0500 (Thu, 24 Mar 2005)
New Revision: 68

Modified:
   trunk/source/python/AvidaGui2/pyAvidaStatsInterface.py
   trunk/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
   trunk/source/python/AvidaGui2/pyOnePopulationCtrl.py
   trunk/source/python/AvidaGui2/pySessionCtrl.py
Log:

* AvidaEd population stats graphing works again.



Modified: trunk/source/python/AvidaGui2/pyAvidaStatsInterface.py
===================================================================
--- trunk/source/python/AvidaGui2/pyAvidaStatsInterface.py	2005-03-22 21:36:51 UTC (rev 67)
+++ trunk/source/python/AvidaGui2/pyAvidaStatsInterface.py	2005-03-24 17:10:58 UTC (rev 68)
@@ -4,12 +4,24 @@
 class pyAvidaStatsInterface:
   def __init__(self):
     self.m_entries = (
-      ('None',                        None,           0, None),
-      ('Average Merit',               'average.dat',  2, cStats.GetAveMerit),
-      ('Average Gestation Time',      'average.dat',  3, cStats.GetAveGestation),
-      ('Average Fitness',             'average.dat',  4, cStats.GetAveFitness),
-      ('Average Size',                'average.dat',  6, cStats.GetAveSize),
+      ('None',                          None,            0, None),
+      ('Average Merit',                 'average.dat',   2, lambda s: s.GetAveMerit()),
+      ('Average Gestation Time',        'average.dat',   3, lambda s: s.GetAveGestation()),
+      ('Average Fitness',               'average.dat',   4, lambda s: s.GetAveFitness()),
+      ('Average Size',                  'average.dat',   6, lambda s: s.GetAveSize()),
+      ('Average Generation',            'average.dat',  13, lambda s: s.SumGeneration().Average()),
+      ('Average Neutral Metric',        'average.dat',  14, lambda s: s.GetAveNeutralMetric()),
+      ('Average Lineage Label',         'average.dat',  15, lambda s: s.GetAveLineageLabel()),
+      ('Dominant Merit',                'dominant.dat',  2, lambda s: s.GetDomMerit()),
+      ('Dominant Gestation Time',       'dominant.dat',  3, lambda s: s.GetDomGestation()),
+      ('Dominant Fitness',              'dominant.dat',  4, lambda s: s.GetDomFitness()),
+      ('Dominant Size',                 'dominant.dat',  6, lambda s: s.GetDomSize()),
+      ('Number of Organisms',           'count.dat',     3, lambda s: s.GetNumCreatures()),
+      ('Number of Genotypes',           'count.dat',     4, lambda s: s.GetNumGenotypes()),
+      ('Number of Threshold Genotypes', 'count.dat',     5, lambda s: s.GetNumThreshold()),
+      ('Number of Births',              'count.dat',     9, lambda s: s.GetNumBirths()),
+      ('Number of Deaths',              'count.dat',    10, lambda s: s.GetNumDeaths()),
     )
-  def getValue(self, entry_index, population):
+  def getValue(self, entry_index, stats):
     if entry_index:
-      return self.m_entries[entry_index][3](population.GetStats())
+      return self.m_entries[entry_index][3](stats)

Modified: trunk/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2005-03-22 21:36:51 UTC (rev 67)
+++ trunk/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2005-03-24 17:10:58 UTC (rev 68)
@@ -26,6 +26,8 @@
     self.m_combo_box.setInsertionPolicy(QComboBox.AtBottom)
     for entry in self.m_avida_stats_interface.m_entries:
       self.m_combo_box.insertItem(entry[0])
+    self.connect(
+      self.m_combo_box, SIGNAL("activated(int)"), self.modeActivatedSlot)
 
     self.m_x_array = zeros(2, Float)
     self.m_y_array = zeros(2, Float)
@@ -72,13 +74,18 @@
   def avidaUpdatedSlot(self):
     if self.m_combo_box.currentItem():
       self.m_x_array = concatenate(
-        (self.m_x_array, [self.m_session_mdl.m_population.GetStats().GetUpdate()]),
+        (self.m_x_array, [self.m_avida.m_population.GetStats().GetUpdate()]),
         1
       )
       self.m_y_array = concatenate(
         (self.m_y_array,
-          [self.m_avida_stats_interface.getValue(self.m_combo_box.currentItem(), self.m_session_mdl.m_population)]),
+          [self.m_avida_stats_interface.getValue(
+            self.m_combo_box.currentItem(),
+            self.m_avida.m_population.GetStats()
+          )]
+        ),
         1
       )
-      self.m_graph_ctrl.setCurveData(self.m_graph_ctrl.m_curve, self.m_x_array, self.m_y_array)
+      if hasattr(self.m_graph_ctrl, "m_curve"):
+        self.m_graph_ctrl.setCurveData(self.m_graph_ctrl.m_curve, self.m_x_array, self.m_y_array)
       self.m_graph_ctrl.replot()

Modified: trunk/source/python/AvidaGui2/pyOnePopulationCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOnePopulationCtrl.py	2005-03-22 21:36:51 UTC (rev 67)
+++ trunk/source/python/AvidaGui2/pyOnePopulationCtrl.py	2005-03-24 17:10:58 UTC (rev 68)
@@ -12,4 +12,5 @@
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl
     self.m_one_pop_petri_dish_ctrl.construct(self.m_session_mdl)
-    #self.m_one_pop_graph_ctrl.construct(self.m_session_mdl)
+    self.m_one_pop_graph_ctrl.construct(self.m_session_mdl)
+    self.m_one_pop_stats_ctrl.construct(self.m_session_mdl)

Modified: trunk/source/python/AvidaGui2/pySessionCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pySessionCtrl.py	2005-03-22 21:36:51 UTC (rev 67)
+++ trunk/source/python/AvidaGui2/pySessionCtrl.py	2005-03-24 17:10:58 UTC (rev 68)
@@ -43,7 +43,7 @@
     self.m_session_mdl.m_current_freezer = "freezer/"
 
     # Create a temporary subdirectory for general use in this session.
-    self.m_session_mdl.m_tempdir = tempfile.mkdtemp('-pid%d'%os.getpid(),'AvidaEd-') + "/"
+    self.m_session_mdl.m_tempdir = tempfile.mkdtemp('','AvidaEd-pid%d-'%os.getpid())
 
     # Create session mediator.
     self.m_session_mdl.m_session_mdtr = pyMdtr()




More information about the Avida-cvs mailing list