Skip to content

Commit 86836f3

Browse files
committed
WIP tests failing
1 parent 3ac6f34 commit 86836f3

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ julia = "1.4"
4343

4444
[extras]
4545
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
46+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
4647
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
4748
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
4849
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4950

5051
[targets]
51-
test = ["Test", "GraphPlot", "Manifolds", "Pkg"]
52+
test = ["Test", "GraphPlot", "LinearAlgebra", "Manifolds", "Pkg"]

src/entities/DFGVariable.jl

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ $(TYPEDFIELDS)
1919
mutable struct VariableNodeData{T<:InferenceVariable, P}
2020
val::Vector{P}
2121
bw::Vector{Vector{Float64}}
22-
BayesNetOutVertIDs::Array{Symbol,1}
23-
dimIDs::Array{Int,1} # Likely deprecate
22+
BayesNetOutVertIDs::Vector{Symbol}
23+
dimIDs::Vector{Int} # Likely deprecate
2424
dims::Int
2525
eliminated::Bool
2626
BayesNetVertID::Symbol # Union{Nothing, }
27-
separator::Array{Symbol,1}
27+
separator::Vector{Symbol}
2828
variableType::T
2929
initialized::Bool
3030
inferdim::Float64
@@ -34,13 +34,14 @@ mutable struct VariableNodeData{T<:InferenceVariable, P}
3434
solvedCount::Int
3535
solveKey::Symbol
3636
events::Dict{Symbol,Threads.Condition}
37-
VariableNodeData{T}(; solveKey::Symbol=:default) where {T <:InferenceVariable} =
38-
new{T,Vector{Vector{Float64}}}([[0.0;];], [[0.0;];], Symbol[], Int[], 0, false, :NOTHING, Symbol[], T(), false, 0.0, false, false, 0, 0, solveKey, Dict{Symbol,Threads.Condition}())
39-
VariableNodeData{T}(val::Vector{P},
37+
VariableNodeData{T,P}(; solveKey::Symbol=:default) where {T <:InferenceVariable, P} =
38+
new{T,getPointType(T)}(Vector{getPointType(T)}(undef, 1), Vector{Vector{Float64}}(undef,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], T(), false, 0.0, false, false, 0, 0, solveKey, Dict{Symbol,Threads.Condition}())
39+
VariableNodeData{T,P}(val::Vector{P},
4040
bw::Vector{Vector{Float64}},
41-
BayesNetOutVertIDs::Array{Symbol,1},
42-
dimIDs::Array{Int,1},
43-
dims::Int,eliminated::Bool,
41+
BayesNetOutVertIDs::AbstractVector{Symbol},
42+
dimIDs::AbstractVector{Int},
43+
dims::Int,
44+
eliminated::Bool,
4445
BayesNetVertID::Symbol,
4546
separator::Array{Symbol,1},
4647
variableType::T,
@@ -51,7 +52,7 @@ mutable struct VariableNodeData{T<:InferenceVariable, P}
5152
solveInProgress::Int=0,
5253
solvedCount::Int=0,
5354
solveKey::Symbol=:default,
54-
events::Dict{Symbol,Threads.Condition}=Dict{Symbol,Threads.Condition}()) where {T <: InferenceVariable, P, B} =
55+
events::Dict{Symbol,Threads.Condition}=Dict{Symbol,Threads.Condition}()) where {T <: InferenceVariable, P} =
5556
new{T,P}( val,bw,BayesNetOutVertIDs,dimIDs,dims,
5657
eliminated,BayesNetVertID,separator,
5758
variableType,initialized,inferdim,ismargin,
@@ -61,13 +62,16 @@ end
6162
##------------------------------------------------------------------------------
6263
## Constructors
6364

65+
#
66+
6467
VariableNodeData(val::Vector{P},
6568
bw::Vector{Vector{Float64}},
66-
BayesNetOutVertIDs::Array{Symbol,1},
67-
dimIDs::Array{Int,1},
68-
dims::Int,eliminated::Bool,
69+
BayesNetOutVertIDs::AbstractVector{Symbol},
70+
dimIDs::AbstractVector{Int},
71+
dims::Int,
72+
eliminated::Bool,
6973
BayesNetVertID::Symbol,
70-
separator::Array{Symbol,1},
74+
separator::AbstractVector{Symbol},
7175
variableType::T,
7276
initialized::Bool,
7377
inferdim::Float64,
@@ -77,15 +81,25 @@ VariableNodeData(val::Vector{P},
7781
solvedCount::Int=0,
7882
solveKey::Symbol=:default
7983
) where {T <: InferenceVariable, P} =
80-
VariableNodeData{T,P}( val,bw,BayesNetOutVertIDs,dimIDs,dims,
84+
VariableNodeData{T}( val,bw,BayesNetOutVertIDs,dimIDs,dims,
8185
eliminated,BayesNetVertID,separator,
8286
variableType,initialized,inferdim,ismargin,
8387
dontmargin, solveInProgress, solvedCount,
84-
solveKey)
85-
86-
87-
VariableNodeData(variableType::T; solveKey::Symbol=:default) where T <: InferenceVariable =
88-
VariableNodeData{T,Vector{getPointType(T)}}([[0.0;];], [[0.0;];], Symbol[], Int[], 0, false, :NOTHING, Symbol[], variableType, false, 0.0, false, false, 0, 0, solveKey)
88+
solveKey )
89+
#
90+
91+
function VariableNodeData(variableType::T; solveKey::Symbol=:default) where T <: InferenceVariable
92+
#
93+
p0 = getPointIdentity(T)
94+
P0 = Vector{getPointType(T)}(undef, 1)
95+
P0[1] = p0
96+
BW = Vector{Vector{Float64}}(undef,1)
97+
BW[1] = zeros(getDimension(T))
98+
VariableNodeData( P0, BW, Symbol[], Int[],
99+
0, false, :NOTHING, Symbol[],
100+
variableType, false, 0.0, false,
101+
false, 0, 0, solveKey )
102+
end
89103

90104
##==============================================================================
91105
## PackedVariableNodeData.jl

test/compareTests.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ vnd2 = deepcopy(vnd1)
1313
vnd3 = VariableNodeData(TestVariableType2())
1414

1515
@test vnd1 == vnd2
16-
vnd2.val = zeros(1,1)
16+
vnd1.val[1] = [1.0;]
17+
vnd2.val = Vector{Vector{Float64}}(undef,1)
18+
vnd2.val[1] = [1.0;]
1719
@test vnd1 == vnd2
18-
vnd2.val[1] = 0.1
20+
vnd2.val[1] = [0.1;]
1921
@test !(vnd1 == vnd2)
2022
@test !(vnd1 == vnd3)
2123

@@ -66,9 +68,10 @@ vnd3 = VariableNodeData(TestVariableType2())
6668
@test !compare(vnd1, vnd3)
6769

6870
@test compare(vnd1, vnd2)
69-
vnd2.val = zeros(1,1)
71+
vnd1.val[1][1] = 1.0
72+
vnd2.val[1][1] = 1.0
7073
@test compare(vnd1, vnd2)
71-
vnd2.val[1] = 0.1
74+
vnd2.val[1][1] = 0.1
7275
@test !compare(vnd1, vnd2)
7376
@test !compare(vnd1, vnd3)
7477

test/testBlocks.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import Base: convert
1616
Base.convert(::Type{<:Tuple}, ::typeof(Euclidean(1))) = (:Euclid,)
1717
Base.convert(::Type{<:Tuple}, ::typeof(Euclidean(2))) = (:Euclid, :Euclid)
1818

19-
@defVariable TestVariableType1 Euclidean(1) Vector{Float64}
20-
@defVariable TestVariableType2 Euclidean(2) Vector{Float64}
19+
@defVariable TestVariableType1 Euclidean(1) [0.0;]
20+
@defVariable TestVariableType2 Euclidean(2) [0;0.0]
2121

2222
# struct TestVariableType2 <: InferenceVariable
2323
# dims::Int

test/test_defVariable.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
using Manifolds
22
using Test
3+
using LinearAlgebra
34

45
@testset "Testing @defVariable" begin
56
##
67

78
struct NotAManifold end
89

9-
@test_throws AssertionError @defVariable(MyVar, NotAManifold(), Matrix{3})
10+
@test_throws AssertionError @defVariable(MyVar, NotAManifold(), zeros(3,3))
1011

1112
##
1213

13-
@defVariable(TestVarType1, Euclidean(3), Vector{Float64})
14-
@defVariable(TestVarType2, SpecialEuclidean(3), ProductRepr{Tuple{Vector{Float64}, Matrix{Float64}}})
14+
@defVariable(TestVarType1, Euclidean(3), zeros(3))
15+
@defVariable(TestVarType2, SpecialEuclidean(3), ProductRepr(zeros(3), diagm(ones(3))))
1516

1617

1718
##

0 commit comments

Comments
 (0)