Skip to content

Commit 169f629

Browse files
authored
Merge pull request #700 from JuliaRobotics/maint/20Q4/softTovariableType
softtype -> variableType
2 parents 980938f + 74e99cc commit 169f629

19 files changed

+207
-151
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.10.11"
3+
version = "0.11.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

docs/extra/CoreAPI.fods

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@
14921492
</table:table-cell>
14931493
<table:table-cell table:style-name="ce28"/>
14941494
<table:table-cell table:style-name="ce52" office:value-type="string" calcext:value-type="string">
1495-
<text:p>softtypename</text:p>
1495+
<text:p>variableTypeName</text:p>
14961496
</table:table-cell>
14971497
<table:table-cell table:style-name="ce47"/>
14981498
<table:table-cell table:style-name="ce74"/>

docs/src/GraphData.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ The solvable flag indicates whether the solver should make use of the variable o
7171

7272
### Variables
7373

74-
#### Soft Type
74+
#### Variable Type
7575

76-
The soft type is the underlying inference variable type, such as a Pose2.
76+
The `variableType` is the underlying inference variable type, such as a Pose2.
7777

78-
- [`getSofttype`](@ref)
78+
- [`getVariableType`](@ref)
7979

8080

8181
#### Packed Parametric Estimates

src/CloudGraphsDFG/CloudGraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import ...DistributedFactorGraphs: setSolverParams!,
2020
exists,
2121
isVariable,
2222
isFactor,
23-
getSofttype,
23+
getVariableType,
2424
getDescription,
2525
updateVariable!,
2626
updateFactor!,

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ isFactor(dfg::CloudGraphsDFG, sym::Symbol)::Bool =
152152
_getNodeCount(dfg.neo4jInstance, ["FACTOR", dfg.userId, dfg.robotId, dfg.sessionId, String(sym)]) == 1
153153

