diff --git a/pyglance/glance/gui_statsprovider.py b/pyglance/glance/gui_statsprovider.py index 9a2da939adcddea9598d259acd51474cbfced698..8de8f0f02989c83b7072b795d6bad9f81818ffae 100644 --- a/pyglance/glance/gui_statsprovider.py +++ b/pyglance/glance/gui_statsprovider.py @@ -60,8 +60,8 @@ class GlanceGUIStats (object) : def sendStatsInfo (self) : """ - our data listeners should be sent statistics information for a comparison - of the currently selected variables (if possible) + our data listeners should be sent statistics information + for the currently selected variable or variables (if possible) may raise an IncompatableDataObjects exception if it is impossible to compare the given data """ @@ -73,7 +73,23 @@ class GlanceGUIStats (object) : # get Data objects aDataObject = self.dataModel.getVariableData(A_CONST, aVarName) bDataObject = self.dataModel.getVariableData(B_CONST, bVarName) + + if aDataObject is None and bDataObject is not None: + aDataObject, bDataObject = bDataObject, aDataObject + + if aDataObject is not None and bDataObject is None: + return self.sendStatsInfoSingle(aVarName, aDataObject) + + return self.sendStatsInfoPair(aVarName, bVarName, aDataObject, bDataObject) + + def sendStatsInfoPair(self, aVarName, bVarName, aDataObject, bDataObject): + """ + send data listeners statistics information + for the currently selected variables + + may raise an IncompatableDataObjects exception if it is impossible to compare the given data + """ # check the minimum validity of our data; this call can raise an IncompatableDataObjects exception dataobjects.DiffInfoObject.verifyDataCompatability(aDataObject, bDataObject, aVarName, bVarName) @@ -97,6 +113,31 @@ class GlanceGUIStats (object) : # tell my listeners to show the stats data we've collected for listener in self.statsListeners : listener.displayStatsData(aVarName, bVarName, renderedText) + + def sendStatsInfoSingle(self, aVarName, aDataObject): + """ + send data listeners statistics information + for the currently selected variable + """ + LOG.info ("Constructing statistics for one variable") + + # do the statistical analysis and collect the data that will be needed to render it nicely + tempAnalysis = stats.StatisticalInspectionAnalysis.withDataObjects(aDataObject) + # TODO, these constants should be moved into the gui_constants + tempInfo = { 'variable_name': aVarName } + kwargs = { 'runInfo': tempInfo, + 'statGroups': tempAnalysis.dictionary_form() } + + # use a mako template to render an html verion of the stats for display + templateLookup = TemplateLookup(directories=[resource_filename(__name__, ".")]) + guiTemplate = Template(resource_string(__name__, "guistatsreport.txt"), lookup=templateLookup) + renderedText = guiTemplate.render(**kwargs) + + # tell my listeners to show the stats data we've collected + for listener in self.statsListeners : + listener.displayStatsData(aVarName, None, renderedText) + + def sendRawData (self, fileID) : """