Ejemplo n.º 1
0
    """
    For this test, a map where its correction maps are:
    (chi=[1,1,...1], e0=[13000,13000,...13000], e0u=[2,2,...2],
    lt=[5000,5000,...5000], ltu=[3,3,...3])
    has been generated.
    """

    maps = read_maps(map_filename)
    assert np.all(maps.chi2 == 1)
    assert np.all(maps.e0 == 13000)
    assert np.all(maps.e0u == 2)
    assert np.all(maps.lt == 5000)
    assert np.all(maps.ltu == 3)


@given(random_length_float_arrays(min_value=0, max_value=3e4))
def test_correct_geometry_properly(x):
    assert_array_equal(correct_geometry_(x), (1 / x))


@given(float_arrays(min_value=0, max_value=530),
       float_arrays(min_value=1, max_value=1e4))
def test_correct_geometry_properly(z, lt):
    compute_corr = np.exp(z / lt)
    assert_array_equal(correct_lifetime_(z, lt), compute_corr)


@given(floats(min_value=0, max_value=1e4))
def test_time_coefs_corr(map_filename, time):
    """
    In the map taken as input, none of the parameters
Ejemplo n.º 2
0
from .fit_functions import sigmoid
from .fit_functions import compute_drift_v
from .fit_functions import chi2f
from .fit_functions import sigmoid
from .fit_functions import compute_drift_v
from .fit_functions import relative_errors
from .fit_functions import to_relative
from .fit_functions import fit_profile_1d_expo
from .fit_functions import fit_slices_2d_gauss
from .fit_functions import fit_slices_2d_expo

from .kr_types import Measurement
sensible_floats = floats(-1e4, +1e4)
fractions = floats(0, 1)
sensible_arrays_variable = random_length_float_arrays(1,
                                                      10,
                                                      min_value=-1e4,
                                                      max_value=1e4)
sensible_arrays_fixed = float_arrays(5, min_value=-1e4, max_value=1e4)
measurements = builds(Measurement, sensible_arrays_fixed,
                      sensible_arrays_fixed.map(abs))


def test_get_chi2f_when_data_equals_error_and_fit_equals_zero():
    Nevt = int(1e6)
    xdata = np.zeros(Nevt)  # Dummy value, not needed
    ydata = np.random.uniform(1, 100, Nevt)
    errs = ydata
    f = lambda x: np.zeros_like(x)
    chi2 = chi2f(f, 0, xdata, ydata, errs)
    assert chi2 == approx(1, rel=1e-3)