コード例 #1
0
def test_record_valid_data():
    ints = Intervals()
    assert ints.as_tuple() == ()

    ints.record(2)
    assert_almost_equal(ints.as_tuple(), (2, ))

    ints.record(3.4)
    assert_almost_equal(ints.as_tuple(), (2, 1.4))
コード例 #2
0
def test_intervals_creation_with_valid_data(timestamps):
    ints = Intervals(timestamps)
    _timestamps = asarray([0] + list(timestamps))
    assert not ints.empty
    assert len(ints) == len(timestamps)
    assert ints.as_tuple() == tuple(_timestamps[1:] - _timestamps[:-1])
    assert ints.last == timestamps[-1]
コード例 #3
0
def test_statistic(data):
    ints = Intervals(data)
    stats = ints.statistic()
    assert_almost_equal(stats.as_tuple(), ints.as_tuple())
コード例 #4
0
def test_as_tuple(timestamps):
    ints = Intervals(timestamps)
    _timestamps = asarray([0] + list(timestamps))
    assert ints.as_tuple() == tuple(_timestamps[1:] - _timestamps[:-1])
コード例 #5
0
def test_intervals_copy_list_content_instead_of_pointer():
    data = [1, 2]
    ints = Intervals(data)
    ints.record(3)
    assert ints.as_tuple() == (1, 1, 1)
    assert data == [1, 2]
コード例 #6
0
def test_empty_intervals_instantiation():
    ints = Intervals()
    assert ints.empty
    assert len(ints) == 0
    assert ints.as_tuple() == ()
    assert ints.last == 0