Пример #1
0
def test_invalid_interval_additions():
    i = Interval((0, False), (1, False))

    vals = [Interval((-1, True), (0, False)),
            Interval((-1, False), (0, False)),
            Interval((1, False), (2, True)),
            Interval((1, False), (2, False)),
            Interval((3, True), (4, False)),
            Interval((3, False), (4, True)),
            Interval((3, False), (4, False))
            ]

    for v in vals:
        yield raises(ValueError)(_add_intervals), i, v
Пример #2
0
def test_false_interval_intersections():
    i = Interval((0, True), (1, True))

    vals = [Interval((-1, True), (0, True)),
            Interval((-1, True), (0, False)),
            Interval((1, True), (2, True)),
            Interval((1, False), (2, True)),
            Interval((-2, True), (-1, True)),
            Interval((2, True), (3, True))
            ]

    results = [True] * 5 + [False]

    intersect = lambda a, b, v: eq_(a & b, v,
                                    msg="{} & {} == {}".format(a, b, v))

    for v, r in zip(vals, results):
        yield intersect, i, v, r
Пример #3
0
 def test_sequential_interval_addition(self):
     i = Interval((2, True), (3, True))
     result = Interval((0, False), (3, True))
     eq_(self.i + i, result, msg="{}+{}={}".format(self.i, i, self.i + i))
Пример #4
0
def test_invalid_interval_creation():
    Interval((1, True), (0, True))
Пример #5
0
 def setUp(self):
     self.i = Interval((0, False), (2, False))
Пример #6
0
 def test_nonsequential_interval_addition(self):
     i = Interval((-2, True), (0, True))
     result = Interval((-2, True), (2, False))
     eq_(i + self.i, result, msg="{}+{}={}".format(i, self.i, i + self.i))
Пример #7
0
 def test_non_overlapping_interval(self):
     i = Interval((3, True), (4, True))
     ok_(not self.i & i, msg="not {} & {}".format(self.i, i))
Пример #8
0
 def test_overlapping_interval(self):
     i = Interval((2, True), (3, True))
     ok_(self.i & i, msg="{} & {}".format(self.i, i))
Пример #9
0
 def test_preceding_interval(self):
     i = Interval((2, True), (3, True))
     ok_(self.i < i, msg="{} < {}".format(self.i, i))
Пример #10
0
 def test_unequal_intervals(self):
     i = Interval((0, True), (1, True))
     ok_(not self.i == i, msg="{} != {}".format(self.i, i))
Пример #11
0
 def setUp(self):
     self.i = Interval((0, True), (2, True))