Example #1
0
 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))
Example #2
0
 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))
Example #3
0
 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))
Example #4
0
 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))
Example #5
0
 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))
Example #6
0
 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))
Example #7
0
 def test_if_contradiction_is_contradictory(self):
     c = Contradiction("foo")
     self.assertTrue(is_contradictory(c))
Example #8
0
 def test_supported_interval_is_not_contradictory(self):
     sup = Supported(Interval(14, 15), {})
     self.assertFalse(is_contradictory(sup))
Example #9
0
 def test_supported_contradiction_is_contradictory(self):
     sup = Supported(Contradiction('...'), {})
     self.assertTrue(is_contradictory(sup))
Example #10
0
    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))
Example #11
0
 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))
Example #12
0
 def test_if_contradiction_is_contradictory(self):
     c = Contradiction("foo")
     self.assertTrue(is_contradictory(c))
Example #13
0
    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]
)
Example #14
0
 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))
Example #15
0
        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])