|
96 | 96 |
|
97 | 97 | @testset "Updating Nodes" begin
|
98 | 98 | global dfg
|
99 |
| - v1 = getVariable(dfg, :a) |
100 |
| - newv1 = deepcopy(v1) |
101 |
| - newv1.estimateDict[:default] = Dict{Symbol, VariableEstimate}( |
| 99 | + #get the variable |
| 100 | + var = getVariable(dfg, :a) |
| 101 | + #make a copy and simulate external changes |
| 102 | + newvar = deepcopy(var) |
| 103 | + newvar.estimateDict[:default] = Dict{Symbol, VariableEstimate}( |
102 | 104 | :max => VariableEstimate(:default, :max, [100.0]),
|
103 | 105 | :mean => VariableEstimate(:default, :mean, [50.0]),
|
104 | 106 | :ppe => VariableEstimate(:default, :ppe, [75.0]))
|
105 |
| - updateVariableSolverData!(dfg, newv1) |
106 |
| - #TODO maybe implement ==; @test newv1==v1 |
| 107 | + #update |
| 108 | + updateVariableSolverData!(dfg, newvar) |
| 109 | + #TODO maybe implement ==; @test newvar==var |
| 110 | + Base.:(==)(varest1::VariableEstimate, varest2::VariableEstimate) = begin |
| 111 | + varest1.lastUpdatedTimestamp == varest2.lastUpdatedTimestamp || return false |
| 112 | + varest1.type == varest2.type || return false |
| 113 | + varest1.solverKey == varest2.solverKey || return false |
| 114 | + varest1.estimate == varest2.estimate || return false |
| 115 | + return true |
| 116 | + end |
107 | 117 | #For now spot check
|
108 |
| - @test newv1.solverDataDict == v1.solverDataDict |
| 118 | + @test newvar.solverDataDict == var.solverDataDict |
| 119 | + @test newvar.estimateDict == var.estimateDict |
| 120 | + |
| 121 | + #delete :default and replace to see if new ones can be added |
| 122 | + delete!(newvar.estimateDict,:default) |
| 123 | + newvar.estimateDict[:second] = Dict{Symbol, VariableEstimate}( |
| 124 | + :max => VariableEstimate(:default, :max, [10.0]), |
| 125 | + :mean => VariableEstimate(:default, :mean, [5.0]), |
| 126 | + :ppe => VariableEstimate(:default, :ppe, [7.0])) |
| 127 | + |
| 128 | + updateVariableSolverData!(dfg, newvar) |
| 129 | + |
| 130 | + #FIXME |
| 131 | + if testDFGAPI != GraphsDFG |
| 132 | + @test symdiff(collect(keys(var.estimateDict)),Symbol[:default, :second]) == Symbol[] |
| 133 | + else |
| 134 | + @error "FIXME: $(keys(var.estimateDict)) should be [:default, :second]" |
| 135 | + @test_skip symdiff(collect(keys(var.estimateDict)),Symbol[:default, :second]) == Symbol[] |
| 136 | + end |
109 | 137 | end
|
110 | 138 |
|
111 | 139 | # Connectivity test
|
|
0 commit comments