From ef193fd0dea9843c9602f497fc5f1781471ddc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Tue, 16 Apr 2024 15:49:23 +0200 Subject: [PATCH] Add tests --- pywrap/pywrap.cc | 36 +++++++++++++++++++++++---------- tests/test_approx_coeff_func.py | 10 +++++++++ tests/test_highenergy.py | 9 +++++++++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/pywrap/pywrap.cc b/pywrap/pywrap.cc index eabf3736..70e3cff9 100644 --- a/pywrap/pywrap.cc +++ b/pywrap/pywrap.cc @@ -42,8 +42,16 @@ PYBIND11_MODULE(_core, m) { .def("GetHigher", &Value::GetHigher) .def("GetLower", &Value::GetLower); + // CoefficientFunction + py::class_( + m, "CoefficientFunction" + ) + .def("GetOrder", &CoefficientFunction::GetOrder) + .def("GetKind", &CoefficientFunction::GetKind) + .def("GetChannel", &CoefficientFunction::GetChannel); + // ApproximateCoefficientFunction - py::class_( + py::class_( m, "ApproximateCoefficientFunction" ) .def( @@ -87,7 +95,7 @@ PYBIND11_MODULE(_core, m) { ); // ApproximateCoefficientFunctionKLMV - py::class_( + py::class_( m, "ApproximateCoefficientFunctionKLMV" ) .def( @@ -131,7 +139,7 @@ PYBIND11_MODULE(_core, m) { ); // AsymptoticCoefficientFunction - py::class_( + py::class_( m, "AsymptoticCoefficientFunction" ) .def( @@ -171,7 +179,7 @@ PYBIND11_MODULE(_core, m) { ); // ExactCoefficientFunction - py::class_(m, "ExactCoefficientFunction") + py::class_(m, "ExactCoefficientFunction") .def( py::init< const int &, const char &, const char &, const double &, @@ -208,8 +216,14 @@ PYBIND11_MODULE(_core, m) { py::arg("m2Q2"), py::arg("m2mu2"), py::arg("nf") ); + // AbstractHighEnergyCoefficientFunction + py::class_( + m, "AbstractHighEnergyCoefficientFunction" + ) + .def("GetNLL", &AbstractHighEnergyCoefficientFunction::GetNLL); + // HighEnergyCoefficientFunction - py::class_( + py::class_( m, "HighEnergyCoefficientFunction" ) .def( @@ -247,7 +261,7 @@ PYBIND11_MODULE(_core, m) { ); // HighEnergyHighScaleCoefficientFunction - py::class_( + py::class_( m, "HighEnergyHighScaleCoefficientFunction" ) .def( @@ -285,7 +299,7 @@ PYBIND11_MODULE(_core, m) { ); // PowerTermsCoefficientFunction - py::class_( + py::class_( m, "PowerTermsCoefficientFunction" ) .def( @@ -323,7 +337,7 @@ PYBIND11_MODULE(_core, m) { ); // HighScaleCoefficientFunction - py::class_(m, "HighScaleCoefficientFunction") + py::class_(m, "HighScaleCoefficientFunction") .def( py::init(), py::arg("order"), py::arg("kind"), py::arg("channel"), @@ -358,7 +372,7 @@ PYBIND11_MODULE(_core, m) { ); // HighScaleSplitLogs - py::class_(m, "HighScaleSplitLogs") + py::class_(m, "HighScaleSplitLogs") .def( py::init(), py::arg("order"), py::arg("kind"), py::arg("channel"), @@ -382,7 +396,7 @@ PYBIND11_MODULE(_core, m) { ); // MasslessCoefficientFunction - py::class_(m, "MasslessCoefficientFunction") + py::class_(m, "MasslessCoefficientFunction") .def( py::init(), py::arg("order"), py::arg("kind"), py::arg("channel") @@ -440,7 +454,7 @@ PYBIND11_MODULE(_core, m) { .def("Local", &ConvolutedSplittingFunctions::Local, py::arg("nf")); // ThresholdCoefficientFunction - py::class_(m, "ThresholdCoefficientFunction") + py::class_(m, "ThresholdCoefficientFunction") .def( py::init(), py::arg("order"), py::arg("kind"), py::arg("channel") diff --git a/tests/test_approx_coeff_func.py b/tests/test_approx_coeff_func.py index a4325dd5..ee6aa613 100644 --- a/tests/test_approx_coeff_func.py +++ b/tests/test_approx_coeff_func.py @@ -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']: diff --git a/tests/test_highenergy.py b/tests/test_highenergy.py index 3704c2d7..5276e041 100644 --- a/tests/test_highenergy.py +++ b/tests/test_highenergy.py @@ -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']: