Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Knoten
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aflab
astrogeology
Knoten
Commits
86f9fdc4
Commit
86f9fdc4
authored
5 years ago
by
Jesse Mapel
Browse files
Options
Downloads
Patches
Plain Diff
Added tests that needed mocks
parent
d8e7520c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_bundle.py
+72
-0
72 additions, 0 deletions
tests/test_bundle.py
with
72 additions
and
0 deletions
tests/test_bundle.py
+
72
−
0
View file @
86f9fdc4
...
...
@@ -199,3 +199,75 @@ def test_compute_sigma0_sparse():
"
point_1
"
:
(
3
,
6
)
}
assert
bundle
.
compute_sigma_sparse
(
V
,
dX
,
W_sensors
,
W_points
,
W_obs
,
column_dict
)
==
np
.
sqrt
(
7809
/
10
)
def
test_compute_image_weight
():
def
mock_covar
(
index_1
,
index_2
):
if
index_1
!=
index_2
:
return
0
return
index_1
+
1
sensor
=
mock
.
MagicMock
(
spec
=
csmapi
.
RasterGM
)
sensor
.
getParameterCovariance
=
mock_covar
params
=
[
mock
.
MagicMock
(),
mock
.
MagicMock
(),
mock
.
MagicMock
()]
params
[
0
].
index
=
0
params
[
1
].
index
=
1
params
[
2
].
index
=
3
np
.
testing
.
assert_allclose
(
bundle
.
compute_image_weight
(
sensor
,
params
),
[[
1
,
0
,
0
],
[
0
,
1
/
2
,
0
],
[
0
,
0
,
1
/
4
]])
def
test_compute_point_weight
(
control_network
):
control_network
.
at
[(
control_network
[
'
id
'
]
==
'
bob
'
).
idxmax
(),
'
aprioriCovar
'
]
=
np
.
array
([
1
,
0
,
0
,
2
,
0
,
3
])
np
.
testing
.
assert_allclose
(
bundle
.
compute_point_weight
(
control_network
,
'
bob
'
),
[[
1
,
0
,
0
],
[
0
,
1
/
2
,
0
],
[
0
,
0
,
1
/
3
]])
def
test_update_parameters
(
control_network
,
sensors
):
def
mock_getParameterValue
(
index
):
return
index
+
1
params
=
{}
coefficient_columns
=
{}
current_column
=
0
for
sn
,
sensor
in
sensors
.
items
():
sensor
.
getParameterValue
=
mock_getParameterValue
sensor_params
=
[]
for
param_idx
in
range
(
6
):
param_mock
=
mock
.
MagicMock
()
param_mock
.
index
=
param_idx
sensor_params
.
append
(
param_mock
)
params
[
sn
]
=
sensor_params
coefficient_columns
[
sn
]
=
(
current_column
,
current_column
+
6
)
current_column
+=
6
for
point_id
in
control_network
[
'
id
'
].
unique
():
coefficient_columns
[
point_id
]
=
(
current_column
,
current_column
+
3
)
current_column
+=
3
updates
=
np
.
arange
(
0
,
current_column
)
bundle
.
update_parameters
(
sensors
,
params
,
control_network
,
updates
,
coefficient_columns
)
for
sn
,
sensor
in
sensors
.
items
():
coeff_start
=
coefficient_columns
[
sn
][
0
]
for
param_idx
in
range
(
6
):
sensor
.
setParameterValue
.
assert_any_call
(
param_idx
,
param_idx
+
1
+
coeff_start
+
param_idx
)
for
point_id
,
group
in
control_network
.
groupby
(
'
id
'
):
coeff_start
=
coefficient_columns
[
point_id
][
0
]
coeff_end
=
coefficient_columns
[
point_id
][
1
]
num_measures
=
len
(
group
)
np
.
testing
.
assert_allclose
(
group
[[
'
adjustedX
'
,
'
adjustedY
'
,
'
adjustedZ
'
]].
values
,
np
.
tile
(
updates
[
coeff_start
:
coeff_end
],
num_measures
).
reshape
((
num_measures
,
3
))
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment