Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 11
0
    def __exit__(self, t, value, traceback):
        if self.file is not None:
            self.file_.close()

        SampleStream.__exit__(self, t, value, traceback)
Exemplo n.º 12
0
    def __init__(self, path='samples.pkl'):
        SampleStream.__init__(self, generator=None)

        self.path = path
        self.samples = []
Exemplo n.º 13
0
 def __init__(self, n=10):
     SampleStream.__init__(self)
     self.n = n
     self.cnt = 0
Exemplo n.º 14
0
 def __init__(self, n=10):
     SampleStream.__init__(self)
     self.n = n
     self.cnt = 0
Exemplo n.º 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]
Exemplo n.º 16
0
    def __init__(self):
        SampleStream.__init__(self)

        self.seen = set()
Exemplo n.º 17
0
Arquivo: Z.py Projeto: wrongu/LOTlib
    def __exit__(self, t, value, traceback):

        print self

        return SampleStream.__exit__(self, t, value, traceback)
Exemplo n.º 18
0
    def __exit__(self, t, value, traceback):

        print self

        return SampleStream.__exit__(self, t, value, traceback)
Exemplo n.º 19
0
 def __init__(self, file=None, prefix='', mode='w'):
     self.__dict__.update(locals())
     SampleStream.__init__(self, generator=None)
Exemplo n.º 20
0
    def __init__(self):
        SampleStream.__init__(self)

        self.seen = set()
Exemplo n.º 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]
Exemplo n.º 22
0
    def __init__(self, path='samples.pkl'):
        SampleStream.__init__(self, generator=None)

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

        SampleStream.__exit__(self, t, value, traceback)
Exemplo n.º 26
0
    def __exit__(self, t, value, traceback):
        self.plot()

        return SampleStream.__exit__(self, t, value, traceback)
Exemplo n.º 27
0
    def __init__(self, key='posterior_score'):
        SampleStream.__init__(self)

        self.key = key
        self.Z = -Infinity
Exemplo n.º 28
0
Arquivo: Z.py Projeto: wrongu/LOTlib
    def __init__(self, key="posterior_score"):
        SampleStream.__init__(self)

        self.key = key
        self.Z = -Infinity
Exemplo n.º 29
0
 def __init__(self, generator=None):
     self.last = None
     SampleStream.__init__(self, generator=generator)
Exemplo n.º 30
0
    def __exit__(self, t, value, traceback):
        self.plot()

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