예제 #1
0
def test_static_model_conversion_sampling_period():
    G = State(np.eye(5), dt=0.001)
    H = state_to_transfer(G)
    assert_(H._isgain)  # 0
    assert_(not H._isSISO)  # 1
    assert_equal(H.SamplingPeriod, 0.001)  # 2
    K = transfer_to_state(H)
    assert_equal(K.SamplingPeriod, 0.001)  # 3
예제 #2
0
def test_static_model_conversion_sampling_period():
    G = State(np.eye(5), dt=0.001)
    H = state_to_transfer(G)
    assert_(H._isgain)  # 0
    assert_(not H._isSISO)  # 1
    assert_equal(H.SamplingPeriod, 0.001)  # 2
    K = transfer_to_state(H)
    assert_equal(K.SamplingPeriod, 0.001)  # 3
예제 #3
0
파일: test_classes.py 프로젝트: psxz/harold
def test_Transfer_slicing():
    Hind = [(1, 5), (4, 1), (4, 5), (1, 1), (2, 5), (4, 2), (2, 5), (4, 2),
            (1, 2), (2, 1), (2, 5), (4, 3)]

    np.random.seed(1234)
    H = state_to_transfer(
        State(np.random.rand(3, 3), np.random.rand(3, 5), np.random.rand(4,
                                                                         3)))
    F = Transfer(np.random.rand(4, 5))

    for s, sind in ((H, Hind), (F, Hind)):
        for ind, x in enumerate([
                s[1, :], s[:, 1], s[:, :], s[0, 0], s[1:3, :], s[:, 1:3],
                s[[1, 2], :], s[:, [1, 2]], s[2, [1, 2]], s[[1, 2], 2],
                s[::2, :], s[:, ::2]
        ]):
            assert_equal(x.shape, sind[ind])
    assert_raises(ValueError, H.__setitem__)
예제 #4
0
def test_Transfer_slicing():
    Hind = [(1, 5), (4, 1),
            (4, 5), (1, 1),
            (2, 5), (4, 2),
            (2, 5), (4, 2),
            (1, 2), (2, 1),
            (2, 5), (4, 3)]

    np.random.seed(1234)
    H = state_to_transfer(State(np.random.rand(3, 3),
                                np.random.rand(3, 5),
                                np.random.rand(4, 3)))
    F = Transfer(np.random.rand(4, 5))

    for s, sind in ((H, Hind), (F, Hind)):
        for ind, x in enumerate([s[1, :], s[:, 1],
                                s[:, :], s[0, 0],
                                s[1:3, :], s[:, 1:3],
                                s[[1, 2], :], s[:, [1, 2]],
                                s[2, [1, 2]], s[[1, 2], 2],
                                s[::2, :], s[:, ::2]]):
            assert_equal(x.shape, sind[ind])
    assert_raises(ValueError, H.__setitem__)
예제 #5
0
파일: test_classes.py 프로젝트: psxz/harold
def test_state_to_transfer():
    G = State(-2 * np.eye(2), np.eye(2), [[1, -3], [0, 0]], [[0, 1], [-1, 0]])
    H = state_to_transfer(G)
    H11 = H[1, 1]
    assert_array_equal(H11.num, np.array([[0.]]))
    assert_array_equal(H11.den, np.array([[1.]]))
예제 #6
0
def test_state_to_transfer():
    G = State(-2*np.eye(2), np.eye(2), [[1, -3], [0, 0]], [[0, 1], [-1, 0]])
    H = state_to_transfer(G)
    H11 = H[1, 1]
    assert_array_equal(H11.num, np.array([[0.]]))
    assert_array_equal(H11.den, np.array([[1.]]))