From ec079b4dc328c3945f5c36d5b230e2a8b40b7359 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 6 Jan 2025 08:38:43 +0000 Subject: [PATCH] Added extra tests to please codecov --- ...t_genetic_programming_regression_fitter.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/estimation_tests/test_genetic_programming_regression_fitter.py b/tests/estimation_tests/test_genetic_programming_regression_fitter.py index 4382b819..37dc455d 100644 --- a/tests/estimation_tests/test_genetic_programming_regression_fitter.py +++ b/tests/estimation_tests/test_genetic_programming_regression_fitter.py @@ -1,5 +1,6 @@ import unittest import pandas as pd +from operator import sub from causal_testing.estimation.genetic_programming_regression_fitter import GP @@ -8,3 +9,21 @@ class TestGP(unittest.TestCase): def test_init_invalid_fun_name(self): with self.assertRaises(ValueError): GP(df=pd.DataFrame(), features=[], outcome="", max_order=2, sympy_conversions={"power_1": ""}) + + def test_simplify_string(self): + gp = GP( + df=None, + features=["x1"], + outcome=None, + max_order=1, + ) + self.assertEquals(str(gp.simplify("power_1(x1)")), "x1") + + def test_fitness_string(self): + gp = GP( + df=pd.DataFrame({"x1": [1, 2, 3], "outcome": [2, 3, 4]}), + features=["x1"], + outcome="outcome", + max_order=0, + ) + self.assertEquals(gp.fitness("add(x1, 1)"), (0,))