Skip to content

Commit ac0b03c

Browse files
committed
remove as much possble,
closes #290
1 parent 3ac9451 commit ac0b03c

File tree

3 files changed

+91
-69
lines changed

3 files changed

+91
-69
lines changed

src/Deprecated.jl

Lines changed: 80 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,86 @@
1313
@deprecate getFactorIds(dfg, regexFilter=nothing; solvable=0) listFactors(dfg, regexFilter, solvable=solvable)
1414

1515

16+
export getLabelDict
17+
getLabelDict(dfg::AbstractDFG) = error("getLabelDict is deprecated, consider using listing functions")
18+
19+
export getAdjacencyMatrix
20+
"""
21+
$(SIGNATURES)
22+
Get a matrix indicating relationships between variables and factors. Rows are
23+
all factors, columns are all variables, and each cell contains either nothing or
24+
the symbol of the relating factor. The first row and first column are factor and
25+
variable headings respectively.
26+
"""
27+
function getAdjacencyMatrix(dfg::AbstractDFG; solvable::Int=0)::Matrix{Union{Nothing, Symbol}}
28+
error("Deprecated function, please use getBiadjacencyMatrix")
29+
end
30+
31+
@deprecate getAdjacencyMatrixSparse(dfg::AbstractDFG; solvable::Int=0) getBiadjacencyMatrix(dfg, solvable=solvable)
32+
33+
34+
Base.getproperty(x::DFGFactor,f::Symbol) = begin
35+
if f == :solvable
36+
getfield(x,:_dfgNodeParams).solvable
37+
elseif f == :_internalId
38+
getfield(x,:_dfgNodeParams)._internalId
39+
elseif f == :data
40+
41+
if !(@isdefined getFactorDataWarnOnce)
42+
@warn "get: data field is deprecated, use getSolverData. Further warnings are suppressed"
43+
global getFactorDataWarnOnce = true
44+
end
45+
46+
getfield(x, :solverData)
47+
else
48+
getfield(x,f)
49+
end
50+
end
51+
52+
Base.setproperty!(x::DFGFactor,f::Symbol, val) = begin
53+
if f == :solvable
54+
setfield!(x,f,val)
55+
getfield(x,:_dfgNodeParams).solvable = val
56+
elseif f == :_internalId
57+
getfield(x,:_dfgNodeParams)._internalId = val
58+
elseif f == :data
59+
60+
if !(@isdefined setFactorDataWarnOnce)
61+
@warn "set: data field is deprecated, use ...TODO? Further warnings are suppressed"
62+
global setFactorDataWarnOnce = true
63+
end
64+
65+
setfield!(x,:solverData, val)
66+
else
67+
setfield!(x,f,val)
68+
end
69+
end
70+
71+
Base.getproperty(x::DFGVariable,f::Symbol) = begin
72+
# if f == :estimateDict
73+
# @warn "estimateDict is deprecated, use ppeDict instead"
74+
# getfield(x, :ppeDict)
75+
if f == :solvable
76+
getfield(x,:_dfgNodeParams).solvable
77+
elseif f == :_internalId
78+
getfield(x,:_dfgNodeParams)._internalId
79+
else
80+
getfield(x,f)
81+
end
82+
end
83+
84+
Base.setproperty!(x::DFGVariable,f::Symbol, val) = begin
85+
# if f == :estimateDict
86+
# error("estimateDict is deprecated, use ppeDict instead")
87+
if f == :solvable
88+
getfield(x,:_dfgNodeParams).solvable = val
89+
elseif f == :_internalId
90+
getfield(x,:_dfgNodeParams)._internalId = val
91+
else
92+
setfield!(x,f,val)
93+
end
94+
end
95+
1696
##==============================================================================
1797
## Remove in 0.7
1898
##==============================================================================
@@ -52,42 +132,6 @@
52132
# end
53133
#
54134
#
55-
# Base.getproperty(x::DFGFactor,f::Symbol) = begin
56-
# if f == :solvable
57-
# getfield(x,:_dfgNodeParams).solvable
58-
# elseif f == :_internalId
59-
# getfield(x,:_dfgNodeParams)._internalId
60-
# elseif f == :data
61-
#
62-
# if !(@isdefined getFactorDataWarnOnce)
63-
# @warn "get: data field is deprecated, use getSolverData. Further warnings are suppressed"
64-
# global getFactorDataWarnOnce = true
65-
# end
66-
#
67-
# getfield(x, :solverData)
68-
# else
69-
# getfield(x,f)
70-
# end
71-
# end
72-
#
73-
# Base.setproperty!(x::DFGFactor,f::Symbol, val) = begin
74-
# if f == :solvable
75-
# setfield!(x,f,val)
76-
# getfield(x,:_dfgNodeParams).solvable = val
77-
# elseif f == :_internalId
78-
# getfield(x,:_dfgNodeParams)._internalId = val
79-
# elseif f == :data
80-
#
81-
# if !(@isdefined setFactorDataWarnOnce)
82-
# @warn "set: data field is deprecated, use ...TODO? Further warnings are suppressed"
83-
# global setFactorDataWarnOnce = true
84-
# end
85-
#
86-
# setfield!(x,:solverData, val)
87-
# else
88-
# setfield!(x,f,val)
89-
# end
90-
# end
91135
#
92136
# Base.getproperty(x::GenericFunctionNodeData,f::Symbol) = begin
93137
# f == :fncargvID && Base.depwarn("GenericFunctionNodeData field fncargvID will be deprecated, use `getVariableOrder` instead",:getproperty)#@warn "fncargvID is deprecated, use `getVariableOrder` instead"
@@ -115,8 +159,6 @@
115159
#
116160
# @deprecate setDescription(args...) setDescription!(args...)
117161
#
118-
# @deprecate getAdjacencyMatrixSparse(dfg::AbstractDFG; solvable::Int=0) getBiadjacencyMatrix(dfg, solvable=solvable)
119-
#
120162
# @deprecate solverData(f::DFGFactor) getSolverData(f)
121163
#
122164
# @deprecate solverData(v::DFGVariable, key::Symbol=:default) getSolverData(v, key)
@@ -128,20 +170,6 @@
128170
# @deprecate pack(dfg::AbstractDFG, d::VariableNodeData) packVariableNodeData(dfg, d)
129171
# @deprecate unpack(dfg::AbstractDFG, d::PackedVariableNodeData) unpackVariableNodeData(dfg, d)
130172
#
131-
# export getLabelDict
132-
# getLabelDict(dfg::AbstractDFG) = error("getLabelDict is deprecated, consider using listing functions")
133-
#
134-
# export getAdjacencyMatrix
135-
# """
136-
# $(SIGNATURES)
137-
# Get a matrix indicating relationships between variables and factors. Rows are
138-
# all factors, columns are all variables, and each cell contains either nothing or
139-
# the symbol of the relating factor. The first row and first column are factor and
140-
# variable headings respectively.
141-
# """
142-
# function getAdjacencyMatrix(dfg::AbstractDFG; solvable::Int=0)::Matrix{Union{Nothing, Symbol}}
143-
# error("Deprecated function, please use getBiadjacencyMatrix")
144-
# end
145173
#
146174
#
147175
# export buildSubgraphFromLabels

