Skip to content

Commit

Permalink
Added extra tests to please codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
jmafoster1 committed Jan 6, 2025
1 parent 279f462 commit ec079b4
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
import pandas as pd
from operator import sub

from causal_testing.estimation.genetic_programming_regression_fitter import GP

Expand All @@ -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,))

0 comments on commit ec079b4

Please sign in to comment.