-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDeprecated.jl
More file actions
364 lines (321 loc) · 11.9 KB
/
Deprecated.jl
File metadata and controls
364 lines (321 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
## ================================================================================
## Deprecated in v0.29
##=================================================================================
export FactorCompute
const FactorCompute = FactorDFG
const MetadataTypes = Union{
Int,
Float64,
String,
Bool,
Vector{Int},
Vector{Float64},
Vector{String},
Vector{Bool},
}
function getHash(entry::Blobentry)
return error(
"Blobentry field :hash has been deprecated; use :crchash or :shahash instead",
)
end
function getMetadata(node)
return error(
"getMetadata(node::$(typeof(node))) is deprecated; metadata is now stored in bloblets. Use getBloblets instead.",
)
# return JSON.parse(base64decode(f.metadata), Dict{Symbol, MetadataTypes})
end
# getTimestamp
# setTimestamp is deprecated for now we can implement setTimestamp!(dfg, lbl, ts) later.
function setTimestamp(args...; kwargs...)
return error("setTimestamp is obsolete, use addVariable!(..., timestamp=...) instead.")
end
function setTimestamp!(args...; kwargs...)
return error(
"setTimestamp! is not implemented, use addVariable!(..., timestamp=...) instead.",
)
end
##------------------------------------------------------------------------------
## solveInProgress
##------------------------------------------------------------------------------
# getSolveInProgress and isSolveInProgress is deprecated for DFG v1.0, we can bring it back fully implemented when needed.
# """
# $SIGNATURES
# Which variables or factors are currently being used by an active solver. Useful for ensuring atomic transactions.
# DevNotes:
# - Will be renamed to `data.solveinprogress` which will be in VND, not AbstractGraphNode -- see DFG #201
# Related
# isSolvable
# """
function getSolveInProgress(
var::Union{VariableDFG, FactorCompute},
solveKey::Symbol = :default,
)
# Variable
if var isa VariableDFG
if haskey(refStates(var), solveKey)
return refStates(var)[solveKey].solveInProgress
else
return 0
end
end
# Factor
return getFactorState(var).solveInProgress
end
#TODO missing set solveInProgress and graph level accessor
function isSolveInProgress(
node::Union{VariableDFG, FactorCompute},
solvekey::Symbol = :default,
)
return getSolveInProgress(node, solvekey) > 0
end
function getTypeFromSerializationModule(::AbstractString)
return error(
"getTypeFromSerializationModule is obsolete, use DFG.parseVariableType or IIF.getTypeFromSerializationModule.",
)
end
## Version checking
#NOTE fixed really bad function but kept similar as fallback #TODO upgrade to use pkgversion(m::Module)
function _getDFGVersion()
return pkgversion(DistributedFactorGraphs)
end
function _versionCheck(node::Union{<:VariableDFG, <:FactorDFG})
if node._version.minor < _getDFGVersion().minor
@warn "This data was serialized using DFG $(node._version) but you have $(_getDFGVersion()) installed, there may be deserialization issues." maxlog =
10
end
end
refMetadata(node) = node.metadata
@deprecate packDistribution(d) pack(d)
@deprecate unpackDistribution(d) unpack(d)
function setDescription!(args...)
return error("setDescription! was removed and may be implemented later.")
end
# TODO find replacement.
function _getDuplicatedEmptyDFG(
dfg::GraphsDFG{P, V, F},
) where {P <: AbstractDFGParams, V <: AbstractGraphVariable, F <: AbstractGraphFactor}
Base.depwarn("_getDuplicatedEmptyDFG is deprecated.", :_getDuplicatedEmptyDFG)
newDfg = GraphsDFG{P, V, F}(;
agentLabel = getAgentLabel(dfg),
graphLabel = getGraphLabel(dfg),
solverParams = deepcopy(dfg.solverParams),
)
# DFG.setDescription!(newDfg, "(Copy of) $(DFG.getDescription(dfg))")
return newDfg
end
#Type gets confused with returning a DataType, Kind is an instance of StateType
@deprecate getVariableType(args...) getStateKind(args...)
function getVariableTypeName(v::VariableSummary)
Base.depwarn("getVariableTypeName is deprecated.", :getVariableTypeName)
return v.statetype
end
function getMetadata(dfg::AbstractDFG, label::Symbol, key::Symbol)
return getVariable(dfg, label).smallData[key]
end
function addMetadata!(dfg::AbstractDFG, label::Symbol, pair::Pair{Symbol, <:MetadataTypes})
v = getVariable(dfg, label)
haskey(v.smallData, pair.first) && throw(LabelExistsError("Metadata", pair.first))
push!(v.smallData, pair)
mergeVariable!(dfg, v)
return v.smallData #or pair TODO
end
function updateMetadata!(
dfg::AbstractDFG,
label::Symbol,
pair::Pair{Symbol, <:MetadataTypes};
warn_if_absent::Bool = true,
)
v = getVariable(dfg, label)
warn_if_absent &&
!haskey(v.smallData, pair.first) &&
@warn("$(pair.first) does not exist, adding.")
push!(v.smallData, pair)
mergeVariable!(dfg, v)
return v.smallData #or pair TODO
end
function deleteMetadata!(dfg::AbstractDFG, label::Symbol, key::Symbol)
v = getVariable(dfg, label)
pop!(v.smallData, key)
mergeVariable!(dfg, v)
return 1
end
function listMetadata(dfg::AbstractDFG, label::Symbol)
v = getVariable(dfg, label)
return collect(keys(v.smallData)) #or pair TODO
end
function emptyMetadata!(dfg::AbstractDFG, label::Symbol)
v = getVariable(dfg, label)
empty!(v.smallData)
mergeVariable!(dfg, v)
return v.smallData #or pair TODO
end
# """
# $(SIGNATURES)
# Function to generate source string - agentLabel|graphLabel|varLabel
# """
function buildSourceString(dfg::AbstractDFG, label::Symbol)
return "$(getAgentLabel(dfg))|$(getGraphLabel(dfg))|$label"
end
getAgentMetadata(args...) = error("getAgentMetadata is obsolete, use Bloblets instead.")
setAgentMetadata!(args...) = error("setAgentMetadata! is obsolete, use Bloblets instead.")
getGraphMetadata(args...) = error("getGraphMetadata is obsolete, use Bloblets instead.")
setGraphMetadata!(args...) = error("setGraphMetadata! is obsolete, use Bloblets instead.")
function updateAgentMetadata!(args...)
return error("updateAgentMetadata! is obsolete, use Bloblets instead.")
end
function updateGraphMetadata!(args...)
return error("updateGraphMetadata! is obsolete, use Bloblets instead.")
end
function deleteAgentMetadata!(args...)
return error("deleteAgentMetadata! is obsolete, use Bloblets instead.")
end
function deleteGraphMetadata!(args...)
return error("deleteGraphMetadata! is obsolete, use Bloblets instead.")
end
function emptyAgentMetadata!(args...)
return error("emptyAgentMetadata! is obsolete, use Bloblets instead.")
end
function emptyGraphMetadata!(args...)
return error("emptyGraphMetadata! is obsolete, use Bloblets instead.")
end
#TODO deprecate AbstractPackedObservation
abstract type AbstractPackedObservation end
const PackedObservation = AbstractPackedObservation
#TODO deprecate AbstractPackedBelief
abstract type AbstractPackedBelief end
const PackedBelief = AbstractPackedBelief
#TODO maybe replace with `listVariablesAddOrder` or using sort on `listVariables`
getAddHistory(dfg::AbstractDFG) = error("getAddHistory is deprecated.")
getAddHistory(dfg::GraphsDFG) = listVariables(dfg) #default listVariables on GraphsDFG is ordered
## Utility functions for getting type names and modules (from IncrementalInference)
_getmodule(t::T) where {T} = T.name.module
_getname(t::T) where {T} = T.name.name
function convertPackedType(t::Union{T, Type{T}}) where {T <: AbstractObservation}
return getfield(_getmodule(t), Symbol("Packed$(_getname(t))"))
end
function convertStructType(::Type{PT}) where {PT <: AbstractPackedObservation}
# see #668 for expanded reasoning. PT may be ::UnionAll if the type is of template type.
ptt = PT isa DataType ? PT.name.name : PT
moduleName = PT isa DataType ? PT.name.module : Main
symbolName = Symbol(string(ptt)[7:end])
return getfield(moduleName, symbolName)
end
@deprecate getBlobentry(fg::AbstractDFG, varlabel::Symbol, key::Symbol) getVariableBlobentry(
fg,
varlabel,
key,
)
@deprecate getBlobentries(fg::AbstractDFG, varlabel::Symbol; kwargs...) getVariableBlobentries(
fg,
varlabel;
kwargs...,
)
@deprecate addBlobentry!(fg::AbstractDFG, varlabel::Symbol, entry::Blobentry) addVariableBlobentry!(
fg,
varlabel,
entry,
)
@deprecate mergeBlobentry!(fg::AbstractDFG, varlabel::Symbol, entry::Blobentry) mergeVariableBlobentry!(
fg,
varlabel,
entry,
)
@deprecate deleteBlobentry!(fg::AbstractDFG, varlabel::Symbol, key::Symbol) deleteVariableBlobentry!(
fg,
varlabel,
key,
)
@deprecate listBlobentries(fg::AbstractDFG, varlabel::Symbol) listVariableBlobentries(
fg,
varlabel,
)
# """
# $SIGNATURES
# Determine if the variable or factor neighbors have the `tags:;Vector{Symbol}`, and `matchAll::Bool`.
# """
function hasTagsNeighbors(
dfg::AbstractDFG,
node_label::Symbol,
tags::Vector{Symbol};
matchAll::Bool = true,
)
#
Base.depwarn(
"hasTagsNeighbors is deprecated, use listNeighbors with tagsFilter instead",
:hasTagsNeighbors,
)
# assume only variables or factors are neighbors
alltags = union((listNeighbors(dfg, node_label) .|> x -> listTags(dfg, x))...)
return length(filter(x -> x in alltags, tags)) >= (matchAll ? length(tags) : 1)
end
#Obsolete PPEs
abstract type AbstractPointParametricEst end
function _ppe_obsolete()
return error(
"PPEs are obsolete and will be replaced soon (IIF.calcMeanMaxSuggested can be used in some cases), see #1133.",
)
end
getPPEMax(args...) = _ppe_obsolete()
getPPEMean(args...) = _ppe_obsolete()
getPPESuggested(args...) = _ppe_obsolete()
getLastUpdatedTimestamp(est::AbstractPointParametricEst) = _ppe_obsolete()
getPPE(args...) = _ppe_obsolete()
addPPE!(args...) = _ppe_obsolete()
addPPEs!(args...) = _ppe_obsolete()
updatePPE!(args...) = _ppe_obsolete()
deletePPE!(args...) = _ppe_obsolete()
listPPEs(args...) = _ppe_obsolete()
mergePPEs!(args...) = _ppe_obsolete()
getPPEDict(args...) = _ppe_obsolete()
getPPEs(args...) = _ppe_obsolete()
getVariablePPEDict(args...) = _ppe_obsolete()
getVariablePPE(args...) = _ppe_obsolete()
MeanMaxPPE(args...; kwargs...) = _ppe_obsolete()
getEstimateFields(args...) = _ppe_obsolete()
function getFactorState(args...)
return error(
"getFactorState is deprecated, use DFG.getRecipehyper or DFG.getRecipestate instead.",
)
end
function setTags!(node, tags::Union{Vector{Symbol}, Set{Symbol}})
Base.depwarn("setTags! is deprecated, use mergeTags! or addTags! instead.", :setTags!)
node.tags !== tags && empty!(node.tags)
return union!(node.tags, tags)
end
# """
# $(SIGNATURES)
# Get a matrix indicating relationships between variables and factors. Rows are
# all factors, columns are all variables, and each cell contains either nothing or
# the symbol of the relating factor. The first row and first column are factor and
# variable headings respectively.
# Note:
# - rather use getBiadjacencyMatrix
# - Returns either of `::Matrix{Union{Nothing, Symbol}}`
# """
# Deprecated in favor of getBiadjacencyMatrix as it is not efficient for large graphs.
function getAdjacencyMatrixSymbols(
dfg::AbstractDFG;
solvableFilter::Union{Nothing, Function} = nothing,
)
#
varLabels = sort(map(v -> v.label, getVariables(dfg; solvableFilter)))
factLabels = sort(map(f -> f.label, getFactors(dfg; solvableFilter)))
vDict = Dict(varLabels .=> [1:length(varLabels)...] .+ 1)
adjMat = Matrix{Union{Nothing, Symbol}}(
nothing,
length(factLabels) + 1,
length(varLabels) + 1,
)
# Set row/col headings
adjMat[2:end, 1] = factLabels
adjMat[1, 2:end] = varLabels
for (fIndex, factLabel) in enumerate(factLabels)
factVars = listNeighbors(dfg, getFactor(dfg, factLabel); solvable)
map(vLabel -> adjMat[fIndex + 1, vDict[vLabel]] = factLabel, factVars)
end
return adjMat
end
@deprecate findVariableNearTimestamp(args...; kwargs...) findVariablesNearTimestamp(
args...;
kwargs...,
)