Skip to content

Commit d67220d

Browse files
authored
Merge pull request #350 from JuliaRobotics/fix/1Q20/290
remove some deprecations
2 parents e2b1e17 + 3772e73 commit d67220d

File tree

5 files changed

+73
-135
lines changed

5 files changed

+73
-135
lines changed

src/Deprecated.jl

Lines changed: 46 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,33 @@
22
# deprecation staging area
33
##==============================================================================
44

5+
56
##==============================================================================
6-
## Remove in 0.7
7+
## Remove in 0.8
78
##==============================================================================
89

9-
Base.getproperty(x::DFGVariable,f::Symbol) = begin
10-
if f == :estimateDict
11-
@warn "estimateDict is deprecated, use ppeDict instead"
12-
getfield(x, :ppeDict)
13-
elseif f == :solvable
14-
getfield(x,:_dfgNodeParams).solvable
15-
elseif f == :_internalId
16-
getfield(x,:_dfgNodeParams)._internalId
17-
else
18-
getfield(x,f)
19-
end
20-
end
10+
#TODO alias or deprecate
11+
@deprecate getVariableIds(dfg::AbstractDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0) listVariables(dfg, regexFilter, tags=tags, solvable=solvable)
2112

22-
Base.setproperty!(x::DFGVariable,f::Symbol, val) = begin
23-
if f == :estimateDict
24-
error("estimateDict is deprecated, use ppeDict instead")
25-
elseif f == :solvable
26-
getfield(x,:_dfgNodeParams).solvable = val
27-
elseif f == :_internalId
28-
getfield(x,:_dfgNodeParams)._internalId = val
29-
else
30-
setfield!(x,f,val)
31-
end
32-
end
13+
@deprecate getFactorIds(dfg, regexFilter=nothing; solvable=0) listFactors(dfg, regexFilter, solvable=solvable)
3314

34-
Base.getproperty(x::DFGVariableSummary,f::Symbol) = begin
35-
if f == :estimateDict
36-
@warn "estimateDict is deprecated, use ppeDict instead"
37-
getfield(x, :ppeDict)
38-
else
39-
getfield(x,f)
40-
end
41-
end
15+
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)
4232

4333

4434
Base.getproperty(x::DFGFactor,f::Symbol) = begin
@@ -78,87 +68,30 @@ Base.setproperty!(x::DFGFactor,f::Symbol, val) = begin
7868
end
7969
end
8070

81-
Base.getproperty(x::GenericFunctionNodeData,f::Symbol) = begin
82-
f == :fncargvID && Base.depwarn("GenericFunctionNodeData field fncargvID will be deprecated, use `getVariableOrder` instead",:getproperty)#@warn "fncargvID is deprecated, use `getVariableOrder` instead"
83-
84-
getfield(x, f)
85-
86-
end
87-
88-
Base.setproperty!(x::GenericFunctionNodeData,f::Symbol, val) = begin
89-
f == :fncargvID && Base.depwarn("GenericFunctionNodeData field fncargvID will be deprecated, use `getVariableOrder` instead",:getproperty)#@warn "fncargvID is deprecated, use `getVariableOrder` instead"
90-
91-
setfield!(x,f,val)
92-
93-
end
94-
95-
# update is implied, see API wiki
96-
@deprecate mergeUpdateVariableSolverData!(dfg, sourceVariable) mergeVariableData!(dfg, sourceVariable)
97-
@deprecate mergeUpdateGraphSolverData!(sourceDFG, destDFG, varSyms) mergeGraphVariableData!(destDFG, sourceDFG, varSyms)
98-
99-
#TODO alias or deprecate
100-
@deprecate getVariableIds(dfg::AbstractDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0) listVariables(dfg, regexFilter, tags=tags, solvable=solvable)
101-
102-
@deprecate getFactorIds(dfg, regexFilter=nothing; solvable=0) listFactors(dfg, regexFilter, solvable=solvable)
103-
104-
#NOTE too many aliases on PPE
105-
106-
@deprecate getVariablePPEs(v::VariableDataLevel1) getPPEDict(v)
107-
108-
@deprecate getPPEs(vari::VariableDataLevel1) getPPEDict(v)
109-
110-
@deprecate getVariablePPE(args...) getPPE(args...)
111-
112-
113-
#TODO doesn't look like this existed
114-
# @deprecate timestamp(v) getTimestamp(v)
115-
116-
@deprecate setSolverParams(args...) setSolverParams!(args...)
117-
118-
@deprecate setDescription(args...) setDescription!(args...)
119-
120-
@deprecate getAdjacencyMatrixSparse(dfg::AbstractDFG; solvable::Int=0) getBiadjacencyMatrix(dfg, solvable=solvable)
121-
122-
@deprecate solverData(f::DFGFactor) getSolverData(f)
123-
124-
@deprecate solverData(v::DFGVariable, key::Symbol=:default) getSolverData(v, key)
125-
126-
@deprecate solverDataDict(args...) getSolverDataDict(args...)
127-
128-
@deprecate internalId(args...) getInternalId(args...)
129-
130-
@deprecate pack(dfg::AbstractDFG, d::VariableNodeData) packVariableNodeData(dfg, d)
131-
@deprecate unpack(dfg::AbstractDFG, d::PackedVariableNodeData) unpackVariableNodeData(dfg, d)
132-
133-
export getLabelDict
134-
getLabelDict(dfg::AbstractDFG) = error("getLabelDict is deprecated, consider using listing functions")
135-
136-
export getAdjacencyMatrix
137-
"""
138-
$(SIGNATURES)
139-
Get a matrix indicating relationships between variables and factors. Rows are
140-
all factors, columns are all variables, and each cell contains either nothing or
141-
the symbol of the relating factor. The first row and first column are factor and
142-
variable headings respectively.
143-
"""
144-
function getAdjacencyMatrix(dfg::AbstractDFG; solvable::Int=0)::Matrix{Union{Nothing, Symbol}}
145-
error("Deprecated function, please use getBiadjacencyMatrix")
146-
end
147-
148-
149-
export buildSubgraphFromLabels
150-
function buildSubgraphFromLabels(dfg::G,
151-
syms::Vector{Symbol};
152-
subfg::AbstractDFG=(G <: InMemoryDFGTypes ? G : GraphsDFG)(params=getSolverParams(dfg)),
153-
solvable::Int=0,
154-
allowedFactors::Union{Nothing, Vector{Symbol}}=nothing )::G where G <: AbstractDFG
155-
#
156-
@warn "Deprecated buildSubgraphFromLabels, use buildSubgraphFromLabels! instead."
157-
buildSubgraphFromLabels!(dfg, syms, subfg=subfg, solvable=solvable, allowedFactors=allowedFactors )
158-
end
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
15983

