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
)
评论列表
文章目录