Skip to content

Commit

Permalink
Another test
Browse files Browse the repository at this point in the history
  • Loading branch information
jmafoster1 committed Jan 6, 2025
1 parent ec079b4 commit 5066e4f
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from causal_testing.estimation.genetic_programming_regression_fitter import GP


def root(x):
return x**0.5


class TestGP(unittest.TestCase):
def test_init_invalid_fun_name(self):
with self.assertRaises(ValueError):
Expand All @@ -27,3 +31,13 @@ def test_fitness_string(self):
max_order=0,
)
self.assertEquals(gp.fitness("add(x1, 1)"), (0,))

def test_fitness_inf(self):
gp = GP(
df=pd.DataFrame({"x1": [-1], "outcome": [0]}),
features=["x1"],
outcome="outcome",
max_order=0,
extra_operators=[(root, 1)],
)
self.assertEquals(gp.fitness("root(x1)"), (float("inf"),))

0 comments on commit 5066e4f

Please sign in to comment.