Пример #1
0
    def __enter__(self):
        SampleStream.__enter__(self)

        if self.file is not None:
            self.file_ = open(self.file, self.mode)
        else:
            self.file_ = stdout
Пример #2
0
    def __enter__(self):
        SampleStream.__enter__(self)

        if self.file is not None:
            self.file_ = open(self.file, self.mode)
        else:
            self.file_ = stdout
Пример #3
0
    def __exit__(self, t, value, traceback):

        f = open(self.path, 'w')
        pickle.dump(self.samples, f)
        f.close()

        SampleStream.__exit__(self, t, value, traceback)
Пример #4
0
    def __exit__(self, t, value, traceback):

        f = open(self.path, 'w')
        pickle.dump(self.samples, f)
        f.close()

        SampleStream.__exit__(self, t, value, traceback)
Пример #5
0
    def __init__(self, generator=None, plot_every=1000, window=False, block=False, file='trace.pdf'):
        self.__dict__.update(locals())

        self.posteriors = []
        self.priors = []
        self.likelihoods = []

        SampleStream.__init__(self, generator)
Пример #6
0
    def __init__(self, N=1000, key='posterior_score', sorted=True):
        """

        :param N: How many samples to store.
        :param key:  The key we sort by
        :param sorted: When we output, do we output sorted? (slightly slower)
        :return:
        """
        self.__dict__.update(locals())
        SampleStream.__init__(self)
        self.top = TopN(N=N, key=key)
Пример #7
0
    def __init__(self, N=1000, key='posterior_score', sorted=True):
        """

        :param N: How many samples to store.
        :param key:  The key we sort by
        :param sorted: When we output, do we output sorted? (slightly slower)
        :return:
        """
        self.__dict__.update(locals())
        SampleStream.__init__(self)
        self.top = TopN(N=N, key=key)
Пример #8
0
    def __init__(self,
                 generator=None,
                 plot_every=1000,
                 window=False,
                 block=False,
                 file='trace.pdf'):
        self.__dict__.update(locals())

        self.posteriors = []
        self.priors = []
        self.likelihoods = []

        SampleStream.__init__(self, generator)
Пример #9
0
    def __exit__(self, t, value, traceback):

        ## Here, only on exit do I give my data (the tops) to my outputs
        for v in self.top.get_all(sorted=sorted):
            # Cannot just call self.process_and_push since self.process always returns None
            if v is not None:
                for a in self.outputs:
                    a.process_and_push(v)

        return SampleStream.__exit__(self, t, value, traceback)
Пример #10
0
    def __exit__(self, t, value, traceback):

        ## Here, only on exit do I give my data (the tops) to my outputs
        for v in self.top.get_all(sorted=sorted):
            # Cannot just call self.process_and_push since self.process always returns None
            if v is not None:
                for a in self.outputs:
                    a.process_and_push(v)

        return SampleStream.__exit__(self, t,value,traceback)
Пример #11
0
    def __exit__(self, t, value, traceback):
        if self.file is not None:
            self.file_.close()

        SampleStream.__exit__(self, t, value, traceback)
Пример #12
0
    def __init__(self, path='samples.pkl'):
        SampleStream.__init__(self, generator=None)

        self.path = path
        self.samples = []
Пример #13
0
 def __init__(self, n=10):
     SampleStream.__init__(self)
     self.n = n
     self.cnt = 0
Пример #14
0
 def __init__(self, n=10):
     SampleStream.__init__(self)
     self.n = n
     self.cnt = 0
Пример #15
0
    def __init__(self, *outputs):
        SampleStream.__init__(self)

        ##UUGH because of the weird associativity, >> will return the last in the chain.
        ## But really my child should be the root of whatever chain I got.
        self.outputs = [o.root() for o in outputs]
Пример #16
0
    def __init__(self):
        SampleStream.__init__(self)

        self.seen = set()
Пример #17
0
Файл: Z.py Проект: wrongu/LOTlib
    def __exit__(self, t, value, traceback):

        print self

        return SampleStream.__exit__(self, t, value, traceback)
Пример #18
0
    def __exit__(self, t, value, traceback):

        print self

        return SampleStream.__exit__(self, t, value, traceback)
Пример #19
0
 def __init__(self, file=None, prefix='', mode='w'):
     self.__dict__.update(locals())
     SampleStream.__init__(self, generator=None)
Пример #20
0
    def __init__(self):
        SampleStream.__init__(self)

        self.seen = set()
Пример #21
0
    def __init__(self, *outputs):
        SampleStream.__init__(self)

        ##UUGH because of the weird associativity, >> will return the last in the chain.
        ## But really my child should be the root of whatever chain I got.
        self.outputs = [o.root() for o in outputs]
Пример #22
0
    def __init__(self, path='samples.pkl'):
        SampleStream.__init__(self, generator=None)

        self.path = path
        self.samples = []
Пример #23
0
 def __init__(self, generator=None):
     self.last = None
     SampleStream.__init__(self, generator=generator)
Пример #24
0
 def __init__(self, file=None, prefix='', mode='w'):
     self.__dict__.update(locals())
     SampleStream.__init__(self, generator=None)
Пример #25
0
    def __exit__(self, t, value, traceback):
        if self.file is not None:
            self.file_.close()

        SampleStream.__exit__(self, t, value, traceback)
Пример #26
0
    def __exit__(self, t, value, traceback):
        self.plot()

        return SampleStream.__exit__(self, t, value, traceback)
Пример #27
0
    def __init__(self, key='posterior_score'):
        SampleStream.__init__(self)

        self.key = key
        self.Z = -Infinity
Пример #28
0
Файл: Z.py Проект: wrongu/LOTlib
    def __init__(self, key="posterior_score"):
        SampleStream.__init__(self)

        self.key = key
        self.Z = -Infinity
Пример #29
0
 def __init__(self, generator=None):
     self.last = None
     SampleStream.__init__(self, generator=generator)
Пример #30
0
    def __exit__(self, t, value, traceback):
        self.plot()

        return SampleStream.__exit__(self, t, value, traceback)