Skip to content

Commit

Permalink
Rename files (icaro_components -> krmap_functions)
Browse files Browse the repository at this point in the history
  • Loading branch information
carhc committed Oct 16, 2024
1 parent d98450c commit 341425f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from hypothesis import given, settings
from hypothesis.strategies import floats, integers

from .. reco import icaro_components as icarcomp
from .. reco import krmap_functions as krf
from ..types.symbols import KrFitFunction
from .. evm.ic_containers import FitFunction
from .. core.fit_functions import expo
Expand All @@ -21,7 +21,7 @@
def test_lin_function_output_values(x_min, x_max, a, b):
x = np.array([x_min, x_max])
y = a + b * x
a_test, b_test = icarcomp.lin_seed(x, y)
a_test, b_test = krf.lin_seed(x, y)

assert np.isclose(a_test, a)
assert np.isclose(b_test, b)
Expand All @@ -34,7 +34,7 @@ def test_lin_function_output_values(x_min, x_max, a, b):
def test_expo_seed_output_values(zmin, zmax, elt, e0):
x = np.array([zmin, zmax])
y = e0 * np.exp(-x / elt)
e0_test, elt_test = icarcomp.expo_seed(x, y)
e0_test, elt_test = krf.expo_seed(x, y)

assert np.isclose( e0_test, e0, rtol=0.1)
assert np.isclose(elt_test, elt, rtol=0.1)
Expand All @@ -48,9 +48,9 @@ def sample_df():


def test_select_fit_variables(sample_df):
x_linear, y_linear = icarcomp.select_fit_variables(KrFitFunction.linear, sample_df)
x_expo, y_expo = icarcomp.select_fit_variables(KrFitFunction.expo, sample_df)
x_log_lin, y_log_lin = icarcomp.select_fit_variables(KrFitFunction.log_lin, sample_df)
x_linear, y_linear = krf.select_fit_variables(KrFitFunction.linear, sample_df)
x_expo, y_expo = krf.select_fit_variables(KrFitFunction.expo, sample_df)
x_log_lin, y_log_lin = krf.select_fit_variables(KrFitFunction.log_lin, sample_df)

# First return the same for the 3 cases
assert (x_expo == x_linear).all()
Expand All @@ -71,9 +71,9 @@ def test_get_function_and_seed_lt_with_data(x_min, x_max, steps, e0, lt):
x = np.linspace(x_min, x_max, steps)
y = expo(x, e0, lt)

fit_func_lin, seed_func_lin = icarcomp.get_function_and_seed_lt(KrFitFunction.linear)
fit_func_expo, seed_func_expo = icarcomp.get_function_and_seed_lt(KrFitFunction.expo)
fit_func_log_lin, seed_func_log_lin = icarcomp.get_function_and_seed_lt(KrFitFunction.log_lin)
fit_func_lin, seed_func_lin = krf.get_function_and_seed_lt(KrFitFunction.linear)
fit_func_expo, seed_func_expo = krf.get_function_and_seed_lt(KrFitFunction.expo)
fit_func_log_lin, seed_func_log_lin = krf.get_function_and_seed_lt(KrFitFunction.log_lin)

popt_lin, _ = so.curve_fit(fit_func_lin, x, y, p0=seed_func_lin (x, y))
popt_expo, _ = so.curve_fit(fit_func_expo, x, y, p0=seed_func_expo (x, y))
Expand All @@ -93,7 +93,7 @@ def test_transform_parameters(a, b):
fit_output = FitFunction(values=[a, b], errors=errors, cov=np.array([[0.04, 0.02], [0.02, 0.04]]),
fn=None, chi2=None, pvalue=None, infodict=None, mesg=None, ier=None)

transformed_par, transformed_err, transformed_cov = icarcomp.transform_parameters(fit_output)
transformed_par, transformed_err, transformed_cov = krf.transform_parameters(fit_output)

E0_expected = np.exp(-a)
s_E0_expected = np.abs(E0_expected * errors[0])
Expand Down

0 comments on commit 341425f

Please sign in to comment.