1# Copyright (c) 2003-2004 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 9 unchanged lines hidden (view full) --- 18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26# 27# Authors: Nathan Binkert |
28 29from __future__ import division 30import operator, re, types 31 32class ProxyError(Exception): 33 pass 34 35def unproxy(proxy): --- 135 unchanged lines hidden (view full) --- 171 if isinstance(value, Value): 172 return value 173 174 raise AttributeError, 'Only values can be wrapped' 175 176class Statistic(object): 177 def __getattr__(self, attr): 178 if attr in ('data', 'x', 'y'): |
179 result = self.source.data(self, self.bins, self.ticks) |
180 self.data = result.data 181 self.x = result.x 182 self.y = result.y 183 return super(Statistic, self).__getattribute__(attr) 184 185 def __setattr__(self, attr, value): 186 if attr == 'stat': 187 raise AttributeError, '%s is read only' % stat |
188 if attr in ('source', 'bins', 'ticks'): |
189 if getattr(self, attr) != value: 190 if hasattr(self, 'data'): 191 delattr(self, 'data') 192 193 super(Statistic, self).__setattr__(attr, value) 194 195 def __str__(self): 196 return self.name --- 559 unchanged lines hidden (view full) --- 756 elif data.type == 'VECTORDIST': 757 stat = VectorDist() 758 elif data.type == 'VECTOR2D': 759 stat = Vector2d() 760 elif data.type == 'FORMULA': 761 stat = Formula() 762 763 stat.__dict__['source'] = source |
764 stat.__dict__['bins'] = None |
765 stat.__dict__['ticks'] = None 766 stat.__dict__.update(data.__dict__) 767 768 return stat 769 |