Lines Matching refs:self

73     def __scalar__(self):
74 raise AttributeError, "must define __scalar__ for %s" % (type (self))
75 def __vector__(self):
76 raise AttributeError, "must define __vector__ for %s" % (type (self))
78 def __add__(self, other):
79 return BinaryProxy(operator.__add__, self, other)
80 def __sub__(self, other):
81 return BinaryProxy(operator.__sub__, self, other)
82 def __mul__(self, other):
83 return BinaryProxy(operator.__mul__, self, other)
84 def __div__(self, other):
85 return BinaryProxy(operator.__div__, self, other)
86 def __truediv__(self, other):
87 return BinaryProxy(operator.__truediv__, self, other)
88 def __floordiv__(self, other):
89 return BinaryProxy(operator.__floordiv__, self, other)
91 def __radd__(self, other):
92 return BinaryProxy(operator.__add__, other, self)
93 def __rsub__(self, other):
94 return BinaryProxy(operator.__sub__, other, self)
95 def __rmul__(self, other):
96 return BinaryProxy(operator.__mul__, other, self)
97 def __rdiv__(self, other):
98 return BinaryProxy(operator.__div__, other, self)
99 def __rtruediv__(self, other):
100 return BinaryProxy(operator.__truediv__, other, self)
101 def __rfloordiv__(self, other):
102 return BinaryProxy(operator.__floordiv__, other, self)
104 def __neg__(self):
105 return UnaryProxy(operator.__neg__, self)
106 def __pos__(self):
107 return UnaryProxy(operator.__pos__, self)
108 def __abs__(self):
109 return UnaryProxy(operator.__abs__, self)
112 def __scalar__(self):
115 def __vector__(self):
118 def __value__(self, run):
122 def __init__(self, proxy, index):
123 self.proxy = proxy
124 self.index = index
126 def __scalar__(self):
129 def __vector__(self):
132 def __value__(self, run):
133 return value(self.proxy, run, self.index)
136 def __scalar__(self):
139 def __vector__(self):
142 def __value__(self, run, index):
145 def __getitem__(self, index):
146 return VectorItemProxy(self, index)
149 def __init__(self, constant):
150 self.constant = constant
151 def __value__(self, run):
152 return self.constant
153 def __str__(self):
154 return str(self.constant)
157 def __init__(self, constant):
158 self.constant = constant
159 def __value__(self, run, index):
160 return self.constant[index]
161 def __len__(self):
162 return len(self.constant)
163 def __str__(self):
164 return str(self.constant)
177 def __getattr__(self, attr):
179 result = self.source.data(self, self.ticks)
180 self.data = result.data
181 self.x = result.x
182 self.y = result.y
183 return super(Statistic, self).__getattribute__(attr)
185 def __setattr__(self, attr, value):
189 if getattr(self, attr) != value:
190 if hasattr(self, 'data'):
191 delattr(self, 'data')
193 super(Statistic, self).__setattr__(attr, value)
195 def __str__(self):
196 return self.name
199 def __getattr__(self, attr):
201 if scalar(self):
202 return self.__scalarvalue__
203 if vector(self):
204 return self.__vectorvalue__
206 if vector(self):
207 return self.__vectorlen__
208 return super(ValueProxy, self).__getattribute__(attr)
211 def __init__(self, op, arg):
212 self.op = op
213 self.arg = WrapValue(arg)
215 def __scalar__(self):
216 return scalar(self.arg)
218 def __vector__(self):
219 return vector(self.arg)
221 def __scalarvalue__(self, run):
222 val = value(self.arg, run)
225 return self.op(val)
227 def __vectorvalue__(self, run, index):
228 val = value(self.arg, run, index)
231 return self.op(val)
233 def __vectorlen__(self):
234 return len(unproxy(self.arg))
236 def __str__(self):
237 if self.op == operator.__neg__:
238 return '-%s' % str(self.arg)
239 if self.op == operator.__pos__:
240 return '+%s' % str(self.arg)
241 if self.op == operator.__abs__:
242 return 'abs(%s)' % self.arg
245 def __init__(self, op, arg0, arg1):
246 super(BinaryProxy, self).__init__()
247 self.op = op
248 self.arg0 = WrapValue(arg0)
249 self.arg1 = WrapValue(arg1)
251 def __scalar__(self):
252 return scalar(self.arg0) and scalar(self.arg1)
254 def __vector__(self):
255 return vector(self.arg0) or vector(self.arg1)
257 def __scalarvalue__(self, run):
258 val0 = value(self.arg0, run)
259 val1 = value(self.arg1, run)
263 return self.op(val0, val1)
267 def __vectorvalue__(self, run, index):
268 if scalar(self.arg0):
269 val0 = value(self.arg0, run)
270 if vector(self.arg0):
271 val0 = value(self.arg0, run, index)
272 if scalar(self.arg1):
273 val1 = value(self.arg1, run)
274 if vector(self.arg1):
275 val1 = value(self.arg1, run, index)
281 return self.op(val0, val1)
285 def __vectorlen__(self):
286 if vector(self.arg0) and scalar(self.arg1):
287 return len(self.arg0)
288 if scalar(self.arg0) and vector(self.arg1):
289 return len(self.arg1)
291 len0 = len(self.arg0)
292 len1 = len(self.arg1)
300 def __str__(self):
308 return '(%s %s %s)' % (str(self.arg0), ops[self.op], str(self.arg1))
311 def __init__(self, name, dict):
312 self.name = name
313 self.dict = dict
315 def __unproxy__(self):
316 return unproxy(self.dict[self.name])
318 def __getitem__(self, index):
319 return ItemProxy(self, index)
321 def __getattr__(self, attr):
322 return AttrProxy(self, attr)
324 def __str__(self):
325 return str(self.dict[self.name])
328 def __init__(self, proxy, index):
329 self.proxy = proxy
330 self.index = index
332 def __unproxy__(self):
333 return unproxy(unproxy(self.proxy)[self.index])
335 def __str__(self):
336 return '%s[%s]' % (self.proxy, self.index)
339 def __init__(self, proxy, attr):
340 self.proxy = proxy
341 self.attr = attr
343 def __unproxy__(self):
344 proxy = unproxy(self.proxy)
346 attr = getattr(proxy, self.attr)
351 def __str__(self):
352 return '%s.%s' % (self.proxy, self.attr)
355 def __init__(self, dict=None, **kwargs):
356 self.__dict__['dict'] = {}
359 self.dict.update(dict)
362 self.dict.update(kwargs)
364 def __getattr__(self, name):
365 return Proxy(name, self.dict)
367 def __setattr__(self, attr, value):
368 self.dict[attr] = value
371 def __value__(self, run):
372 if run not in self.data:
374 return self.data[run][0][0]
376 def display(self, run=None):
379 p.name = self.name
380 p.desc = self.desc
381 p.value = value(self, run)
382 p.flags = self.flags
383 p.precision = self.precision
384 if display.all or (self.flags & flags.printable):
388 def __value__(self, run, item):
389 if run not in self.data:
391 return self.data[run][item][0]
393 def __len__(self):
394 return self.x
396 def display(self, run=None):
399 d.name = self.name
400 d.desc = self.desc
401 d.value = [ value(self, run, i) for i in xrange(len(self)) ]
402 d.flags = self.flags
403 d.precision = self.precision
407 def __getattribute__(self, attr):
409 return super(Formula, self).__getattribute__(attr)
411 formula = re.sub(':', '__', self.formula)
412 value = eval(formula, self.source.stattop)
415 def __str__(self):
416 return self.name
419 def __init__(self, sums, squares, samples):
420 self.sums = sums
421 self.squares = squares
422 self.samples = samples
424 def display(self, name, desc, flags, precision):
430 if self.samples > 0:
432 p.value = self.sums / self.samples
436 if self.samples > 1:
437 var = (self.samples * self.squares - self.sums ** 2) \
438 / (self.samples * (self.samples - 1))
448 p.value = self.samples
451 def comparable(self, other):
454 def __eq__(self, other):
455 return self.sums == other.sums and self.squares == other.squares and \
456 self.samples == other.samples
458 def __isub__(self, other):
459 self.sums -= other.sums
460 self.squares -= other.squares
461 self.samples -= other.samples
462 return self
464 def __iadd__(self, other):
465 self.sums += other.sums
466 self.squares += other.squares
467 self.samples += other.samples
468 return self
470 def __itruediv__(self, other):
472 return self
473 self.sums /= other
474 self.squares /= other
475 self.samples /= other
476 return self
479 def __init__(self, sums, squares, samples, minval, maxval,
481 self.sums = sums
482 self.squares = squares
483 self.samples = samples
484 self.minval = minval
485 self.maxval = maxval
486 self.under = under
487 self.vec = vec
488 self.over = over
489 self.min = min
490 self.max = max
491 self.bsize = bsize
492 self.size = size
494 def display(self, name, desc, flags, precision):
501 p.value = self.minval
505 p.value = self.maxval
509 p.value = self.under
512 i = self.min
513 for val in self.vec[:-1]:
514 p.name = name + '[%d:%d]' % (i, i + self.bsize - 1)
517 i += self.bsize
519 p.name = name + '[%d:%d]' % (i, self.max)
520 p.value = self.vec[-1]
525 p.value = self.over
528 SimpleDist.display(self, name, desc, flags, precision)
530 def comparable(self, other):
531 return self.min == other.min and self.max == other.max and \
532 self.bsize == other.bsize and self.size == other.size
534 def __eq__(self, other):
535 return self.sums == other.sums and self.squares == other.squares and \
536 self.samples == other.samples
538 def __isub__(self, other):
539 self.sums -= other.sums
540 self.squares -= other.squares
541 self.samples -= other.samples
544 self.minval = min(self.minval, other.minval)
545 self.maxval = max(self.maxval, other.maxval)
546 self.under -= under
547 self.vec = map(lambda x,y: x - y, self.vec, other.vec)
548 self.over -= over
549 return self
551 def __iadd__(self, other):
552 if not self.samples and other.samples:
553 self = other
554 return self
556 self.sums += other.sums
557 self.squares += other.squares
558 self.samples += other.samples
561 self.minval = min(self.minval, other.minval)
562 self.maxval = max(self.maxval, other.maxval)
563 self.under += other.under
564 self.vec = map(lambda x,y: x + y, self.vec, other.vec)
565 self.over += other.over
566 return self
568 def __itruediv__(self, other):
570 return self
571 self.sums /= other
572 self.squares /= other
573 self.samples /= other
575 if self.samples:
576 self.under /= other
577 for i in xrange(len(self.vec)):
578 self.vec[i] /= other
579 self.over /= other
580 return self
583 def display(self):
585 if not display.all and not (self.flags & flags.printable):
588 self.dist.display(self.name, self.desc, self.flags, self.precision)
590 def comparable(self, other):
591 return self.name == other.name and \
592 self.dist.compareable(other.dist)
594 def __eq__(self, other):
595 return self.dist == other.dist
597 def __isub__(self, other):
598 self.dist -= other.dist
599 return self
601 def __iadd__(self, other):
602 self.dist += other.dist
603 return self
605 def __itruediv__(self, other):
607 return self
608 self.dist /= other
609 return self
612 def display(self):
614 if not display.all and not (self.flags & flags.printable):
617 if isinstance(self.dist, SimpleDist):
620 for dist,sn,sd,i in map(None, self.dist, self.subnames, self.subdescs,
621 range(len(self.dist))):
623 name = '%s.%s' % (self.name, sn)
625 name = '%s[%d]' % (self.name, i)
630 desc = self.desc
632 dist.display(name, desc, self.flags, self.precision)
634 if (self.flags & flags.total) or 1:
635 if isinstance(self.dist[0], SimpleDist):
637 reduce(sums, [d.sums for d in self.dist]),
638 reduce(sums, [d.squares for d in self.dist]),
639 reduce(sums, [d.samples for d in self.dist]))
642 reduce(sums, [d.sums for d in self.dist]),
643 reduce(sums, [d.squares for d in self.dist]),
644 reduce(sums, [d.samples for d in self.dist]),
645 min([d.minval for d in self.dist]),
646 max([d.maxval for d in self.dist]),
647 reduce(sums, [d.under for d in self.dist]),
648 reduce(sums, [d.vec for d in self.dist]),
649 reduce(sums, [d.over for d in self.dist]),
655 name = '%s.total' % (self.name)
656 desc = self.desc
657 disttotal.display(name, desc, self.flags, self.precision)
659 def comparable(self, other):
660 return self.name == other.name and \
662 self.dist,
665 def __eq__(self, other):
666 return alltrue(map(lambda x, y : x == y, self.dist, other.dist))
668 def __isub__(self, other):
669 if isinstance(self.dist, (list, tuple)) and \
671 for sd,od in zip(self.dist, other.dist):
674 self.dist -= other.dist
675 return self
677 def __iadd__(self, other):
678 if isinstance(self.dist, (list, tuple)) and \
680 for sd,od in zip(self.dist, other.dist):
683 self.dist += other.dist
684 return self
686 def __itruediv__(self, other):
688 return self
689 if isinstance(self.dist, (list, tuple)):
690 for dist in self.dist:
693 self.dist /= other
694 return self
697 def display(self):
699 if not display.all and not (self.flags & flags.printable):
703 d.__dict__.update(self.__dict__)
705 if self.__dict__.has_key('ysubnames'):
706 ysubnames = list(self.ysubnames)
707 slack = self.x - len(ysubnames)
711 ysubnames = range(self.x)
714 o = x * self.y
715 d.value = self.value[o:o+self.y]
716 d.name = '%s[%s]' % (self.name, sname)
719 if self.flags & flags.total:
721 for y in range(self.y):
723 for x in range(self.x):
724 xtot += self.value[y + x * self.x]
727 d.name = self.name + '.total'
730 def comparable(self, other):
731 return self.name == other.name and self.x == other.x and \
732 self.y == other.y
734 def __eq__(self, other):
737 def __isub__(self, other):
738 return self
740 def __iadd__(self, other):
741 return self
743 def __itruediv__(self, other):
745 return self
746 return self