Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niclaurenti committed Apr 16, 2024
1 parent 4a89481 commit ef193fd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
36 changes: 25 additions & 11 deletions pywrap/pywrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,16 @@ PYBIND11_MODULE(_core, m) {
.def("GetHigher", &Value::GetHigher)
.def("GetLower", &Value::GetLower);

// CoefficientFunction
py::class_<CoefficientFunction>(
m, "CoefficientFunction"
)
.def("GetOrder", &CoefficientFunction::GetOrder)
.def("GetKind", &CoefficientFunction::GetKind)
.def("GetChannel", &CoefficientFunction::GetChannel);

// ApproximateCoefficientFunction
py::class_<ApproximateCoefficientFunction>(
py::class_<ApproximateCoefficientFunction, CoefficientFunction>(
m, "ApproximateCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -87,7 +95,7 @@ PYBIND11_MODULE(_core, m) {
);

// ApproximateCoefficientFunctionKLMV
py::class_<ApproximateCoefficientFunctionKLMV>(
py::class_<ApproximateCoefficientFunctionKLMV, CoefficientFunction>(
m, "ApproximateCoefficientFunctionKLMV"
)
.def(
Expand Down Expand Up @@ -131,7 +139,7 @@ PYBIND11_MODULE(_core, m) {
);

// AsymptoticCoefficientFunction
py::class_<AsymptoticCoefficientFunction>(
py::class_<AsymptoticCoefficientFunction, CoefficientFunction>(
m, "AsymptoticCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -171,7 +179,7 @@ PYBIND11_MODULE(_core, m) {
);

// ExactCoefficientFunction
py::class_<ExactCoefficientFunction>(m, "ExactCoefficientFunction")
py::class_<ExactCoefficientFunction, CoefficientFunction>(m, "ExactCoefficientFunction")
.def(
py::init<
const int &, const char &, const char &, const double &,
Expand Down Expand Up @@ -208,8 +216,14 @@ PYBIND11_MODULE(_core, m) {
py::arg("m2Q2"), py::arg("m2mu2"), py::arg("nf")
);

// AbstractHighEnergyCoefficientFunction
py::class_<AbstractHighEnergyCoefficientFunction, CoefficientFunction>(
m, "AbstractHighEnergyCoefficientFunction"
)
.def("GetNLL", &AbstractHighEnergyCoefficientFunction::GetNLL);

// HighEnergyCoefficientFunction
py::class_<HighEnergyCoefficientFunction>(
py::class_<HighEnergyCoefficientFunction, AbstractHighEnergyCoefficientFunction>(
m, "HighEnergyCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -247,7 +261,7 @@ PYBIND11_MODULE(_core, m) {
);

// HighEnergyHighScaleCoefficientFunction
py::class_<HighEnergyHighScaleCoefficientFunction>(
py::class_<HighEnergyHighScaleCoefficientFunction, AbstractHighEnergyCoefficientFunction>(
m, "HighEnergyHighScaleCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -285,7 +299,7 @@ PYBIND11_MODULE(_core, m) {
);

// PowerTermsCoefficientFunction
py::class_<PowerTermsCoefficientFunction>(
py::class_<PowerTermsCoefficientFunction, AbstractHighEnergyCoefficientFunction>(
m, "PowerTermsCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -323,7 +337,7 @@ PYBIND11_MODULE(_core, m) {
);

// HighScaleCoefficientFunction
py::class_<HighScaleCoefficientFunction>(m, "HighScaleCoefficientFunction")
py::class_<HighScaleCoefficientFunction, CoefficientFunction>(m, "HighScaleCoefficientFunction")
.def(
py::init<const int &, const char &, const char &, const string &>(),
py::arg("order"), py::arg("kind"), py::arg("channel"),
Expand Down Expand Up @@ -358,7 +372,7 @@ PYBIND11_MODULE(_core, m) {
);

// HighScaleSplitLogs
py::class_<HighScaleSplitLogs>(m, "HighScaleSplitLogs")
py::class_<HighScaleSplitLogs, CoefficientFunction>(m, "HighScaleSplitLogs")
.def(
py::init<const int &, const char &, const char &, const string &>(),
py::arg("order"), py::arg("kind"), py::arg("channel"),
Expand All @@ -382,7 +396,7 @@ PYBIND11_MODULE(_core, m) {
);

// MasslessCoefficientFunction
py::class_<MasslessCoefficientFunction>(m, "MasslessCoefficientFunction")
py::class_<MasslessCoefficientFunction, CoefficientFunction>(m, "MasslessCoefficientFunction")
.def(
py::init<const int &, const char &, const char &>(),
py::arg("order"), py::arg("kind"), py::arg("channel")
Expand Down Expand Up @@ -440,7 +454,7 @@ PYBIND11_MODULE(_core, m) {
.def("Local", &ConvolutedSplittingFunctions::Local, py::arg("nf"));

// ThresholdCoefficientFunction
py::class_<ThresholdCoefficientFunction>(m, "ThresholdCoefficientFunction")
py::class_<ThresholdCoefficientFunction, CoefficientFunction>(m, "ThresholdCoefficientFunction")
.def(
py::init<const int &, const char &, const char &>(),
py::arg("order"), py::arg("kind"), py::arg("channel")
Expand Down
10 changes: 10 additions & 0 deletions tests/test_approx_coeff_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
import oldadani as oldad
import numpy as np

def test_coeff_func():
for order in range(1, 3 + 1):
for kind in ["2", "L"]:
for channel in ["q", "g"]:
app = ad.ApproximateCoefficientFunction(order, kind, channel)
assert app.GetOrder() == order
assert app.GetKind() == kind
assert app.GetChannel() == channel
del app

def test_mudependent_terms():
for order in [2, 3]:
for channel in ['g', 'q']:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_highenergy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
import oldadani as old
import numpy as np

def test_nll():
for nll in [True, False]:
he = ad.HighEnergyCoefficientFunction(3, "2", "g", NLL=nll)
hehs = ad.HighEnergyHighScaleCoefficientFunction(3, "2", "g", NLL=nll)
pt = ad.PowerTermsCoefficientFunction(3, "2", "g", NLL=nll)
assert he.GetNLL() == nll
assert hehs.GetNLL() == nll
assert pt.GetNLL() == nll

def test_highenergy_as2_oldadani():
for kind in ['2', 'L']:
for channel in ['g', 'q']:
Expand Down

0 comments on commit ef193fd

Please sign in to comment.