FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonLinearNonlinearControl/tests/models/test_model.py at master · privvyledge/PythonLinearNonlinearControl · GitHub
privvyledge
PythonLinearNonlinearControl
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonLinearNonlinearControl
/
tests
/
models
/
test_model.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (37 loc) · 1.5 KB
Breadcrumbs
PythonLinearNonlinearControl
/
tests
/
models
/
test_model.py
Copy path
File metadata and controls
53 lines (37 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import
pytest
import
numpy
as
np
from
PythonLinearNonlinearControl
.
models
.
model
import
LinearModel
class
TestLinearModel
():
"""
"""
def
test_predict
(
self
):
A
=
np
.
array
([[
1.
,
0.1
],
[
0.1
,
1.5
]])
B
=
np
.
array
([[
0.2
], [
0.5
]])
curr_x
=
np
.
ones
(
2
)
*
0.5
u
=
np
.
ones
((
1
,
1
))
linear_model
=
LinearModel
(
A
,
B
)
pred_xs
=
linear_model
.
predict_traj
(
curr_x
,
u
)
assert
pred_xs
==
pytest
.
approx
(
np
.
array
([[
0.5
,
0.5
], [
0.75
,
1.3
]]))
def
test_alltogether
(
self
):
A
=
np
.
array
([[
1.
,
0.1
],
[
0.1
,
1.5
]])
B
=
np
.
array
([[
0.2
], [
0.5
]])
curr_x
=
np
.
ones
(
2
)
*
0.5
u
=
np
.
ones
((
1
,
1
))
linear_model
=
LinearModel
(
A
,
B
)
pred_xs
=
linear_model
.
predict_traj
(
curr_x
,
u
)
u
=
np
.
tile
(
u
, (
1
,
1
,
1
))
pred_xs_alltogether
=
linear_model
.
predict_traj
(
curr_x
,
u
)[
0
]
assert
pred_xs_alltogether
==
pytest
.
approx
(
pred_xs
)
def
test_alltogether_val
(
self
):
A
=
np
.
array
([[
1.
,
0.1
],
[
0.1
,
1.5
]])
B
=
np
.
array
([[
0.2
], [
0.5
]])
curr_x
=
np
.
ones
(
2
)
*
0.5
u
=
np
.
stack
((
np
.
ones
((
1
,
1
)),
np
.
ones
((
1
,
1
))
*
0.5
),
axis
=
0
)
linear_model
=
LinearModel
(
A
,
B
)
pred_xs_alltogether
=
linear_model
.
predict_traj
(
curr_x
,
u
)
expected_val
=
np
.
array
([[[
0.5
,
0.5
], [
0.75
,
1.3
]],
[[
0.5
,
0.5
], [
0.65
,
1.05
]]])
assert
pred_xs_alltogether
==
pytest
.
approx
(
expected_val
)
Back
|
FazBrowse Home
|
New Git URL