Beispiel #1
0
    def test_builddata_pdata(self):
        " MultiFitter.builddata(pdata=..., ...) "
        # ncg=1
        fitter = MultiFitter(models=self.make_models(ncg=1))
        data = fitter.builddata(data=self.data, mopt=fitter.mopt)
        data['extra'] = np.array([1.])
        ndata = fitter.builddata(pdata=data, mopt=fitter.mopt)
        del data['extra']
        self.assertEqual(str(data), str(ndata))

        # ncg=2
        fitter = MultiFitter(models=self.make_models(ncg=2))
        data = fitter.builddata(data=self.data, mopt=fitter.mopt)
        data['extra'] = np.array([1.])
        ndata = fitter.builddata(pdata=data, mopt=fitter.mopt)
        del data['extra']
        self.assertEqual(str(data), str(ndata))
Beispiel #2
0
    def test_builddata(self):
        " MultiFitter.builddata "
        # ncg=1
        fitter = MultiFitter(models=self.make_models(ncg=1))
        data = fitter.builddata(data=self.data, mopt=fitter.mopt)
        del self.data['dummy']
        self.assertEqual(str(data), str(self.data))

        # ncg=2
        simpledata = gv.BufferDict()
        simpledata['l'] = ['1.0(3)', '2.0(4)', '3.0(3)', '4.0(4)']
        simpledata['c1'] = ['1.0(3)', '2.0(4)', '3.0(3)', '4.0(4)']
        simpledata['c2'] = ['1.0(3)', '2.0(4)', '3.0(3)', '4.0(4)']
        simpledata = gv.gvar(simpledata)
        fitter = MultiFitter(models=self.make_models(ncg=2))
        data = fitter.builddata(data=simpledata, mopt=fitter.mopt)
        for k in simpledata:
            self.assertEqual(str(data[k]), '[1.50(25) 3.50(25)]')
Beispiel #3
0
 def test_builddata_marginalized(self):
     " MultiFitter.builddata with marginalization "
     fitter = MultiFitter(models=self.make_models(ncg=1), mopt=True)
     data = fitter.builddata(self.data, prior=self.prior)
     self.assertEqual(
         str(self.data['l'] - self.prior['b'] * self.x),
         str(data['l']),
     )
     self.assertEqual(str(self.data['c1']), str(data['c1']))
     self.assertEqual(str(self.data['c2']), str(data['c2']))