Skip to content

Commit 16dd691

Browse files
committed
set partials update (restore tests)
1 parent 2330c7f commit 16dd691

File tree

3 files changed

+65
-62
lines changed

3 files changed

+65
-62
lines changed

src/services/NumericalCalculations.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,9 @@ function _solveCCWNumeric!(
362362
perturb::Real = 1e-10,
363363
) where {N_, F <: AbstractRelative, S, T}
364364
#
365-
365+
366366
#
367367
# thrid = Threads.threadid()
368-
369368
smpid = ccwl.particleidx[]
370369
# cannot Nelder-Mead on 1dim, partial can be 1dim or more but being conservative.
371370
islen1 = length(ccwl.partialDims) == 1 || ccwl.partial
@@ -377,10 +376,11 @@ function _solveCCWNumeric!(
377376
# a separate deepcopy of the destination (aka target) memory is necessary.
378377
# Choosen solution is to splice together ccwl.varValsAll each time, with destination as
379378
# deepcopy but other input variables are just point to the source variable values directly.
380-
if ccwl.partial
381-
target = view(ccwl.varValsAll[][ccwl.varidx[]][smpid], ccwl.partialDims)
379+
target = if ccwl.partial # FIXME likely type-instability on `typeof(target)`
380+
# view(ccwl.varValsAll[][ccwl.varidx[]][smpid], ccwl.partialDims)
381+
ccwl.varValsAll[][ccwl.varidx[]][smpid][ccwl.partialDims]
382382
else
383-
target = ccwl.varValsAll[][ccwl.varidx[]][smpid];
383+
ccwl.varValsAll[][ccwl.varidx[]][smpid]
384384
end
385385
# build the pre-objective function for this sample's hypothesis selection
386386
unrollHypo!, _ = _buildCalcFactorLambdaSample(
@@ -407,12 +407,13 @@ function _solveCCWNumeric!(
407407
# target .+= _perturbIfNecessary(getFactorType(ccwl), length(target), perturb)
408408
sfidx = ccwl.varidx[]
409409
# do the parameter search over defined decision variables using Minimization
410-
if ccwl.partial
411-
X = collect(view(ccwl.varValsAll[][sfidx][smpid], ccwl.partialDims))
412-
else
413-
X = ccwl.varValsAll[][sfidx][smpid][ccwl.partialDims]
414-
end
415-
# X = destVarVals[smpid]#[ccwl.partialDims]
410+
X = ccwl.varValsAll[][sfidx][smpid][ccwl.partialDims]
411+
# X = if ccwl.partial # TODO check for type-instability on `X`
412+
# collect(view(ccwl.varValsAll[][sfidx][smpid], ccwl.partialDims))
413+
# else
414+
# ccwl.varValsAll[][sfidx][smpid][ccwl.partialDims]
415+
# end
416+
# # X = destVarVals[smpid]#[ccwl.partialDims]
416417

417418
retval = _solveLambdaNumeric(
418419
getFactorType(ccwl),
@@ -430,7 +431,11 @@ function _solveCCWNumeric!(
430431

431432
# insert result back at the correct variable element location
432433
if ccwl.partial
433-
ccwl.varValsAll[][sfidx][smpid][ccwl.partialDims] .= retval
434+
# NOTE use workaround of TranslationGroup for coordinates on partial assignment
435+
# FIXME consolidate to Manopt and upgrade to Riemannian (i.e. incl non-groups)
436+
M = TranslationGroup(length(ccwl.varValsAll[][sfidx][smpid]))
437+
setPointPartial!(M, ccwl.varValsAll[][sfidx][smpid], M, retval,ccwl.partialDims,true )
438+
# ccwl.varValsAll[][sfidx][smpid][ccwl.partialDims] .= retval
434439
else
435440
# copyto!(ccwl.varValsAll[sfidx][smpid], retval)
436441
copyto!(ccwl.varValsAll[][sfidx][smpid][ccwl.partialDims], retval)

test/runtests.jl

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ TEST_GROUP = get(ENV, "IIF_TEST_GROUP", "all")
55
# temporarily moved to start (for debugging)
66
#...
77
if TEST_GROUP in ["all", "tmp_debug_group"]
8-
include("testSpecialOrthogonalMani.jl")
8+
# include("testSpecialOrthogonalMani.jl")
99
# include("testDERelative.jl")
1010
# include("testpartialconstraint.jl")
1111

@@ -14,51 +14,51 @@ include("priorusetest.jl")
1414
end
1515

1616
if TEST_GROUP in ["all", "basic_functional_group"]
17-
# more frequent stochasic failures from numerics
18-
# include("manifolds/manifolddiff.jl")
19-
# include("manifolds/factordiff.jl")
20-
# include("testSpecialEuclidean2Mani.jl")
21-
# include("testEuclidDistance.jl")
22-
23-
# # regular testing
24-
# include("testSphereMani.jl")
25-
# include("testBasicManifolds.jl")
26-
27-
# # start as basic as possible and build from there
28-
# include("typeReturnMemRef.jl")
29-
# include("testDistributionsGeneric.jl")
30-
# include("testHeatmapGridDensity.jl")
31-
# include("testCliqSolveDbgUtils.jl")
32-
# include("basicGraphsOperations.jl")
33-
34-
# # include("TestModuleFunctions.jl")
35-
# include("testCompareVariablesFactors.jl")
36-
# include("saveconvertertypes.jl")
37-
# include("testgraphpackingconverters.jl")
38-
# include("testSaveLoadDFG.jl")
39-
40-
# include("testPackingMixtures.jl")
41-
42-
# include("testJunctionTreeConstruction.jl")
43-
# include("testBayesTreeiSAM2Example.jl")
44-
# include("testTreeFunctions.jl")
45-
46-
# #FIXME fails on MetaBayesTree
47-
# include("testTreeSaveLoad.jl")
48-
49-
# @error "Gradient tests must be updated and restored for new ccw.varValsAll[]"
50-
# # include("testGradientUtils.jl")
51-
# # include("testFactorGradients.jl")
52-
# include("testSpecialSampler.jl") # TODO, rename, refine
53-
# include("testCommonConvWrapper.jl")
54-
55-
# include("testApproxConv.jl")
56-
# include("testBasicForwardConvolve.jl")
57-
# include("testUseMsgLikelihoods.jl")
58-
# include("testDefaultDeconv.jl")
59-
60-
# include("testPartialFactors.jl")
61-
# include("testPartialPrior.jl")
17+
# more frequent stochasic failures from numerics
18+
include("manifolds/manifolddiff.jl")
19+
include("manifolds/factordiff.jl")
20+
include("testSpecialEuclidean2Mani.jl")
21+
include("testEuclidDistance.jl")
22+
23+
# regular testing
24+
include("testSphereMani.jl")
25+
include("testBasicManifolds.jl")
26+
27+
# start as basic as possible and build from there
28+
include("typeReturnMemRef.jl")
29+
include("testDistributionsGeneric.jl")
30+
include("testHeatmapGridDensity.jl")
31+
include("testCliqSolveDbgUtils.jl")
32+
include("basicGraphsOperations.jl")
33+
34+
# include("TestModuleFunctions.jl")
35+
include("testCompareVariablesFactors.jl")
36+
include("saveconvertertypes.jl")
37+
include("testgraphpackingconverters.jl")
38+
include("testSaveLoadDFG.jl")
39+
40+
include("testPackingMixtures.jl")
41+
42+
include("testJunctionTreeConstruction.jl")
43+
include("testBayesTreeiSAM2Example.jl")
44+
include("testTreeFunctions.jl")
45+
46+
#FIXME fails on MetaBayesTree
47+
include("testTreeSaveLoad.jl")
48+
49+
@error "Gradient tests must be updated and restored for new ccw.varValsAll[]"
50+
# include("testGradientUtils.jl")
51+
# include("testFactorGradients.jl")
52+
include("testSpecialSampler.jl") # TODO, rename, refine
53+
include("testCommonConvWrapper.jl")
54+
55+
include("testApproxConv.jl")
56+
include("testBasicForwardConvolve.jl")
57+
include("testUseMsgLikelihoods.jl")
58+
include("testDefaultDeconv.jl")
59+
60+
include("testPartialFactors.jl")
61+
include("testPartialPrior.jl")
6262

6363
include("testPartialNH.jl")
6464
include("testMixturePrior.jl")

test/testpartialconstraint.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,19 @@ f2 = addFactor!(fg,[:x1],dp, graphinit=false)
5959

6060
doautoinit!(fg, :x1)
6161

62-
##
6362

6463
@testset "test evaluation of full constraint prior" begin
65-
64+
##
6665

6766
pts_, _ = evalFactor(fg, f1, v1.label, N=N)
6867
@cast pts[i,j] := pts_[j][i]
6968
@test size(pts,1) == 2
7069
@test size(pts,2) == N
7170
@test norm(Statistics.mean(pts,dims=2)[1] .- [0.0]) < 0.3
7271

73-
72+
##
7473
end
7574

76-
##
7775

7876
@testset "test evaluation of partial constraint prior" begin
7977
##

0 commit comments

Comments
 (0)