Ejemplo n.º 1
0
def test_sliding_tensor():
    N = 1000
    V = 5
    width = 10
    ts = np.random.rand(N, V)
    for step in 1 + np.arange(width):
        sts = transform.sliding_tensor(ts, width, step)
        assert sts.shape[1] == width
        assert sts.shape[2] == V
        Nsts = 1 + (N - width) // step
        assert Nsts == sts.shape[0]
        for j in range(V):
            assert np.all(np.isin(sts[:, :, j], ts[:, j]))

        # todo: reconstruct tensor ts

    final_tensor = []
    for step in 1 + np.arange(width):
        sts = transform.sliding_tensor(ts, width, step, 'C')
        final_tensor.append(sts)
        assert sts.flags.c_contiguous
        assert sts.shape[1] == width
        assert sts.shape[2] == V
        Nsts = 1 + (N - width) // step
        assert Nsts == sts.shape[0]
        for j in range(V):
            assert np.all(np.isin(sts[:, :, j], ts[:, j]))
    assert np.concatenate(final_tensor).flags.c_contiguous
Ejemplo n.º 2
0
def test_sliding_tensor():
    N = 1000
    V = 5
    width = 10
    ts = np.ones((N, V))
    for step in (1 + np.arange(width)):
        sts = transform.sliding_tensor(ts, width, step)
        assert sts.shape[1] == width
        assert sts.shape[2] == V
        Nsts = 1 + (N - width) // step
        assert Nsts == sts.shape[0]
Ejemplo n.º 3
0
def test_sliding_tensor():
    N = 1000
    V = 5
    width = 10
    ts = np.random.rand(N, V)
    for step in 1 + np.arange(width):
        sts = transform.sliding_tensor(ts, width, step)
        assert sts.shape[1] == width
        assert sts.shape[2] == V
        Nsts = 1 + (N - width) // step
        assert Nsts == sts.shape[0]
        for j in range(V):
            assert np.all(np.isin(sts[:, :, j], ts[:, j]))