def _enumerate_all(self, bayes_net, unprocessed_variables, evidence_variables):
        if len(unprocessed_variables) == 0:
            return 1
        else:
            var = unprocessed_variables[0]
            if var in evidence_variables.keys():
                prob_var_true_given_parents = bayes_net.probability_of(var, evidence_variables[var], evidence_variables)

                second_term = self._enumerate_all(bayes_net, rest(unprocessed_variables), evidence_variables)

                return prob_var_true_given_parents * second_term
            else:
                evars_clone = dict(evidence_variables)

                evars_clone[var] = True
                prob_var_true_given_parents = bayes_net.probability_of(var, True, evars_clone)
                second_term = self._enumerate_all(bayes_net, rest(unprocessed_variables), evars_clone)

                true_probability_var = prob_var_true_given_parents * second_term

                evars_clone[var] = False
                prob_var_false_given_parents = bayes_net.probability_of(var, False, evars_clone)
                second_term = self._enumerate_all(bayes_net, rest(unprocessed_variables), evars_clone)

                false_probability_var = prob_var_false_given_parents * second_term

                return true_probability_var + false_probability_var
 def test_many_elements_rest(self):
     l = [1, 2, 3]
     rst = rest(l)
     self.assertSequenceEqual([2, 3], rst)
 def test_no_elements_rest(self):
     l = []
     rst = rest(l)
     self.assertSequenceEqual([], rst)
 def test_single_element_rest(self):
     l = [1]
     rst = rest(l)
     self.assertSequenceEqual([], rst)
 def test_many_elements_rest(self):
     l = [1, 2, 3]
     rst = rest(l)
     self.assertSequenceEqual([2, 3], rst)
 def test_no_elements_rest(self):
     l = []
     rst = rest(l)
     self.assertSequenceEqual([], rst)
 def test_single_element_rest(self):
     l = [1]
     rst = rest(l)
     self.assertSequenceEqual([], rst)