Skip to content

Commit 4bc7607

Browse files
committed
Found a test input for the weird edge case
1 parent 9973f1f commit 4bc7607

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/estimation_tests/test_genetic_programming_regression_fitter.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
from causal_testing.estimation.genetic_programming_regression_fitter import GP
66

77

8+
def root(x):
9+
return x**0.5
10+
11+
812
class TestGP(unittest.TestCase):
913
def test_init_invalid_fun_name(self):
1014
with self.assertRaises(ValueError):
@@ -17,7 +21,7 @@ def test_simplify_string(self):
1721
outcome=None,
1822
max_order=1,
1923
)
20-
self.assertEqual(str(gp.simplify("power_1(x1)")), "x1")
24+
self.assertEquals(str(gp.simplify("power_1(x1)")), "x1")
2125

2226
def test_fitness_string(self):
2327
gp = GP(
@@ -26,13 +30,14 @@ def test_fitness_string(self):
2630
outcome="outcome",
2731
max_order=0,
2832
)
29-
self.assertEqual(gp.fitness("add(x1, 1)"), (0,))
33+
self.assertEquals(gp.fitness("add(x1, 1)"), (0,))
3034

31-
def test_fitness_invalid(self):
35+
def test_fitness_inf(self):
3236
gp = GP(
33-
df=pd.DataFrame({"x1": [1, None], "outcome": [2, None]}),
37+
df=pd.DataFrame({"x1": [1, 2, 3], "outcome": [2, 3, 4]}),
3438
features=["x1"],
3539
outcome="outcome",
3640
max_order=0,
41+
extra_operators=[(root, 1)],
3742
)
38-
self.assertEqual(gp.fitness("add(x1, x1)"), (float("inf"),))
43+
self.assertEquals(gp.fitness("root(-1)"), (float("inf"),))

0 commit comments

Comments
 (0)