Skip to content

Commit ec079b4

Browse files
committed
Added extra tests to please codecov
1 parent 279f462 commit ec079b4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/estimation_tests/test_genetic_programming_regression_fitter.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import unittest
22
import pandas as pd
3+
from operator import sub
34

45
from causal_testing.estimation.genetic_programming_regression_fitter import GP
56

@@ -8,3 +9,21 @@ class TestGP(unittest.TestCase):
89
def test_init_invalid_fun_name(self):
910
with self.assertRaises(ValueError):
1011
GP(df=pd.DataFrame(), features=[], outcome="", max_order=2, sympy_conversions={"power_1": ""})
12+
13+
def test_simplify_string(self):
14+
gp = GP(
15+
df=None,
16+
features=["x1"],
17+
outcome=None,
18+
max_order=1,
19+
)
20+
self.assertEquals(str(gp.simplify("power_1(x1)")), "x1")
21+
22+
def test_fitness_string(self):
23+
gp = GP(
24+
df=pd.DataFrame({"x1": [1, 2, 3], "outcome": [2, 3, 4]}),
25+
features=["x1"],
26+
outcome="outcome",
27+
max_order=0,
28+
)
29+
self.assertEquals(gp.fitness("add(x1, 1)"), (0,))

0 commit comments

Comments
 (0)