Beispiel #1
0
 def test_basics(self):
     D = Domain("d", 0, 10)
     assert D._name == "d"
     assert D._low == 0
     assert D._high == 10
     assert D._res == 1
     x = Set(lambda x: 1)
     D.s = x
     assert D.s == x
     assert D._sets == {"s": x}
     R = D(3)
     assert R == {D.s: 1}
Beispiel #2
0
 def test_eq(self, low, high, res):
     """This also tests Set.array().
     This test can massively slow down hypothesis with even
     reasonably large/small values.
     """
     assume(low < high)
     # to avoid MemoryError and runs that take forever..
     assume(high - low <= 10)
     D1 = Domain("1", low, high, res=res)
     D1.s1 = fun.bounded_linear(low, high)
     D2 = Domain("2", low, high, res=res)
     D2.s2 = Set(fun.bounded_linear(low, high))
     assert D1.s1 == D2.s2
Beispiel #3
0
def temp():
    d = Domain("temperature", -100, 100, res=0.1)  # in Celsius
    d.cold = S(0, 15)  # sic
    d.hot = Set(R(10, 30))  # sic
    d.warm = ~d.cold & ~d.hot
    return d
Beispiel #4
0
 def test_complement(self):
     D = Domain("d", 0, 10, res=0.1)
     D.s1 = Set(fun.bounded_linear(3, 12))
     D.s2 = ~~D.s1
     assert all(np.isclose(D.s1.array(), D.s2.array()))
Beispiel #5
0
 def test_sub_super_set(self):
     D = Domain("d", 0, 10, res=0.1)
     D.s = Set(fun.bounded_linear(3, 12))
     D.x = D.s.normalized()
     assert D.x >= D.s
     assert D.s <= D.x
Beispiel #6
0
 def test_normalized(self):
     D = Domain("d", 0, 10, res=0.1)
     D.s = Set(fun.bounded_linear(3, 12))
     D.x = D.s.normalized()
     D.y = D.x.normalized()
     assert D.x == D.y
Beispiel #7
0
 def test_plus(self, x):
     s = Set(fun.noop())
     f = hedges.plus(s)
     assert 0 <= f(x) <= 1
Beispiel #8
0
 def test_very(self, x):
     s = Set(fun.noop())
     f = hedges.very(s)
     assert 0 <= f(x) <= 1
Beispiel #9
0
 def test_minus(self, x):
     s = Set(fun.noop())
     f = hedges.minus(s)
     assert (0 <= f(x) <= 1)