def test_if_merging_contradiction_with_interval_is_contradictory(self): c = Contradiction("foo") n = Interval(5, 10) m1 = merge(c, n) m2 = merge(n, c) self.assertTrue(is_contradictory(m1)) self.assertTrue(is_contradictory(m2))
def test_if_merging_contradiction_with_supported_value_is_contradictory(self): c = Contradiction("foo") n = Supported(Interval(5, 10)) m1 = merge(c, n) m2 = merge(n, c) self.assertTrue(is_contradictory(m1)) self.assertTrue(is_contradictory(m2))
def test_if_merging_contradiction_with_number_is_contradictory(self): c = Contradiction("foo") n = 10 m1 = merge(c, n) m2 = merge(n, c) self.assertTrue(is_contradictory(m1)) self.assertTrue(is_contradictory(m2))
def test_if_merging_contradiction_with_supported_value_is_contradictory( self): c = Contradiction("foo") n = Supported(Interval(5, 10)) m1 = merge(c, n) m2 = merge(n, c) self.assertTrue(is_contradictory(m1)) self.assertTrue(is_contradictory(m2))
def test_merge_supported_none_and_supported_interval(self): nil = Supported(None, {}) sup = Supported(Interval(15, 16), {'this', 'that'}) self.assertEqual( merge(nil, sup), merge(sup, nil), ) self.assertEqual( merge(sup, nil), Supported(Interval(15, 16), {'this', 'that'}) )
def test_merge_flat_interval_and_looser_supported_interval(self): number = Interval(14.5, 16.7) sup = Supported(Interval(3, 18), {'this', 'that'}) self.assertEqual( merge(number, sup), merge(sup, number), ) self.assertEqual( merge(number, sup), Supported(Interval(14.5, 16.7), {}) )
def add_content(self, increment): answer = merge(self.content, increment) if answer != self.content: debug("Adding content {1} to {0}".format(self, answer)) self.content = answer scheduler.alert_propagators(self.neighbors)
def test_merge_two_supporteds_nones(self): nil1 = Supported(None, {}) nil2 = Supported(None, {}) self.assertEqual( merge(nil1, nil2), Supported(None, {}) )
def _merge_supporteds(content, increment): merged_value = merge(content.value, increment.value) if merged_value == content.value: if implies(increment.value, merged_value): # Confirmation of existing information if increment.support.more_informative_than(content.support): return increment else: return content else: # New information is not interesting return content elif merged_value == increment.value: # New information overrides old information return increment else: # Interesting merge, need both provenances return Supported(merged_value, content.support | increment.support)
def test_merge_contradictory_supported_values(self): sup1 = Supported(Interval(3, 6), {}) sup2 = Supported(Interval(7, 9), {}) merged = merge(sup1, sup2) self.assertTrue(is_contradictory(merged))