Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_AddPdf():
import ROOT
df = get_test_df()
assert isinstance(df, pd.DataFrame)
bkg = Chebychev(('mbc', 0, 1))
sig = Gauss(('mbc', 0, 1))
pdf = sig+bkg
#pdf.fit(df)
#pdf.plot('test2.pdf')
assert isinstance(pdf, AddPdf)
assert isinstance(pdf.roo_pdf, ROOT.RooAbsPdf)
def test_AddPdf_fit():
import ROOT
df = get_test_df()
assert isinstance(df, pd.DataFrame)
bkg = Chebychev(('mbc', 0, 1))
sig = Gauss(('mbc', 0, 1))
pdf = sig+bkg
pdf.fit(df)
#pdf.plot('test2.pdf')
assert isinstance(pdf, AddPdf)
assert isinstance(pdf.roo_pdf, ROOT.RooAbsPdf)
# First we build the template of some data
template_data = np.random.normal(0, 1, 1000)
pdf = HistPDF(
('x', -3, 3),
template_data,
nbins=10,
)
pdf.fix()
pdf.get()
# And now we can fit that template to some new data to measure the yield
fit_data = np.random.normal(0, 1, 5000)
pdf2 = AddPdf([pdf])
pdf2.fit(fit_data)
# pdf2.plot('example_hist.pdf') # Bug causes this to error atm
pdf2.get()
pdf2.plot('histogram_template_fit.pdf')