コード例 #1
0
def test_view_as_windows_1D():

    A = np.arange(10)
    window_shape = (3, )
    B = view_as_windows(A, window_shape)
    assert_equal(
        B,
        np.array([[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6],
                  [5, 6, 7], [6, 7, 8], [7, 8, 9]]))
コード例 #2
0
def test_view_as_windows_2D():

    A = np.arange(5 * 4).reshape(5, 4)
    window_shape = (4, 3)
    B = view_as_windows(A, window_shape)
    assert_equal(B.shape, (2, 2, 4, 3))
    assert_equal(
        B,
        np.array([[[[0, 1, 2], [4, 5, 6], [8, 9, 10], [12, 13, 14]],
                   [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15]]],
                  [[[4, 5, 6], [8, 9, 10], [12, 13, 14], [16, 17, 18]],
                   [[5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19]]]]))
コード例 #3
0
def test_view_as_windows_1D():

    A = np.arange(10)
    window_shape = (3,)
    B = view_as_windows(A, window_shape)
    assert_equal(B, np.array([[0, 1, 2],
                              [1, 2, 3],
                              [2, 3, 4],
                              [3, 4, 5],
                              [4, 5, 6],
                              [5, 6, 7],
                              [6, 7, 8],
                              [7, 8, 9]]))
コード例 #4
0
def test_view_as_windows_2D():

    A = np.arange(5 * 4).reshape(5, 4)
    window_shape = (4, 3)
    B = view_as_windows(A, window_shape)
    assert_equal(B.shape, (2, 2, 4, 3))
    assert_equal(B, np.array([[[[0,  1,  2],
                                [4,  5,  6],
                                [8,  9, 10],
                                [12, 13, 14]],
                               [[1,  2,  3],
                                [5,  6,  7],
                                [9, 10, 11],
                                [13, 14, 15]]],
                              [[[4,  5,  6],
                                [8,  9, 10],
                                [12, 13, 14],
                                [16, 17, 18]],
                               [[5,  6,  7],
                                [9, 10, 11],
                                [13, 14, 15],
                                [17, 18, 19]]]]))
コード例 #5
0
def test_view_as_windows_window_too_large():

    A = np.arange(10)
    view_as_windows(A, (11, ))
コード例 #6
0
def test_view_as_windows_negative_window_length():

    A = np.arange(10)
    view_as_windows(A, (-1, ))
コード例 #7
0
def test_view_as_windows_wrong_window_dimension():

    A = np.arange(10)
    view_as_windows(A, (2, 2))
コード例 #8
0
def test_view_as_windows_window_not_tuple():

    A = np.arange(10)
    view_as_windows(A, [2])
コード例 #9
0
def test_view_as_windows_input_not_array():

    A = [1, 2, 3, 4, 5]
    view_as_windows(A, (2, ))
コード例 #10
0
def test_view_as_windows_negative_window_length():

    A = np.arange(10)
    view_as_windows(A, (-1,))
コード例 #11
0
def test_view_as_windows_wrong_window_dimension():

    A = np.arange(10)
    view_as_windows(A, (2, 2))
コード例 #12
0
def test_view_as_windows_window_not_tuple():

    A = np.arange(10)
    view_as_windows(A, [2])
コード例 #13
0
def test_view_as_windows_input_not_array():

    A = [1, 2, 3, 4, 5]
    view_as_windows(A, (2,))
コード例 #14
0
def test_view_as_windows_window_too_large():

    A = np.arange(10)
    view_as_windows(A, (11,))