示例#1
0
def test_filter_lower_pair():
    '''Tests with pair shape arrays'''

    idx = np.array([], dtype='d')
    data = np.array([], dtype='d')
    ts = TimeSeries(idx, data)

    result = ts.filter_lower(1)
    assert_array_equal(result.data, [])
    assert_array_equal(result.timestamps, [])
    
    idx = np.array([1, 2, 3, 4, 5, 6], dtype='d')
    data = np.array([1, 2, 3, 4, 5, 6], dtype='d')
    ts = TimeSeries(idx, data)

    result = ts.filter_lower(1)
    assert_array_equal(result.data, [])
    assert_array_equal(result.timestamps, [])
    
    result = ts.filter_lower(0)
    assert_array_equal(result.data, [])
    assert_array_equal(result.timestamps, [])
    
    result = ts.filter_lower(2)
    assert_array_equal(result.data, [1])
    assert_array_equal(result.timestamps, [1])
    
    result = ts.filter_lower(2.5)
    assert_array_equal(result.data, [1, 2])
    assert_array_equal(result.timestamps, [1, 2])
    
    result = ts.filter_lower(5)
    assert_array_equal(result.data, [1, 2, 3, 4])
    assert_array_equal(result.timestamps, [1, 2, 3, 4])
    
    result = ts.filter_lower(3.5)
    assert_array_equal(result.data, [1, 2, 3])
    assert_array_equal(result.timestamps, [1, 2, 3])
    
    result = ts.filter_lower(5.5)
    assert_array_equal(result.data, [1, 2, 3, 4, 5])
    assert_array_equal(result.timestamps, [1, 2, 3, 4, 5])
    
    result = ts.filter_lower(6.5)
    assert_array_equal(result.data, [1, 2, 3, 4, 5, 6])
    assert_array_equal(result.timestamps, [1, 2, 3, 4, 5, 6])
示例#2
0
def test_filter_lower_pair():
    '''Tests with pair shape arrays'''

    idx = np.array([], dtype='d')
    data = np.array([], dtype='d')
    ts = TimeSeries(idx, data)

    result = ts.filter_lower(1)
    assert_array_equal(result.data, [])
    assert_array_equal(result.timestamps, [])

    idx = np.array([1, 2, 3, 4, 5, 6], dtype='d')
    data = np.array([1, 2, 3, 4, 5, 6], dtype='d')
    ts = TimeSeries(idx, data)

    result = ts.filter_lower(1)
    assert_array_equal(result.data, [])
    assert_array_equal(result.timestamps, [])

    result = ts.filter_lower(0)
    assert_array_equal(result.data, [])
    assert_array_equal(result.timestamps, [])

    result = ts.filter_lower(2)
    assert_array_equal(result.data, [1])
    assert_array_equal(result.timestamps, [1])

    result = ts.filter_lower(2.5)
    assert_array_equal(result.data, [1, 2])
    assert_array_equal(result.timestamps, [1, 2])

    result = ts.filter_lower(5)
    assert_array_equal(result.data, [1, 2, 3, 4])
    assert_array_equal(result.timestamps, [1, 2, 3, 4])

    result = ts.filter_lower(3.5)
    assert_array_equal(result.data, [1, 2, 3])
    assert_array_equal(result.timestamps, [1, 2, 3])

    result = ts.filter_lower(5.5)
    assert_array_equal(result.data, [1, 2, 3, 4, 5])
    assert_array_equal(result.timestamps, [1, 2, 3, 4, 5])

    result = ts.filter_lower(6.5)
    assert_array_equal(result.data, [1, 2, 3, 4, 5, 6])
    assert_array_equal(result.timestamps, [1, 2, 3, 4, 5, 6])
示例#3
0
def test_filter_lower():
    '''Tests the lower filter'''

    idx = np.array([0.0, 1.0, 2, 3, 4], dtype='d')
    data = np.array([1.0, 2, 3, 4, 5], dtype='d')
    ts = TimeSeries(idx, data)

    result = ts.filter_lower(1)
    assert_array_equal(result.timestamps, [0.0])
    assert_array_equal(result.data, [1.0])

    result = ts.filter_lower(0)
    assert_array_equal(result.timestamps, [])
    assert_array_equal(result.data, [])

    result = ts.filter_lower(3)
    assert_array_equal(result.timestamps, [0.0, 1.0, 2.0])
    assert_array_equal(result.data, [1.0, 2.0, 3.0])

    result = ts.filter_lower(-1)
    assert_array_equal(result.timestamps, [])
    assert_array_equal(result.data, [])

    result = ts.filter_lower(8)
    assert_array_equal(result.data, [1.0, 2.0, 3.0, 4.0, 5.0])
    assert_array_equal(result.timestamps, [0.0, 1.0, 2.0, 3.0, 4.0])

    expected = []
    for i, f in enumerate(np.arange(-0.5, 5.51, 1)):
        result = ts.filter_lower(f)
        assert_array_equal(result.timestamps, expected)
        if i < ts.timestamps.shape[0]:
            expected.append(ts.timestamps[i])
示例#4
0
def test_filter_lower():
    '''Tests the lower filter'''

    idx = np.array([0.0, 1.0, 2, 3, 4], dtype='d')
    data = np.array([1.0, 2, 3, 4, 5], dtype='d')
    ts = TimeSeries(idx, data)

    result = ts.filter_lower(1)
    assert_array_equal(result.timestamps, [0.0])
    assert_array_equal(result.data, [1.0])

    result = ts.filter_lower(0)
    assert_array_equal(result.timestamps, [])
    assert_array_equal(result.data, [])

    result = ts.filter_lower(3)
    assert_array_equal(result.timestamps, [0.0, 1.0, 2.0])
    assert_array_equal(result.data, [1.0, 2.0, 3.0])

    result = ts.filter_lower(-1)
    assert_array_equal(result.timestamps, [])
    assert_array_equal(result.data, [])

    result = ts.filter_lower(8)
    assert_array_equal(result.data, [1.0, 2.0, 3.0, 4.0, 5.0])
    assert_array_equal(result.timestamps, [0.0, 1.0, 2.0, 3.0, 4.0])

    expected = []
    for i, f in enumerate(np.arange(-0.5, 5.51, 1)):
        result = ts.filter_lower(f)
        assert_array_equal(result.timestamps, expected)
        if i < ts.timestamps.shape[0]:
            expected.append(ts.timestamps[i])