info.py (1301:f85f6fb43474) | info.py (1329:1e7bd1684f64) |
---|---|
1from __future__ import division 2import operator, re, types 3 4source = None 5display_run = 0 | 1from __future__ import division 2import operator, re, types 3 4source = None 5display_run = 0 |
6global globalTicks 7globalTicks = None |
|
6 7def issequence(t): 8 return isinstance(t, types.TupleType) or isinstance(t, types.ListType) 9 10def total(f): 11 if isinstance(f, FormulaStat): 12 v = f.value 13 else: --- 111 unchanged lines hidden (view full) --- 125 if a < b: 126 return -1 127 elif a == b: 128 return 0 129 else: 130 return 1 131 132class Statistic(object): | 8 9def issequence(t): 10 return isinstance(t, types.TupleType) or isinstance(t, types.ListType) 11 12def total(f): 13 if isinstance(f, FormulaStat): 14 v = f.value 15 else: --- 111 unchanged lines hidden (view full) --- 127 if a < b: 128 return -1 129 elif a == b: 130 return 0 131 else: 132 return 1 133 134class Statistic(object): |
135 |
|
133 def __init__(self, data): 134 self.__dict__.update(data.__dict__) 135 if not self.__dict__.has_key('value'): 136 self.__dict__['value'] = None 137 if not self.__dict__.has_key('bins'): 138 self.__dict__['bins'] = None 139 if not self.__dict__.has_key('ticks'): 140 self.__dict__['ticks'] = None | 136 def __init__(self, data): 137 self.__dict__.update(data.__dict__) 138 if not self.__dict__.has_key('value'): 139 self.__dict__['value'] = None 140 if not self.__dict__.has_key('bins'): 141 self.__dict__['bins'] = None 142 if not self.__dict__.has_key('ticks'): 143 self.__dict__['ticks'] = None |
144 if 'vc' not in self.__dict__: 145 self.vc = {} |
|
141 142 def __getattribute__(self, attr): | 146 147 def __getattribute__(self, attr): |
148 if attr == 'ticks': 149 if self.__dict__['ticks'] != globalTicks: 150 self.__dict__['value'] = None 151 self.__dict__['ticks'] = globalTicks 152 return self.__dict__['ticks'] |
|
143 if attr == 'value': | 153 if attr == 'value': |
154 if self.__dict__['ticks'] != globalTicks: 155 if self.__dict__['ticks'] != None and \ 156 len(self.__dict__['ticks']) == 1: 157 self.vc[self.__dict__['ticks'][0]] = self.__dict__['value'] 158 self.__dict__['ticks'] = globalTicks 159 if len(globalTicks) == 1 and self.vc.has_key(globalTicks[0]): 160 self.__dict__['value'] = self.vc[globalTicks[0]] 161 else: 162 self.__dict__['value'] = None |
|
144 if self.__dict__['value'] == None: 145 self.__dict__['value'] = self.getValue() 146 return self.__dict__['value'] 147 else: 148 return super(Statistic, self).__getattribute__(attr) 149 150 def __setattr__(self, attr, value): 151 if attr == 'bins' or attr == 'ticks': 152 if attr == 'bins': 153 if value is not None: 154 value = source.getBin(value) | 163 if self.__dict__['value'] == None: 164 self.__dict__['value'] = self.getValue() 165 return self.__dict__['value'] 166 else: 167 return super(Statistic, self).__getattribute__(attr) 168 169 def __setattr__(self, attr, value): 170 if attr == 'bins' or attr == 'ticks': 171 if attr == 'bins': 172 if value is not None: 173 value = source.getBin(value) |
155 elif attr == 'ticks' and type(value) is str: 156 value = [ int(x) for x in value.split() ] | 174 #elif attr == 'ticks' and type(value) is str: 175 # value = [ int(x) for x in value.split() ] |
157 158 self.__dict__[attr] = value 159 self.__dict__['value'] = None | 176 177 self.__dict__[attr] = value 178 self.__dict__['value'] = None |
179 self.vc = {} |
|
160 else: 161 super(Statistic, self).__setattr__(attr, value) 162 163 def getValue(self): 164 raise AttributeError, 'getValue() must be defined' 165 166 def zero(self): 167 return False --- 554 unchanged lines hidden --- | 180 else: 181 super(Statistic, self).__setattr__(attr, value) 182 183 def getValue(self): 184 raise AttributeError, 'getValue() must be defined' 185 186 def zero(self): 187 return False --- 554 unchanged lines hidden --- |