Skip to content

Commit c272ba9

Browse files
committed
swap arg order for _evalFactorTemporary!
1 parent f259f2b commit c272ba9

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/ApproxConv.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ Notes
597597
598598
Example
599599
```julia
600-
B = _evalFactorTemporary!(EuclidDistance, ([10;],), 2, [(ContinuousScalar,[0]); (ContinuousScalar,[9.5;])] )
600+
B = _evalFactorTemporary!(EuclidDistance, (ContinuousScalar, ContinuousScalar), 2, ([10;],), ([0.],[9.5]) )
601601
# should return `B = 10`
602602
```
603603
@@ -606,9 +606,9 @@ Related
606606
[`evalFactor`](@ref), [`calcFactorResidual`](@ref), [`testFactorResidualBinary`](@ref)
607607
"""
608608
function _evalFactorTemporary!( fct::AbstractFactor,
609+
varTypes::Tuple,
609610
sfidx::Int, # solve for index, assuming variable order for fct
610611
meas_single::Tuple,
611-
varTypes::Tuple,
612612
pts::Tuple;
613613
tfg::AbstractDFG=initfg(),
614614
solveKey::Symbol=:default,

src/services/FactorGradients.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function _prepFactorGradientLambdas(fct::Union{<:AbstractRelativeMinimize,<:Abst
2929
T_pth_s_i = (s,i) -> AMP.makePointFromCoords(M[s], coord_h(s,i), pts[s]) # exp(M,..., hat(M,...) )
3030
tup_pt_s_i_h = (s,i) -> tuple(pts[1:(s-1)]..., T_pth_s_i(s,i), pts[(s+1):end]...)
3131
# build a residual calculation specifically considering graph factor selections `s`, e.g. for binary `s ∈ {1,2}`.
32-
f_dsi_h = (d,s,i) -> IIF._evalFactorTemporary!(fct, d, measurement, varTypes, tup_pt_s_i_h(s,i); tfg=tfg, newFactor=false, currNumber=0, _slack=slack_resid )
32+
f_dsi_h = (d,s,i) -> IIF._evalFactorTemporary!(fct, varTypes, d, measurement, tup_pt_s_i_h(s,i); tfg=tfg, newFactor=false, currNumber=0, _slack=slack_resid )
3333
# standard calculus derivative definition (in coordinate space)
3434
Δf_dsi = (d,s,i, crd=coord_(d)) -> (f_dsi_h(d,s,i)[1] - crd)./h
3535
# jacobian block per s, for each i

test/testGradientUtils.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dfg, _dfgfct = IIF._buildGraphByFactorAndTypes!(fct, varTypes, varPts)
2020

2121
## test the evaluation of factor without
2222

23-
B = IIF._evalFactorTemporary!(EuclidDistance(Normal(10,1)), 2, ([10;],), varTypes, varPts );
23+
B = IIF._evalFactorTemporary!(EuclidDistance(Normal(10,1)), varTypes, 2, ([10;],), varPts );
2424

2525
@test_broken B isa Vector{Vector{Float64}}
2626
@test isapprox( B[1], [10.0;], atol=1e-6)
@@ -43,21 +43,21 @@ slack_resid = calcFactorResidualTemporary(fct, varTypes, measurement, pts)
4343

4444
##
4545

46-
coord_1 = IIF._evalFactorTemporary!(fct, 1, measurement, varTypes, pts, _slack=slack_resid )
46+
coord_1 = IIF._evalFactorTemporary!(fct, varTypes, 1, measurement, pts, _slack=slack_resid )
4747
@test length(coord_1) == 1
4848
@test isapprox( coord_1[1], [0.0], atol=1e-6)
4949

50-
coord_2 = IIF._evalFactorTemporary!(fct, 2, measurement, varTypes, pts, _slack=slack_resid )
50+
coord_2 = IIF._evalFactorTemporary!(fct, varTypes, 2, measurement, pts, _slack=slack_resid )
5151
@test length(coord_2) == 1
5252
@test isapprox( coord_2[1], [9.5], atol=1e-6)
5353

5454
##
5555

56-
coord_1 = IIF._evalFactorTemporary!(fct, 1, measurement, varTypes, pts )
56+
coord_1 = IIF._evalFactorTemporary!(fct, varTypes, 1, measurement, pts )
5757
@test length(coord_1) == 1
5858
@test isapprox( coord_1[1], [-0.5], atol=1e-6)
5959

60-
coord_2 = IIF._evalFactorTemporary!(fct, 2, measurement, varTypes, pts )
60+
coord_2 = IIF._evalFactorTemporary!(fct, varTypes, 2, measurement, pts )
6161
@test length(coord_2) == 1
6262
@test isapprox( coord_2[1], [10.0], atol=1e-6)
6363

@@ -100,7 +100,7 @@ slack_resid = calcFactorResidualTemporary(fct, varTypes, measurement, pts, tfg=_
100100
## Manually provide a common temp graph and force no factor and same variables via keywords
101101

102102
tfg,_ = IIF._buildGraphByFactorAndTypes!(fct, varTypes, pts);
103-
coord_1 = IIF._evalFactorTemporary!(fct, 1, measurement, varTypes, pts, _slack=slack_resid, tfg=tfg, newFactor=false, currNumber=0 )
103+
coord_1 = IIF._evalFactorTemporary!(fct, varTypes, 1, measurement, pts, _slack=slack_resid, tfg=tfg, newFactor=false, currNumber=0 )
104104

105105
##
106106

@@ -109,23 +109,23 @@ coord_1 = IIF._evalFactorTemporary!(fct, 1, measurement, varTypes, pts, _slack=s
109109

110110
@test isapprox( coord_1[1], [0;0.0], atol=1e-6)
111111

112-
coord_2 = IIF._evalFactorTemporary!(fct, 2, measurement, varTypes, pts, _slack=slack_resid )
112+
coord_2 = IIF._evalFactorTemporary!(fct, varTypes, 2, measurement, pts, _slack=slack_resid )
113113
@test length(coord_2) == 1
114114
@test length(coord_2[1]) == 2
115115

116116
@test isapprox( coord_2[1], [9.5; 0], atol=1e-6)
117117

118118
## Repeat the same test but allow _evalFactorTemporary to self construct internal temporary graph
119119

120-
coord_1 = IIF._evalFactorTemporary!(fct, 1, measurement, varTypes, pts )
120+
coord_1 = IIF._evalFactorTemporary!(fct, varTypes, 1, measurement, pts )
121121

122122
##
123123
@test length(coord_1) == 1
124124
@test length(coord_1[1]) == 2
125125

126126
@test isapprox( coord_1[1], [-0.5;0], atol=1e-6)
127127

128-
coord_2 = IIF._evalFactorTemporary!(fct, 2, measurement, varTypes, pts )
128+
coord_2 = IIF._evalFactorTemporary!(fct, varTypes, 2, measurement, pts )
129129
@test length(coord_2) == 1
130130
@test length(coord_2[1]) == 2
131131

0 commit comments

Comments
 (0)