def test_abc(): for n in range(1, max_n + 1): for m in range(1, max_m + 1): for p in range(1, max_p + 1): A = elem_min + (elem_max - elem_min) * np.random.rand(n, n) B = elem_min + (elem_max - elem_min) * np.random.rand(n, m) C = elem_min + (elem_max - elem_min) * np.random.rand(p, n) x = elem_min + (elem_max - elem_min) * np.random.rand(n) u = elem_min + (elem_max - elem_min) * np.random.rand(m) if p != n: with pytest.raises(AssertionError): LTISystem(A, B, np.random.rand(n, p)) sys = LTISystem(A, B, C) assert sys.dim_state == n assert sys.dim_output == p assert sys.dim_input == m npt.assert_allclose( sys.state_equation_function(n * max_m + m, x, u), A @ x + B @ u) npt.assert_allclose( sys.output_equation_function(n * max_m + m, x), C @ x)
def test_ab(): for n in range(1, max_n + 1): for m in range(1, max_m + 1): A = elem_min + (elem_max - elem_min) * np.random.rand(n, n) B = elem_min + (elem_max - elem_min) * np.random.rand(n, m) x = elem_min + (elem_max - elem_min) * np.random.rand(n) u = elem_min + (elem_max - elem_min) * np.random.rand(m) if n != m: with pytest.raises(AssertionError): LTISystem(np.random.rand(n, m), B) with pytest.raises(AssertionError): LTISystem(A, np.random.rand(m, n)) sys = LTISystem(A, B) assert sys.dim_state == n assert sys.dim_output == n assert sys.dim_input == m npt.assert_allclose( sys.state_equation_function(n * max_m + m, x, u), A @ x + B @ u) npt.assert_allclose(sys.output_equation_function(n * max_m + m, x), x)