Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-sofia committed Jan 13, 2025
1 parent 053ae26 commit e8732d6
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/test_pc_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_pc_number_of_all_proposed_actions_three_nodes(self):
pc_results = tst.execute_pipeline_steps()
self.assertEqual(len(pc_results[0].all_proposed_actions), 3)
self.assertEqual(len(pc_results[1].all_proposed_actions), 3)
# this should be 3, but with the current combinations generator, it does 4 tests
# TODO: think about whether the pairs with neighbours generator returns what we want, but the counting seems correct
self.assertEqual(len(pc_results[2].all_proposed_actions), 4)

def test_pc_number_of_actions_three_nodes(self):
Expand All @@ -112,6 +112,31 @@ def test_pc_number_of_actions_three_nodes(self):
self.assertEqual(len(pc_results[1].actions), 0)
self.assertEqual(len(pc_results[2].actions), 1)

def test_pc_number_of_all_proposed_actions_four_nodes(self):
"""
test if the number of all proposed actions is correct
"""
rdnv = self.seeded_random.normalvariate
sample_generator = IIDSampleGenerator(
edges=[
SampleEdge(NodeReference("X"), NodeReference("Y"), 5),
SampleEdge(NodeReference("Y"), NodeReference("Z"), 6),
SampleEdge(NodeReference("X"), NodeReference("W"), 7),
SampleEdge(NodeReference("W"), NodeReference("Y"), 5),
SampleEdge(NodeReference("W"), NodeReference("Z"), 6),
],
random=lambda: rdnv(0, 1),
)
test_data, graph = sample_generator.generate(1000)
tst = PC()
tst.create_graph_from_data(test_data)
tst.create_all_possible_edges()
pc_results = tst.execute_pipeline_steps()
self.assertEqual(len(pc_results[0].all_proposed_actions), 6)
self.assertEqual(len(pc_results[1].all_proposed_actions), 6)
# TODO: think about whether the pairs with neighbours generator returns what we want, but the counting seems correct
self.assertEqual(len(pc_results[3].all_proposed_actions), 7)

def test_pc_calculate_pearson_correlations(self):
"""
Test conditional independence of ordered pairs given pairs of other variables works.
Expand Down

0 comments on commit e8732d6

Please sign in to comment.