FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gtsam/python/gtsam/tests/test_PybindOutputParameters.py at develop · borglab/gtsam · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
borglab
/
gtsam
Public
Notifications
You must be signed in to change notification settings
Fork
985
Star
3.7k
Code
Issues
2
Pull requests
5
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
gtsam
/
python
/
gtsam
/
tests
/
test_PybindOutputParameters.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
77 lines (59 loc) · 2.32 KB
Breadcrumbs
gtsam
/
python
/
gtsam
/
tests
/
test_PybindOutputParameters.py
Copy path
File metadata and controls
77 lines (59 loc) · 2.32 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""Tests for writable output parameters exposed by the pybind wrappers."""
import
numpy
as
np
import
gtsam
from
gtsam
.
symbol_shorthand
import
X
def
test_dynamic_matrix_outputs_and_omitted_defaults
():
"""Dynamic Matrix pointers accept None defaults and copy results back."""
factor
=
gtsam
.
NonlinearEquality2Point2
(
1
,
2
)
x1
=
np
.
array
([
1.0
,
2.0
])
x2
=
np
.
array
([
3.0
,
5.0
])
expected
=
factor
.
evaluateError
(
x1
,
x2
)
H1
=
np
.
zeros
((
2
,
2
))
H2
=
np
.
zeros
((
2
,
2
))
actual
=
factor
.
evaluateError
(
x1
,
x2
,
H1
,
H2
)
np
.
testing
.
assert_allclose
(
actual
,
expected
)
np
.
testing
.
assert_allclose
(
H1
,
-
np
.
eye
(
2
))
np
.
testing
.
assert_allclose
(
H2
,
np
.
eye
(
2
))
def
test_fixed_optional_jacobian_outputs_and_omitted_defaults
():
"""Fixed OptionalJacobian arguments retain their C++ defaults."""
pose
=
gtsam
.
Pose2
(
1.0
,
2.0
,
0.3
)
point
=
np
.
array
([
4.0
,
6.0
])
expected
=
gtsam
.
BearingRange2D
.
Measure
(
pose
,
point
)
H1
=
np
.
zeros
((
2
,
3
))
H2
=
np
.
zeros
((
2
,
2
))
actual
=
gtsam
.
BearingRange2D
.
Measure
(
pose
,
point
,
H1
,
H2
)
assert
actual
.
bearing
().
equals
(
expected
.
bearing
(),
1e-12
)
assert
actual
.
range
()
==
expected
.
range
()
assert
np
.
any
(
H1
)
assert
np
.
any
(
H2
)
def
test_raw_matrix_output_and_omitted_default
():
"""A raw Matrix output works without changing the old zero-argument call."""
density
=
gtsam
.
ConcentratedGaussianPoint2
(
1
,
np
.
array
([
1.0
,
2.0
]),
np
.
array
([
0.2
,
-
0.1
]),
np
.
eye
(
2
)
)
expected
=
density
.
retractMean
()
H
=
np
.
zeros
((
2
,
2
))
actual
=
density
.
retractMean
(
H
)
np
.
testing
.
assert_allclose
(
actual
,
expected
)
np
.
testing
.
assert_allclose
(
H
,
np
.
eye
(
2
))
def
test_print_errors_callback_and_default
():
"""The formerly hidden predicate is optional and accepts Python callables."""
graph
=
gtsam
.
NonlinearFactorGraph
()
graph
.
add
(
gtsam
.
PriorFactorPose2
(
X
(
0
),
gtsam
.
Pose2
(),
gtsam
.
noiseModel
.
Isotropic
.
Sigma
(
3
,
1.0
)
)
)
values
=
gtsam
.
Values
()
values
.
insert
(
X
(
0
),
gtsam
.
Pose2
())
seen
=
[]
graph
.
printErrors
(
values
)
graph
.
printErrors
(
values
,
""
,
gtsam
.
DefaultKeyFormatter
,
lambda
factor
,
error
,
index
:
seen
.
append
((
factor
,
error
,
index
))
or
True
,
)
assert
len
(
seen
)
==
1
assert
isinstance
(
seen
[
0
][
0
],
gtsam
.
PriorFactorPose2
)
assert
seen
[
0
][
1
:]
==
(
0.0
,
0
)
Back
|
FazBrowse Home
|
New Git URL