def test_two_implying_groups(self, make_statement): left_weight = FactorGroup(make_statement["large_weight"]) right_weight = FactorGroup(make_statement["small_weight"]) explanation = left_weight.explain_implication(right_weight) left_more = FactorGroup(make_statement["way_more"]) right_more = FactorGroup(make_statement["more"]) new = left_more.explain_implication(right_more, context=explanation) assert len(new.reasons) == 2 assert new.reasons[0].operation == operator.ge assert new.reasons[1].operation == operator.ge
def _add_if_universal(self, other: Procedure, explanation: Explanation) -> Optional[Procedure]: """Show how first Procedure triggers the second if both are universal.""" self_output_or_input = FactorGroup( (*self.outputs_group, *self.inputs_group)) other_input = list(other.inputs) implied_inputs = [] not_implied = [] while other_input: current = other_input.pop() implying_explanation = self_output_or_input.explain_implication( current, context=explanation) if implying_explanation is not None: explanation = implying_explanation implied_inputs.append(current) else: not_implied.append(current) if not any(implied_inputs): return None to_combine = Procedure(inputs=not_implied, outputs=other.outputs, despite=other.despite) return self.union(to_combine, context=explanation)
def test_explanations_implication_of_factor(self, make_statement): """Explanation shows the statements in `left` narrow down the quantity more than `right` does.""" left = FactorGroup([ make_statement["absent_way_more"], make_statement["less_than_20"] ]) right = make_statement["less"] explanation = left.explain_implication(right) assert "implies" in str(explanation).lower()
def test_explanation_implication_of_factorgroup(self, watt_factor): """The returned Explanation shows that f8_meters matches up with f8.""" left = FactorGroup([watt_factor["f9_absent_miles"], watt_factor["f8_meters"]]) right = FactorGroup([watt_factor["f8"], watt_factor["f9_absent"]]) explanation = left.explain_implication(right) assert "implies" in str(explanation).lower()