154154
#Optimization
155-
function getSofttype(dfg::CloudGraphsDFG, lbl::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
156-
st = _getNodeProperty(dfg.neo4jInstance, union(_getLabelsForType(dfg, DFGVariable), [String(lbl)]), "softtype", currentTransaction=currentTransaction)
157-
@debug "Trying to find softtype: $st"
158-
softType = getTypeFromSerializationModule(st)
159-
return softType()
155+
function getVariableType(dfg::CloudGraphsDFG, lbl::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
156+
st = _getNodeProperty(dfg.neo4jInstance, union(_getLabelsForType(dfg, DFGVariable), [String(lbl)]), "variableType", currentTransaction=currentTransaction)
157+
@debug "Trying to find variableType: $st"
158+
variableType = getTypeFromSerializationModule(st)
159+
return variableType()
160160
end
161161

162162
function addVariable!(dfg::CloudGraphsDFG, variable::DFGVariable)
@@ -177,7 +177,7 @@ function updateVariable!(dfg::CloudGraphsDFG, variable::DFGVariable; warn_if_abs
177177
# Create/update the base variable
178178
# NOTE: We are not merging the variable.tags into the labels anymore. We can index by that but not
179179
# going to pollute the graph with unnecessary (and potentially dangerous) labels.
180-
addProps = Dict("softtype" => "\"$(DistributedFactorGraphs.typeModuleName(getSofttype(variable)))\"")
180+
addProps = Dict("variableType" => "\"$(DistributedFactorGraphs.typeModuleName(getVariableType(variable)))\"")
181181
query = """
182182
MATCH (session:$(join(_getLabelsForType(dfg, Session), ":")))
183183
MERGE (node:$(join(_getLabelsForInst(dfg, variable), ":")))
@@ -553,23 +553,23 @@ function getPPE(dfg::CloudGraphsDFG, variablekey::Symbol, ppekey::Symbol=:defaul
553553
return _unpackPPE(dfg, properties)
554554
end
555555

556-
function _generateAdditionalProperties(softType::ST, ppe::P)::Dict{String, String} where {P <: AbstractPointParametricEst, ST <: InferenceVariable}
556+
function _generateAdditionalProperties(variableType::ST, ppe::P)::Dict{String, String} where {P <: AbstractPointParametricEst, ST <: InferenceVariable}
557557
addProps = Dict{String, String}()
558-
# Try get the projectCartesian function for this softType
558+
# Try get the projectCartesian function for this variableType
559559
projectCartesianFunc = nothing
560560
if isdefined(Main, :projectCartesian)
561561
# Try find a signature that matches
562-
if applicable(Main.projectCartesian, softType, Vector{Float64}())
562+
if applicable(Main.projectCartesian, variableType, Vector{Float64}())
563563
projectCartesianFunc = Main.projectCartesian
564564
end
565565
end
566-
if projectCartesianFunc == nothing
567-
@warn "There is no cartesianProjection function for $(typeof(softType)), so no cartesian entries will be added. Please add a projectCartesian function for this softtype."
566+
if projectCartesianFunc === nothing
567+
@warn "There is no cartesianProjection function for $(typeof(variableType)), so no cartesian entries will be added. Please add a projectCartesian function for this variableType."
568568
return addProps
569569
end
570570
for field in DistributedFactorGraphs.getEstimateFields(ppe)
571571
est = getfield(ppe, field)
572-
cart = Main.projectCartesian(softType, est) # Assuming we've imported the variables into Main
572+
cart = Main.projectCartesian(variableType, est) # Assuming we've imported the variables into Main
573573
addProps["$(field)_cart3"] = "point({x:$(cart[1]),y:$(cart[2]),z:$(cart[3])})" # Need to look at 3D too soon.
574574
end
575575
return addProps
@@ -583,9 +583,9 @@ function addPPE!(dfg::CloudGraphsDFG,
583583
if ppe.solveKey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction)
584584
error("PPE '$(ppe.solveKey)' already exists")
585585
end
586-
softType = getSofttype(dfg, variablekey)
586+
variableType = getVariableType(dfg, variablekey)
587587
# Add additional properties for the PPE
588-
addProps = _generateAdditionalProperties(softType, ppe)
588+
addProps = _generateAdditionalProperties(variableType, ppe)
589589
return _unpackPPE(dfg, _matchmergeVariableSubnode!(
590590
dfg,
591591
variablekey,
@@ -606,9 +606,9 @@ function updatePPE!(
606606
if warn_if_absent && !(ppe.solveKey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction))
607607
@warn "PPE '$(ppe.solveKey)' does not exist, adding"
608608
end
609-
softType = getSofttype(dfg, variablekey, currentTransaction=currentTransaction)
609+
variableType = getVariableType(dfg, variablekey, currentTransaction=currentTransaction)
610610
# Add additional properties for the PPE
611-
addProps = _generateAdditionalProperties(softType, ppe)
611+
addProps = _generateAdditionalProperties(variableType, ppe)
612612
return _unpackPPE(dfg, _matchmergeVariableSubnode!(
613613
dfg,
614614
variablekey,
@@ -623,11 +623,11 @@ function updatePPE!(dfg::CloudGraphsDFG, sourceVariables::Vector{<:DFGVariable},
623623
currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing,
624624
warn_if_absent::Bool=true)
625625

626-
tx = currentTransaction == nothing ? transaction(dfg.neo4jInstance.connection) : currentTransaction
626+
tx = currentTransaction === nothing ? transaction(dfg.neo4jInstance.connection) : currentTransaction
627627
for var in sourceVariables
628628
updatePPE!(dfg, var.label, getPPE(var, ppekey), currentTransaction=tx, warn_if_absent=warn_if_absent)
629629
end
630-
if currentTransaction == nothing
630+
if currentTransaction === nothing
631631
result = commit(tx)
632632
end
633633
return nothing

src/CloudGraphsDFG/services/CommonFunctions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ function _structToNeo4jProps(inst::Union{User, Robot, Session, PVND, N, APPE, AB
171171
if fieldname == :nstime
172172
val = field.value
173173
end
174-
if fieldname == :softtype
175-
val = DistributedFactorGraphs.typeModuleName(getSofttype(inst))
174+
if fieldname == :variableType
175+
val = DistributedFactorGraphs.typeModuleName(getVariableType(inst))
176176
end
177177
# Factors
178178
# TODO: Consolidate with packFactor in Serialization.jl - https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/525

src/Deprecated.jl

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,59 @@ export AbstractRelativeFactor, AbstractRelativeFactorMinimize
140140
const AbstractRelativeFactor = AbstractRelativeRoots
141141
const AbstractRelativeFactorMinimize = AbstractRelativeMinimize
142142

143+
##-------------------------------------------------------------------------------
144+
## softtype -> variableType deprecation
145+
##-------------------------------------------------------------------------------
146+
147+
function Base.getproperty(x::VariableNodeData,f::Symbol)
148+
if f == :softtype
149+
Base.depwarn("`VariableNodeData` field `softtype` is deprecated, use `variableType`", :getproperty)
150+
f = :variableType
151+
end
152+
getfield(x,f)
153+
end
154+
155+
function Base.setproperty!(x::VariableNodeData, f::Symbol, val)
156+
if f == :softtype
157+
Base.depwarn("`VariableNodeData` field `softtype` is deprecated, use `variableType`", :getproperty)
158+
f = :variableType
159+
end
160+
return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
161+
end
162+
163+
164+
function Base.getproperty(x::PackedVariableNodeData,f::Symbol)
165+
if f == :softtype
166+
Base.depwarn("`PackedVariableNodeData` field `softtype` is deprecated, use `variableType`", :getproperty)
167+
f = :variableType
168+
end
169+
getfield(x,f)
170+
end
171+
172+
function Base.setproperty!(x::PackedVariableNodeData, f::Symbol, val)
173+
if f == :softtype
174+
Base.depwarn("`PackedVariableNodeData` field `softtype` is deprecated, use `variableType`", :getproperty)
175+
f = :variableType
176+
end
177+
return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
178+
end
179+
180+
181+
function Base.getproperty(x::DFGVariableSummary,f::Symbol)
182+
if f == :softtypename
183+
Base.depwarn("`DFGVariableSummary` field `softtypename` is deprecated, use `variableTypeName`", :getproperty)
184+
f = :variableTypeName
185+
end
186+
getfield(x,f)
187+
end
188+
189+
function Base.setproperty!(x::DFGVariableSummary, f::Symbol, val)
190+
if f == :softtypename
191+
Base.depwarn("`DFGVariableSummary` field `softtypename` is deprecated, use `variableTypeName`", :getproperty)
192+
f = :variableTypeName
193+
end
194+
return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
195+
end
143196

197+
@deprecate getSofttype(args...) getVariableType(args...)
198+
@deprecate getSofttypename(args...) getVariableTypeName(args...)

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ export InferenceVariable
123123

124124
# accessors
125125
export getSolverDataDict, setSolverData!
126-
export getSofttype, getSofttypename
126+
export getVariableType, getVariableTypeName
127127

128128
export getSolverData
129129

130130
export getVariableType
131131

132-
# Softtype functions
132+
# VariableType functions
133133
export getDimension, getManifolds
134134

135135
# Small Data CRUD

src/FileDFG/services/FileDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function saveDFG(folder::AbstractString, dfg::AbstractDFG)
3131
factorFolder = "$savepath/factors"
3232
# Folder preparations
3333
if !isdir(savepath)
34-
@info "Folder '$savepath' doesn't exist, creating..."
34+
@debug "Folder '$savepath' doesn't exist, creating..."
3535
mkpath(savepath)
3636
end
3737
!isdir(varFolder) && mkpath(varFolder)

src/entities/DFGVariable.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mutable struct VariableNodeData{T<:InferenceVariable}
2525
eliminated::Bool
2626
BayesNetVertID::Symbol # Union{Nothing, }
2727
separator::Array{Symbol,1}
28-
softtype::T
28+
variableType::T
2929
initialized::Bool
3030
inferdim::Float64
3131
ismargin::Bool
@@ -43,7 +43,7 @@ mutable struct VariableNodeData{T<:InferenceVariable}
4343
dims::Int,eliminated::Bool,
4444
BayesNetVertID::Symbol,
4545
separator::Array{Symbol,1},
46-
softtype::T,
46+
variableType::T,
4747
initialized::Bool,
4848
inferdim::Float64,
4949
ismargin::Bool,
@@ -54,7 +54,7 @@ mutable struct VariableNodeData{T<:InferenceVariable}
5454
events::Dict{Symbol,Threads.Condition}=Dict{Symbol,Threads.Condition}()) where T <: InferenceVariable =
5555
new{T}(val,bw,BayesNetOutVertIDs,dimIDs,dims,
5656
eliminated,BayesNetVertID,separator,
57-
softtype::T,initialized,inferdim,ismargin,
57+
variableType::T,initialized,inferdim,ismargin,
5858
dontmargin, solveInProgress, solvedCount, solveKey, events)
5959
end
6060

@@ -68,7 +68,7 @@ VariableNodeData(val::Array{Float64,2},
6868
dims::Int,eliminated::Bool,
6969
BayesNetVertID::Symbol,
7070
separator::Array{Symbol,1},
71-
softtype::T,
71+
variableType::T,
7272
initialized::Bool,
7373
inferdim::Float64,
7474
ismargin::Bool,
@@ -79,13 +79,13 @@ VariableNodeData(val::Array{Float64,2},
7979
) where T <: InferenceVariable =
8080
VariableNodeData{T}(val,bw,BayesNetOutVertIDs,dimIDs,dims,
8181
eliminated,BayesNetVertID,separator,
82-
softtype::T,initialized,inferdim,ismargin,
82+
variableType::T,initialized,inferdim,ismargin,
8383
dontmargin, solveInProgress, solvedCount,
8484
solveKey)
8585

8686

87-
VariableNodeData(softtype::T; solveKey::Symbol=:default) where T <: InferenceVariable =
88-
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], softtype, false, 0.0, false, false, 0, 0, solveKey)
87+
VariableNodeData(variableType::T; solveKey::Symbol=:default) where T <: InferenceVariable =
88+
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], variableType, false, 0.0, false, false, 0, 0, solveKey)
8989

9090
##==============================================================================
9191
## PackedVariableNodeData.jl
@@ -110,7 +110,7 @@ mutable struct PackedVariableNodeData
110110
eliminated::Bool
111111
BayesNetVertID::Symbol # Int
112112
separator::Array{Symbol,1} # Int
113-
softtype::String
113+
variableType::String
114114
initialized::Bool
115115
inferdim::Float64
116116
ismargin::Bool
@@ -256,7 +256,7 @@ end
256256
$SIGNATURES
257257
The default DFGVariable constructor.
258258
"""
259-
function DFGVariable(label::Symbol, softtype::T;
259+
function DFGVariable(label::Symbol, variableType::T;
260260
timestamp::Union{DateTime,ZonedDateTime}=now(localzone()),
261261
nstime::Nanosecond = Nanosecond(0),
262262
tags::Set{Symbol}=Set{Symbol}(),
@@ -309,7 +309,7 @@ end
309309
##------------------------------------------------------------------------------
310310
# TODO: can't see the reason to overwrite copy, leaving it here for now
311311
# function Base.copy(o::DFGVariable)::DFGVariable
312-
# return DFGVariable(o.label, getSofttype(o)(), tags=copy(o.tags), estimateDict=copy(o.estimateDict),
312+
# return DFGVariable(o.label, getVariableType(o)(), tags=copy(o.tags), estimateDict=copy(o.estimateDict),
313313
# solverDataDict=copy(o.solverDataDict), smallData=copy(o.smallData),
314314
# dataDict=copy(o.dataDict), solvable=getSolvable(o))
315315
# end
@@ -339,9 +339,9 @@ struct DFGVariableSummary <: AbstractDFGVariable
339339
"""Dictionary of parametric point estimates keyed by solverDataDict keys
340340
Accessors: [`addPPE!`](@ref), [`updatePPE!`](@ref), and [`deletePPE!`](@ref)"""
341341
ppeDict::Dict{Symbol, <:AbstractPointParametricEst}
342-
"""Symbol for the softtype for the underlying variable.
343-
Accessor: [`getSofttype`](@ref)"""
344-
softtypename::Symbol
342+
"""Symbol for the variableType for the underlying variable.
343+
Accessor: [`getVariableType`](@ref)"""
344+
variableTypeName::Symbol
345345
"""Dictionary of large data associated with this variable.
346346
Accessors: [`addDataEntry!`](@ref), [`getDataEntry`](@ref), [`updateDataEntry!`](@ref), and [`deleteDataEntry!`](@ref)"""
347347
dataDict::Dict{Symbol, AbstractDataEntry}
@@ -383,7 +383,7 @@ const VariableDataLevel2 = Union{DFGVariable}
383383
##==============================================================================
384384

385385
DFGVariableSummary(v::DFGVariable) =
386-
DFGVariableSummary(v.label, v.timestamp, deepcopy(v.tags), deepcopy(v.ppeDict), Symbol(typeof(getSofttype(v))), v.dataDict)
386+
DFGVariableSummary(v.label, v.timestamp, deepcopy(v.tags), deepcopy(v.ppeDict), Symbol(typeof(getVariableType(v))), v.dataDict)
387387

388388
SkeletonDFGVariable(v::VariableDataLevel1) =
389389
SkeletonDFGVariable(v.label, deepcopy(v.tags))

src/services/CompareUtils.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function compare(a::VariableNodeData, b::VariableNodeData)
163163
a.ismargin != b.ismargin && @debug("ismargin is not equal")==nothing && return false
164164
a.dontmargin != b.dontmargin && @debug("dontmargin is not equal")==nothing && return false
165165
a.solveInProgress != b.solveInProgress && @debug("solveInProgress is not equal")==nothing && return false
166-
typeof(a.softtype) != typeof(b.softtype) && @debug("softtype is not equal")==nothing && return false
166+
typeof(a.variableType) != typeof(b.variableType) && @debug("variableType is not equal")==nothing && return false
167167
return true
168168
end
169169

@@ -181,19 +181,19 @@ function compareVariable(A::DFGVariable,
181181
skiplist = union([:attributes;:solverDataDict;:createdTimestamp;:lastUpdatedTimestamp],skip)
182182
TP = compareAll(A, B, skip=skiplist, show=show)
183183
varskiplist = skipsamples ? [:val; :bw] : Symbol[]
184-
skiplist = union([:softtype;],varskiplist)
184+
skiplist = union([:variableType;],varskiplist)
185185
union!(skiplist, skip)
186186
TP = TP && compareAll(A.solverDataDict, B.solverDataDict, skip=skiplist, show=show)
187187

188188
Ad = getSolverData(A)
189189
Bd = getSolverData(B)
190190

191-
# TP = TP && compareAll(A.attributes, B.attributes, skip=[:softtype;], show=show)
192-
varskiplist = union(varskiplist, [:softtype])
191+
# TP = TP && compareAll(A.attributes, B.attributes, skip=[:variableType;], show=show)
192+
varskiplist = union(varskiplist, [:variableType])
193193
union!(varskiplist, skip)
194194
TP = TP && compareAll(Ad, Bd, skip=varskiplist, show=show)
195-
TP = TP && typeof(Ad.softtype) == typeof(Bd.softtype)
196-
TP = TP && compareAll(Ad.softtype, Bd.softtype, show=show, skip=skip)
195+
TP = TP && typeof(Ad.variableType) == typeof(Bd.variableType)
196+
TP = TP && compareAll(Ad.variableType, Bd.variableType, show=show, skip=skip)
197197
return TP
198198
end
199199

src/services/CustomPrinting.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function printVariable( io::IO, vert::DFGVariable;
1414
ioc = IOContext(io, :limit=>limit, :compact=>compact)
1515

1616
if short
17-
# opmemt = (getSofttype(vert) |> typeof ).name
18-
vari = getSofttype(vert) |> typeof
17+
# opmemt = (getVariableType(vert) |> typeof ).name
18+
vari = getVariableType(vert) |> typeof
1919
printstyled(ioc, typeof(vert).name, "{",vari.name,"...}","\n", bold=true)
2020
# printstyled(ioc, summary(vert),"\n", bold=true)
2121

0 commit comments

Comments
 (0)