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_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_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_contradiction_is_contradictory(self): c = Contradiction("foo") self.assertTrue(is_contradictory(c))
def test_supported_interval_is_not_contradictory(self): sup = Supported(Interval(14, 15), {}) self.assertFalse(is_contradictory(sup))
def test_supported_contradiction_is_contradictory(self): sup = Supported(Contradiction('...'), {}) self.assertTrue(is_contradictory(sup))
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))
def test_add_new_content_to_filled_cell_returns_contradiction(self): a = Cell(content='hello') a.add_content('world') self.assertTrue(is_contradictory(a.content))
else: return Supported(thing) operator_names = ["add", "sub", "mul", "truediv"] operator_functions = { name: getattr(propagator.operator, name) for name in operator_names } for op_name, op_function in operator_functions.items(): assign_operation(op_name, supported_unpacking(op_function), [is_supported, is_supported] ) #lambda s, f, func=op_function: func(s.value, f), assign_operation(op_name, coercing(to_supported, supported_unpacking(op_function)), [is_supported, is_flat] ) #lambda f, s, func=op_function: func(f, s.value), assign_operation(op_name, coercing(to_supported, supported_unpacking(op_function)), [is_flat, is_supported] ) assign_operation("sqrt", supported_unpacking(propagator.operator.sqrt), [is_supported]) assign_operation("is_contradictory", lambda s: is_contradictory(s.value), [is_supported] )
return thing else: return Supported(thing) operator_names = ["add", "sub", "mul", "truediv"] operator_functions = { name: getattr(propagator.operator, name) for name in operator_names } for op_name, op_function in operator_functions.items(): assign_operation(op_name, supported_unpacking(op_function), [is_supported, is_supported]) #lambda s, f, func=op_function: func(s.value, f), assign_operation(op_name, coercing(to_supported, supported_unpacking(op_function)), [is_supported, is_flat]) #lambda f, s, func=op_function: func(f, s.value), assign_operation(op_name, coercing(to_supported, supported_unpacking(op_function)), [is_flat, is_supported]) assign_operation("sqrt", supported_unpacking(propagator.operator.sqrt), [is_supported]) assign_operation("is_contradictory", lambda s: is_contradictory(s.value), [is_supported])