コード例 #1
0
def test_scale_state(radius):
    sys = Alpha(0.1)
    scaled = scale_state(sys, radii=radius)
    assert not np.allclose(sys.B, scaled.B)
    assert not np.allclose(sys.C, scaled.C)

    # Check that it's still the same system, even though different matrices
    assert sys_equal(sys, scaled)

    # Check that the state vectors have scaled power
    assert np.allclose(state_norm(sys) / radius, state_norm(scaled))
コード例 #2
0
def test_invalid_scale_state():
    sys = Lowpass(0.1)

    scale_state(sys, radii=[1])

    with pytest.raises(ValueError):
        scale_state(sys, radii=[[1]])

    with pytest.raises(ValueError):
        scale_state(sys, radii=[1, 2])