Esempio n. 1
0
def main(jobtype, model, nevts, repetitions, outputfile, backend):

    minkit.initialize(backend)

    pdf = getattr(minkit_models, model)()

    if jobtype == 'generate':
        times = generate(pdf, nevts, repetitions)
    elif jobtype == 'fit':
        times = fit(pdf, nevts, repetitions)
    else:
        raise ValueError(f'Unknown job type {jobtype}')

    with open(outputfile, 'at') as f:
        f.write(f'{times.mean()} {times.std()}\n')
Esempio n. 2
0
'''
Test the "pdf_core" module.
'''
from helpers import check_parameters, check_pdfs, check_multi_pdfs, fit_test, setting_numpy_seed
import json
import helpers
import numpy as np
import os
import minkit
import pytest

helpers.configure_logging()
minkit.initialize()


@pytest.mark.pdfs
@setting_numpy_seed
def test_pdf():
    '''
    General tests for the PDF class.
    '''
    # Create a Polynomial PDF
    m = minkit.Parameter('m', bounds=(0, 10))
    p1 = minkit.Parameter('p1', 0.)
    p2 = minkit.Parameter('p2', 0.)
    p = minkit.Polynomial('polynomial', m, p1, p2)

    m.set_range('sides', [(0, 4), (6, 10)])

    # integral
    assert np.allclose(p.integral(integral_range='full', range='full'), 1.)