test_numeric_switchedsystem.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:simupy 作者: sixpearls 项目源码 文件源码
def test_state_equations_functions_kwarg(switch_fixture):
    with pytest.raises(ValueError, match=need_state_equation_function_msg):
        SwitchedSystem(
            dim_state=1,
            event_variable_equation_function=event_variable_equation_function,
            event_bounds=switch_fixture[0],
            output_equations_functions=switch_fixture[2]
        )
    with pytest.raises(ValueError, match="broadcast"):
        SwitchedSystem(
            dim_state=1,
            event_variable_equation_function=event_variable_equation_function,
            event_bounds=switch_fixture[0],
            state_equations_functions=np.array([
                     lambda t, x, u: cnd*np.ones(x.shape)
                     for cnd in range(switch_fixture[0].size+2)
             ]),
            output_equations_functions=switch_fixture[2]
        )
    sys = SwitchedSystem(
        dim_state=1,
        event_variable_equation_function=event_variable_equation_function,
        event_bounds=switch_fixture[0],
        state_equations_functions=switch_fixture[1],
        output_equations_functions=switch_fixture[2]
    )
    npt.assert_array_equal(sys.state_equations_functions, switch_fixture[1])
    sys = SwitchedSystem(
        dim_state=1,
        event_variable_equation_function=event_variable_equation_function,
        event_bounds=switch_fixture[0],
        state_equations_functions=state_equation_function,
        output_equations_functions=switch_fixture[2]
    )
    npt.assert_array_equal(
        sys.state_equations_functions,
        state_equation_function
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号