src/services/DFGVariable.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,18 @@ Since the `timestamp` field is not mutable `setTimestamp` returns a new variable
162162
Use [`updateVariable!`](@ref) on the returened variable to update it in the factor graph if needed. Alternatively use [`setTimestamp!`](@ref).
163163
See issue #315.
164164
"""
165-
function setTimestamp(v::DFGVariable, ts::DateTime)
165+
function setTimestamp(v::DFGVariable, ts::DateTime; verbose::Bool=true)
166+
if verbose
167+
@warn "verbose=true: setTimestamp(::DFGVariable,...) creates a returns a new immutable DFGVariable object (and didn't change a distributed factor graph object), make sure you are using the right pointers: getVariable(...). See setTimestamp!(...) and note suggested use is at addVariable!(..., [timestamp=...]). See DFG #315 for explanation."
168+
end
166169
return DFGVariable(v.label, ts, v.tags, v.ppeDict, v.solverDataDict, v.smallData, v.bigData, v._dfgNodeParams)
167170
end
168171

169-
function setTimestamp(v::DFGVariableSummary, ts::DateTime)
170-
return DFGVariableSummary(v.label, ts, v.tags, v.estimateDict, v.softtypename, v.bigData, v._internalId)
172+
function setTimestamp(v::DFGVariableSummary, ts::DateTime; verbose::Bool=true)
173+
if verbose
174+
@warn "verbose=true: setTimestamp(::DFGVariableSummary,...) creates a returns a new immutable DFGVariable object (and didn't change a distributed factor graph object), make sure you are using the right pointers: getVariable(...). See setTimestamp!(...) and note suggested use is at addVariable!(..., [timestamp=...]). See DFG #315 for explanation."
175+
end
176+
return DFGVariableSummary(v.label, ts, v.tags, v.ppeDict, v.softtypename, v.bigData, v._internalId)
171177
end
172178

173179

test/testBlocks.jl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ function DFGStructureAndAccessors(::Type{T}, solparams::AbstractParams=NoSolverP
107107

108108
#deprecated
109109
@test_throws ErrorException getLabelDict(fg)
110-
@test @test_deprecated setDescription(fg, des) == des
111110

112111

113112
#TODO
@@ -179,9 +178,6 @@ function DFGVariableSCA()
179178

180179
@test getTimestamp(v1) == v1.timestamp
181180

182-
@test getInternalId(v1) == v1._internalId
183-
@test getInternalId(v1) == v1._dfgNodeParams._internalId
184-
185181
@test getSolvable(v1) == 0
186182
@test getSolvable(v2) == 1
187183

@@ -217,7 +213,7 @@ function DFGVariableSCA()
217213
#no accessors on BigData, only CRUD
218214

219215
#deprecated
220-
@test @test_deprecated solverData(v1, :default) === v1.solverDataDict[:default]
216+
# @test @test_deprecated solverData(v1, :default) === v1.solverDataDict[:default]
221217

222218

223219
# #TODO sort out
@@ -259,7 +255,6 @@ function DFGFactorSCA()
259255

260256
@test getTimestamp(f1) == f1.timestamp
261257

262-
@test getInternalId(f1) == f1._internalId
263258
@test getInternalId(f1) == f1._dfgNodeParams._internalId
264259

265260
@test getSolvable(f1) == 0
@@ -296,9 +291,6 @@ function DFGFactorSCA()
296291
#TODO don't know if this should be used, added for completeness, it just wastes the gc's time
297292
@test setSolverData!(f1, deepcopy(gfnd)) == gfnd
298293

299-
# Deprecated functions
300-
@test @test_deprecated solverData(f1) === f1.solverData
301-
302294
# create f0 here for a later timestamp
303295
f0 = DFGFactor(:af1, [:a], gfnd_prior, tags = Set([:PRIOR]))
304296

@@ -586,7 +578,6 @@ function VSDTestBlock!(fg, v1)
586578

587579
#FIXME copied from lower
588580
@test getSolverData(v1) === v1.solverDataDict[:default]
589-
@test @test_logs (:warn, r"[Dd]eprecate") solverData(v1, :default) === v1.solverDataDict[:default]
590581

591582
# Add new VND of type ContinuousScalar to :x0
592583
# Could also do VariableNodeData(ContinuousScalar())
@@ -694,9 +685,6 @@ function testGroup!(fg, v1, v2, f0, f1)
694685

695686
# TODO Mabye implement IIF type here
696687
# Requires IIF or a type in IIF
697-
@test @test_deprecated getfnctype(f1.solverData) === getFactorType(f1.solverData)
698-
@test @test_deprecated getfnctype(f1) === getFactorType(f1)
699-
@test @test_deprecated getfnctype(fg, :abf1) === getFactorType(fg, :abf1)
700688
@test getFactorType(f1.solverData) === f1.solverData.fnc.usrfnc!
701689
@test getFactorType(f1) === f1.solverData.fnc.usrfnc!
702690
@test getFactorType(fg, :abf1) === f1.solverData.fnc.usrfnc!
@@ -705,6 +693,7 @@ function testGroup!(fg, v1, v2, f0, f1)
705693
@test lsfPriors(fg) == [:af1]
706694

707695
#TODO add test, don't know what we want from this
696+
# desire is to list all factor types present a graph.
708697
@test_broken lsfTypes(fg)
709698

710699
@test ls(fg, TestFunctorInferenceType1) == [:abf1]
@@ -773,7 +762,6 @@ function testGroup!(fg, v1, v2, f0, f1)
773762

774763
@testset "Sorting" begin
775764
unsorted = [:x1_3;:x1_6;:l1;:april1] #this will not work for :x1x2f1
776-
@test @test_deprecated sortVarNested(unsorted) == sortDFG(unsorted)
777765
@test sort([:x1x2f1, :x1l1f1], lt=natural_lt) == [:x1l1f1, :x1x2f1]
778766

779767
# NOTE Some of what is possible with sort and the wrappers

0 commit comments

Comments
 (0)