Exemplo n.º 1
0
    def test_to_praat_overlapping_points(self):
        point1 = Point(1.5, 'a')
        point2 = Point(1.5, 'b')
        tier = TextTier('abc', 1, 2, [point1, point2])

        with assert_raises(ValueError):
            tier.to_praat()
Exemplo n.º 2
0
    def test_repr(self):
        point1 = Point(0.5, 'a')
        point2 = Point(0.75, 'c')
        tier = TextTier('abc', 0, 1, [point1, point2])

        assert_equal(
            repr(tier), "TextTier('abc', 0, 1, "
            "[Point(0.5, 'a'), Point(0.75, 'c')])")
Exemplo n.º 3
0
    def test_str(self):
        point1 = Point(0.5, 'a')
        point2 = Point(0.75, 'c')
        tier = TextTier('abc', 0, 1, [point1, point2])

        expected = '<TextTier "abc" from 0 to 1 seconds with 2 points>'

        assert_equal(str(tier), expected)
Exemplo n.º 4
0
    def test_insert(self):
        point1 = Point(0.5, 'a')
        point2 = Point(0.75, 'c')
        tier = TextTier('abc', 0, 1, [point1, point2])

        tier.insert(0.6, 'b')

        assert_is(tier[0], point1)
        assert_is(tier[2], point2)

        assert_equal(tier[1].number, 0.6)
        assert_equal(tier[1].mark, 'b')
Exemplo n.º 5
0
    def test_where_range_out_of_bounds(self):
        point1 = Point(0.5, 'a')
        point2 = Point(0.75, 'c')
        tier = TextTier('abc', 0.25, 1, [point1, point2])

        assert_equal(tier.where(0.1, 0.2), [])
        assert_equal(tier.where(0.1, 0.25), [])
        assert_equal(tier.where(0.1, 0.5), [point1])
        assert_equal(tier.where(0.1, 0.6), [point1])

        assert_equal(tier.where(0.6, 1.5), [point2])
        assert_equal(tier.where(0.75, 1.5), [point2])
        assert_equal(tier.where(0.8, 1.5), [])
        assert_equal(tier.where(1.1, 1.5), [])
Exemplo n.º 6
0
    def test_where_left(self):
        point = Point(0.5, 'a')
        tier = TextTier('abc', 0, 1, [point])

        assert_is_none(tier.where(0.25))
        assert_is(tier.where(0.5), point)
        assert_is_none(tier.where(0.75))
Exemplo n.º 7
0
    def test_where_range(self):
        point1 = Point(0.5, 'a')
        point2 = Point(0.75, 'c')
        tier = TextTier('abc', 0, 1, [point1, point2])

        assert_equal(tier.where(0, 0.25), [])
        assert_equal(tier.where(0.25, 0.5), [point1])
        assert_equal(tier.where(0.4, 0.6), [point1])
        assert_equal(tier.where(0.5, 0.6), [point1])

        assert_equal(tier.where(0.6, 0.7), [])
        assert_equal(tier.where(0.6, 0.75), [point2])
        assert_equal(tier.where(0.7, 1), [point2])

        assert_equal(tier.where(0, 1), [point1, point2])
        assert_equal(tier.where(0.25, 1), [point1, point2])
        assert_equal(tier.where(0.5, 0.75), [point1, point2])
Exemplo n.º 8
0
    def test_to_praat(self):
        point = Point(0.35, 'a')
        tier = TextTier('abc', 0.25, 1, [point])

        expected = ('"TextTier" named "abc" \n'
                    'From 0.25 to 1 seconds with 1 points\n'
                    '                    0.35    "a" ')

        assert_equal(tier.to_praat(), expected)
Exemplo n.º 9
0
    def test_to_dict(self):
        point = Point(0.35, 'a')
        tier = TextTier('abc', 0.25, 1, [point])

        assert_equal(
            tier.to_dict(), {
                'xmin': 0.25,
                'xmax': 1,
                'name': 'abc',
                'class': 'TextTier',
                'points': [{
                    'number': 0.35,
                    'mark': 'a'
                }]
            })
Exemplo n.º 10
0
    def test_from_reader(self):
        stream = iter([0.5, 'abc'])
        point = Point.from_reader(stream)

        assert_equal(point.number, 0.5)
        assert_equal(point.mark, 'abc')
Exemplo n.º 11
0
    def test_to_praat_late_point(self):
        point = Point(1.5, 'a')
        tier = TextTier('abc', 0.25, 1, [point])

        with assert_raises(ValueError):
            tier.to_praat()
Exemplo n.º 12
0
    def test_where_left_out_of_bounds(self):
        point = Point(0.5, 'a')
        tier = TextTier('abc', 0.25, 1, [point])

        assert_is_none(tier.where(0.1))
        assert_is_none(tier.where(1.5))
Exemplo n.º 13
0
 def test_init_unsortable(self):
     with assert_raises(TypeError):
         Tier('abc', 0, 1, [Interval(0, 1, 'abc'), Point(0.5, 'abc')])
Exemplo n.º 14
0
 def test_points_are_not_equal(self):
     point = Point(0.5, 'abc')
     assert_not_equal(self.point1, point)
Exemplo n.º 15
0
    def test_from_reader(self):
        stream = iter([0.5, 'abc'])
        point = Point.from_reader(stream)

        assert_equal(point.number, 0.5)
        assert_equal(point.mark, 'abc')
Exemplo n.º 16
0
 def setup_class(cls):
     cls.point1 = Point(0.5, 'abc')
     cls.point2 = Point(0.65, 'abc')