Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 70d940cdad
Fetching contributors…

Cannot retrieve contributors at this time

file 31 lines (25 sloc) 1.139 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
from primitive_util import ListSlotPrimitiveConversion
from stats import MeanVarStat

class SmallGainStat(ListSlotPrimitiveConversion):
    __slots__ = ('win_given_any_gain',
                 'win_given_no_gain',
                 'win_weighted_gain')

    def __init__(self):
        self.win_given_any_gain = MeanVarStat()
        self.win_given_no_gain = MeanVarStat()
        self.win_weighted_gain = MeanVarStat()

    def merge(self, other):
        self.win_given_any_gain.merge(other.win_given_any_gain)
        self.win_given_no_gain.merge(other.win_given_no_gain)
        self.win_weighted_gain.merge(other.win_weighted_gain)

    def avail(self):
        return self.win_given_any_gain.freq() + self.win_given_no_gain.freq()

    def __str__(self):
        return 'a <%s> n <%s> w <%s>' % (self.win_given_any_gain,
                                         self.win_given_no_gain,
                                         self.win_weighted_gain)

    def to_readable_primitive_object(self):
        ret = {}
        for name in self.__slots__:
            ret[name] = getattr(self, name).to_primitive_object()
        return ret
Something went wrong with that request. Please try again.