160-
@deprecate sortVarNested(vars::Vector{Symbol}) sortDFG(vars)
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
16195

16296

163-
#NOTE This one is still used in IIF so maybe leave a bit longer
164-
@deprecate getfnctype(args...) getFactorType(args...)
97+
#

src/DistributedFactorGraphs.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ export getPPEDict
144144

145145
# CRUD & SET
146146
export getPPE,
147+
getPPEs,
148+
getVariablePPE,
149+
getVariablePPEs,
147150
addPPE!,
148151
updatePPE!,
149152
deletePPE!,

src/needsahome.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ print(fct::DFGFactor) = @show fct
8989
9090
Display and return to console the user factor identified by tag name.
9191
"""
92-
printFactor(fgl::AbstractDFG, fsym::Symbol) = print(getFactor(dfg, sym))
92+
printFactor(dfg::AbstractDFG, sym::Symbol) = print(getFactor(dfg, sym))
9393

9494
"""
9595
$SIGNATURES
@@ -99,11 +99,19 @@ Display the content of `VariableNodeData` to console for a given factor graph an
9999
Dev Notes
100100
- TODO split as two show macros between AMP and DFG
101101
"""
102-
printVariable(fgl::AbstractDFG, vsym::Symbol, solveKey::Symbol=:default) = print(getVariable(dfg, sym))
102+
printVariable(dfg::AbstractDFG, sym::Symbol, solveKey::Symbol=:default) = print(getVariable(dfg, sym))
103103

104-
print(fgl::AbstractDFG, fsym::Symbol) = isVariable(dfg,fsym) ? printVariable(dfg, fsym) : printFactor(dfg, sym)
104+
print(dfg::AbstractDFG, sym::Symbol) = isVariable(dfg,sym) ? printVariable(dfg, sym) : printFactor(dfg, sym)
105105

106106

107+
#NOT too many aliases on PPE, brought back from deprecated DF
108+
109+
getVariablePPEs(v::VariableDataLevel1) = getPPEDict(v)
110+
111+
getPPEs(vari::VariableDataLevel1) = getPPEDict(v)
112+
113+
getVariablePPE(args...) = getPPE(args...)
114+
107115
## KEEPING COMMENT, WANT TO BE CONSOLIDATED WITH FUNCTION ABOVE -- KEEPING ONLY ONE FOR MAINTAINABILITY
108116
## STILL NEEDS TO BE CONSOLIDATED WITH `DFG._copyIntoGraph`
109117
# """

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 and 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: 4 additions & 16 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

@@ -468,8 +460,8 @@ function PPETestBlock!(fg, v1)
468460
@test deletePPE!(fg, :a, :default) == ppe
469461

470462
#FIXME copied from lower
471-
@test @test_deprecated getVariablePPEs(v1) == v1.ppeDict
472-
@test_throws KeyError getPPE(v1, :notfound)
463+
# @test @test_deprecated getVariablePPEs(v1) == v1.ppeDict
464+
@test_throws Union{KeyError,UndefVarError} getPPE(v1, :notfound)
473465
#TODO
474466
# @test_deprecated getVariablePPE(v1)
475467

@@ -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)