From 8476d7070178cfbc03161917880297ea22c3d0a6 Mon Sep 17 00:00:00 2001 From: dehann Date: Thu, 4 Oct 2018 16:06:54 -0400 Subject: [PATCH] fix and remove more warnings --- examples/squarefixedpoint.jl | 2 +- src/DispatchPackedConversions.jl | 6 +++--- src/FactorGraph01.jl | 16 ++++++++-------- src/FactorGraphTypes.jl | 4 ++-- src/JunctionTree.jl | 1 - src/SolveTree01.jl | 2 +- src/SolverUtilities.jl | 7 +++---- test/fourdoortest.jl | 6 +++--- test/testBayesTreeChordalProp.jl | 30 +++++++++++++++--------------- 9 files changed, 36 insertions(+), 38 deletions(-) diff --git a/examples/squarefixedpoint.jl b/examples/squarefixedpoint.jl index 7f52e50bf..439f10a34 100644 --- a/examples/squarefixedpoint.jl +++ b/examples/squarefixedpoint.jl @@ -182,7 +182,7 @@ end # frequencies of interest FR = range(0.5/(2pi),stop=3.0/(2pi), length=8) -# FR = linspace(0.5/(2pi),3.0/(2pi), 8) +# FR = range(0.5/(2pi),stop=3.0/(2pi), length=8) mc = 3 diff --git a/src/DispatchPackedConversions.jl b/src/DispatchPackedConversions.jl index aff74aec0..fff17b989 100644 --- a/src/DispatchPackedConversions.jl +++ b/src/DispatchPackedConversions.jl @@ -177,7 +177,7 @@ end function convert(::Type{PackedFunctionNodeData{P}}, d::FunctionNodeData{T}) where {P <: PackedInferenceType, T <: FunctorInferenceType} # println("convert(::Type{PackedFunctionNodeData{$P}}, d::FunctionNodeData{$T})") - warn("convert GenericWrapParam is deprecated, use CommonConvWrapper instead.") + @warn "convert GenericWrapParam is deprecated, use CommonConvWrapper instead." mhstr = packmultihypo(d.fnc) return PackedFunctionNodeData(d.fncargvID, d.eliminated, d.potentialused, d.edgeIDs, string(d.frommodule), convert(P, d.fnc.usrfnc!), mhstr) @@ -198,7 +198,7 @@ function convert( ::Type{IncrementalInference.GenericFunctionNodeData{IncrementalInference.CommonConvWrapper{F},Symbol}}, d::IncrementalInference.GenericFunctionNodeData{P,String} ) where {F <: FunctorInferenceType, P <: PackedInferenceType} # - # warn("Unpacking Option 2, F=$(F), P=$(P)") + # @warn "Unpacking Option 2, F=$(F), P=$(P)" usrfnc = convert(F, d.fnc) # @show d.multihypo mhcat = parsemultihypostr(d.multihypo) @@ -254,7 +254,7 @@ end function encodePackedType(topackdata::GenericFunctionNodeData{T, <:AbstractString}) where {T <: PackedInferenceType} error("IncrementalInference.encodePackedType(::FunctionNodeData{T, <:AbstractString}): Unknown packed type encoding T=$(T) of $(topackdata)") # @show T, typeof(topackdata) - # warn("Yes, its packed!") + # @warn "Yes, its packed!" # fnctype = getfnctype(topackdata) # @show fnc = getfield(getmodule(fnctype), Symbol("Packed$(getname(fnctype))")) # convert(PackedFunctionNodeData{T}, topackdata) diff --git a/src/FactorGraph01.jl b/src/FactorGraph01.jl index 69bbd1a38..bf9675435 100644 --- a/src/FactorGraph01.jl +++ b/src/FactorGraph01.jl @@ -119,7 +119,7 @@ function updateFullVert!(fgl::FactorGraph, exvert::ExVertex; api::DataLayerAPI=IncrementalInference.dlapi, updateMAPest::Bool=false ) # - warn("use of updateFullVert! should be clarified for local or remote operations.") + @warn "use of updateFullVert! should be clarified for local or remote operations." api.updatevertex!(fgl, exvert, updateMAPest=updateMAPest) end @@ -139,7 +139,7 @@ function setDefaultNodeData!(v::Graphs.ExVertex, data = nothing if initialized if size(initval,2) < N && size(initval, 1) == dims - warn("setDefaultNodeData! -- deprecated use of stdev.") + @warn "setDefaultNodeData! -- deprecated use of stdev." p = kde!(initval,diag(stdev)); pN = resample(p,N) elseif size(initval,2) < N && size(initval, 1) != dims @@ -149,7 +149,7 @@ function setDefaultNodeData!(v::Graphs.ExVertex, pN = kde!(initval) end # dims = size(initval,1) # rows indicate dimensions - sp = Int[0;] #round.(Int,linspace(dodims,dodims+dims-1,dims)) + sp = Int[0;] #round.(Int,range(dodims,stop=dodims+dims-1,length=dims)) gbw = getBW(pN)[:,1] gbw2 = Array{Float64}(length(gbw),1) gbw2[:,1] = gbw[:] @@ -283,7 +283,7 @@ end function getVal(vA::Array{Graphs.ExVertex,1}) - warn("getVal(::Vector{ExVertex}) is obsolete, use getVal.(ExVertex) instead.") + @warn "getVal(::Vector{ExVertex}) is obsolete, use getVal.(ExVertex) instead." len = length(vA) vals = Array{Array{Float64,2},1}() cols = Array{Int,1}() @@ -697,7 +697,7 @@ function addBayesNetVerts!(fg::FactorGraph, elimOrder::Array{Int,1}) vert.attributes["data"].BayesNetVertID = p localapi.updatevertex!(fg, vert) else - warn("addBayesNetVerts -- something is very wrong, should not have a Bayes net vertex") + @warn "addBayesNetVerts -- something is very wrong, should not have a Bayes net vertex" end end end @@ -742,7 +742,7 @@ function rmVarFromMarg(fgl::FactorGraph, fromvert::Graphs.ExVertex, gm::Array{Gr edge = localapi.getedge(fgl, id) if edge != nothing # hack to avoid dictionary use case if edge.SourceVertex.exVertexId == m.index || edge.DestVertex.exVertexId == m.index - warn("removing edge $(edge.neo4jEdgeId), between $(m.index) and $(n.index)") + @warn "removing edge $(edge.neo4jEdgeId), between $(m.index) and $(n.index)" localapi.deleteedge!(fgl, edge) m.attributes["data"].edgeIDs = alleids[[collect(1:(i-1));collect((i+1):length(alleids))]] localapi.updatevertex!(fgl, m) @@ -753,7 +753,7 @@ function rmVarFromMarg(fgl::FactorGraph, fromvert::Graphs.ExVertex, gm::Array{Gr end # if 0 edges, delete the marginal if length(localapi.outneighbors(fgl, m)) <= 1 - warn("removing vertex id=$(m.index)") + @warn "removing vertex id=$(m.index)" localapi.deletevertex!(fgl,m) end end @@ -871,7 +871,7 @@ function writeGraphPdf(fgl::FactorGraph; try viewerapp != nothing ? (@async run(`$(viewerapp) $(filepath)`)) : nothing catch e - warn("not able to show $(filepath) with viewerapp=$(viewerapp). Exception e=$(e)") + @warn "not able to show $(filepath) with viewerapp=$(viewerapp). Exception e=$(e)" end nothing end diff --git a/src/FactorGraphTypes.jl b/src/FactorGraphTypes.jl index dbb929fe4..e68337a82 100644 --- a/src/FactorGraphTypes.jl +++ b/src/FactorGraphTypes.jl @@ -147,7 +147,7 @@ mutable struct VariableNodeData dontmargin::Bool VariableNodeData() = new() function VariableNodeData(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11) - warn("Deprecated use of VariableNodeData(11 param), use 13 parameters instead") + @warn "Deprecated use of VariableNodeData(11 param), use 13 parameters instead" new(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11, nothing, true, false, false) # TODO ensure this is initialized true is working for most cases end VariableNodeData(x1::Array{Float64,2}, @@ -385,7 +385,7 @@ function graphsGetEdge(fgl::FactorGraph, id::Int) end function graphsDeleteVertex!(fgl::FactorGraph, vert::Graphs.ExVertex) - warn("graphsDeleteVertex! -- not deleting Graphs.jl vertex id=$(vert.index)") + @warn "graphsDeleteVertex! -- not deleting Graphs.jl vertex id=$(vert.index)" nothing end diff --git a/src/JunctionTree.jl b/src/JunctionTree.jl index 3de52f4ea..e3230ef65 100644 --- a/src/JunctionTree.jl +++ b/src/JunctionTree.jl @@ -123,7 +123,6 @@ end function newPotential(tree::BayesTree, fg::FactorGraph, var::Int, prevVar::Int, p::Array{Int,1}) firvert = localapi.getvertex(fg,var) if (length(getData(firvert).separator) == 0) - # warn("newPotential -- sep length is 0") if (length(tree.cliques) == 0) addClique!(tree, fg, var) else diff --git a/src/SolveTree01.jl b/src/SolveTree01.jl index 6c147e5d4..001f28b94 100644 --- a/src/SolveTree01.jl +++ b/src/SolveTree01.jl @@ -262,7 +262,7 @@ function productbelief(fg::FactorGraph, @info "[drct]" pGM = getPoints(dens[1]) else - warn("Unknown density product on vertid=$(vertid), lennonp=$(lennonp), lenpart=$(lenpart)") + @warn "Unknown density product on vertid=$(vertid), lennonp=$(lennonp), lenpart=$(lenpart)" pGM = Array{Float64,2}(0,1) end diff --git a/src/SolverUtilities.jl b/src/SolverUtilities.jl index 995fc6db9..03748aa97 100644 --- a/src/SolverUtilities.jl +++ b/src/SolverUtilities.jl @@ -122,7 +122,6 @@ function numericRootGenericRandomizedFnc!( ccwl.cpt[Threads.threadid()].Y[1:ccwl.xDim] = ( r ).zero else # TODO print this output as needed - # warn("got NaN, ccwl.cpt[Threads.threadid()].particleidx = $(ccwl.cpt[Threads.threadid()].particleidx), r=$(r)") str = "ccw.thrid_=$(Threads.threadid()), got NaN, ccwl.cpt[Threads.threadid()].particleidx = $(ccwl.cpt[Threads.threadid()].particleidx), r=$(r)\n" ccall(:jl_, Nothing, (Any,), str) ccall(:jl_, Nothing, (Any,), ccwl.usrfnc!) @@ -130,7 +129,7 @@ function numericRootGenericRandomizedFnc!( for thatlen in 1:length(ccwl.params) str = "thatlen=$thatlen, ccwl.params[thatlen][:, ccwl.cpt[Threads.threadid()].particleidx]=$(ccwl.params[thatlen][:, ccwl.cpt[Threads.threadid()].particleidx])\n" ccall(:jl_, Nothing, (Any,), str) - warn(str) + @warn str end end elseif ccwl.partial @@ -171,7 +170,7 @@ Update the frozen node """ function setfreeze!(fgl::FactorGraph, sym::Symbol) if !isInitialized(fgl, sym) - warn("Vertex $(sym) is not initialized, and won't be frozen at this time.") + @warn "Vertex $(sym) is not initialized, and won't be frozen at this time." return nothing end vert = getVert(fgl, sym) @@ -192,7 +191,7 @@ Future: """ function fifoFreeze!(fgl::FactorGraph) if fgl.qfl == 0 - warn("Quasi fixed-lag is enabled buyt QFL horizon is zero. Please set a valid window with FactoGraph.qfl") + @warn "Quasi fixed-lag is enabled buyt QFL horizon is zero. Please set a valid window with FactoGraph.qfl" end tofreeze = fgl.fifo[1:(end-fgl.qfl)] diff --git a/test/fourdoortest.jl b/test/fourdoortest.jl index 340193bab..cace7764e 100644 --- a/test/fourdoortest.jl +++ b/test/fourdoortest.jl @@ -50,7 +50,7 @@ addFactor!(fg,[:x6;:x7], LinearConditional( Normal(60.0,2.0)) ) ensureAllInitialized!(fg) -mlc = MixturePrior(Normal.(doors[1,:], bws[1]), 0.25*ones(4)) +global mlc = MixturePrior(Normal.(doors[1,:], bws[1]), 0.25*ones(4)) # getSample(mlc) @@ -59,7 +59,7 @@ addFactor!(fg,[:x7], mlc ) # HMM computed ground truth, extended for 7 poses with landmark -gt = Dict{Symbol, Array{Float64,2}}() +global gt = Dict{Symbol, Array{Float64,2}}() gt[:x0]=reshape(Float64[0.0;1.97304 ],2,1) # -0.0342366 gt[:x2]=reshape(Float64[50.0; 2.83153 ],2,1) # 49.8797 gt[:x3]=reshape(Float64[100.0; 1.65557 ],2,1) # 99.8351 @@ -70,7 +70,7 @@ gt[:x7]=reshape(Float64[300.0; 2.14353 ],2,1) # 298.467 gt[:l1]=reshape(Float64[165.0; 1.17284 ],2,1) # 164.102 -tree = prepBatchTree!(fg, drawpdf=false); +global tree = prepBatchTree!(fg, drawpdf=false); # list vertices in fg @show xx,ll = ls(fg) diff --git a/test/testBayesTreeChordalProp.jl b/test/testBayesTreeChordalProp.jl index c0736e847..8050e8b9f 100644 --- a/test/testBayesTreeChordalProp.jl +++ b/test/testBayesTreeChordalProp.jl @@ -1,44 +1,44 @@ using IncrementalInference -# using KernelDensityEstimate, Gadfly # for vstack -fg = emptyFactorGraph() -N=100 +global fg = emptyFactorGraph() -doors = [-100.0;0.0;100.0;300.0]' -cov = [3.0] +global N=100 +global doors = [-100.0;0.0;100.0;300.0]' +global cov = [3.0] -v1 = addNode!(fg,:x1,ContinuousScalar,N=N) -f1 = addFactor!(fg,[v1], Obsv2(doors, cov', [1.0])) + +global v1 = addNode!(fg,:x1,ContinuousScalar,N=N) +global f1 = addFactor!(fg,[v1], Obsv2(doors, cov', [1.0])) # tem = 2.0*randn(1,N)+getVal(v1)+50.0 -v2 = addNode!(fg,:x2, ContinuousScalar, N=N) +global v2 = addNode!(fg,:x2, ContinuousScalar, N=N) addFactor!(fg,[v1;v2],Odo([50.0]',[2.0]',[1.0])) -v3=addNode!(fg,:x3,ContinuousScalar, N=N) +global v3=addNode!(fg,:x3,ContinuousScalar, N=N) addFactor!(fg,[v2;v3],Odo([50.0]',[4.0]',[1.0])) -v4=addNode!(fg,:x4,ContinuousScalar, N=N) +global v4=addNode!(fg,:x4,ContinuousScalar, N=N) addFactor!(fg,[v3;v4],Odo([50.0]',[2.0]',[1.0])) -v5=addNode!(fg,:x5,ContinuousScalar, N=N) +global v5=addNode!(fg,:x5,ContinuousScalar, N=N) addFactor!(fg,[v4;v5],Odo([50.0]',[2.0]',[1.0])) -l1=addNode!(fg, :l1, ContinuousScalar, N=N) +global l1=addNode!(fg, :l1, ContinuousScalar, N=N) addFactor!(fg, [v3,l1], Ranged([64.0],[0.5],[1.0])) -l2=addNode!(fg, :l2, ContinuousScalar, N=N) +global l2=addNode!(fg, :l2, ContinuousScalar, N=N) addFactor!(fg, [v4,l2], Ranged([16.0],[0.5],[1.0])) -l3=addNode!(fg, :l3, ContinuousScalar, N=N) +global l3=addNode!(fg, :l3, ContinuousScalar, N=N) addFactor!(fg, [v5,l3], Ranged([16.0],[0.5],[1.0])) # writeGraphPdf(fg); -tree = prepBatchTree!(fg,drawpdf=true); +global tree = prepBatchTree!(fg,drawpdf=true); # run(`evince bt.pdf`) # do belief propagation inference over tree once