From 2f6f86e3af9569ea342948aeb3e94f2afbedfccb Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 26 Nov 2025 11:21:27 +0200 Subject: [PATCH 1/4] getStateKind and fix tests --- NEWS.md | 4 ++ src/Deprecated.jl | 74 ++++++++++-------------- src/DistributedFactorGraphs.jl | 11 ++-- src/GraphsDFG/GraphsDFG.jl | 2 +- src/GraphsDFG/services/GraphsDFG.jl | 2 +- src/entities/Bloblet.jl | 2 +- src/entities/DFGVariable.jl | 9 ++- src/serialization/PackedSerialization.jl | 10 ++++ src/serialization/StateSerialization.jl | 2 +- src/services/CompareUtils.jl | 46 ++++++++++----- src/services/CustomPrinting.jl | 4 +- src/services/DFGFactor.jl | 8 ++- src/services/DFGVariable.jl | 14 ++--- src/services/list.jl | 4 +- test/fileDFGTests.jl | 12 ++-- test/iifCompareTests.jl | 6 +- test/iifInterfaceTests.jl | 36 ++++++------ test/testBlocks.jl | 10 ++-- 18 files changed, 141 insertions(+), 115 deletions(-) diff --git a/NEWS.md b/NEWS.md index babfdb21..eb123556 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG. + +# v0.29 +- `AbstractPointParametricEst` (`MeanMaxPPE`) and related `PPE` functions are obsolete, see #1133. + # v0.28 - Reading or deserialzing of factor graphs created prior to v0.25 are no longer suppoted with the complete removal of User/Robot/Session - Deprecated AbstractRelativeMinimize and AbstractManifoldsMinimize diff --git a/src/Deprecated.jl b/src/Deprecated.jl index 2d1d2623..b5de0ed9 100644 --- a/src/Deprecated.jl +++ b/src/Deprecated.jl @@ -85,42 +85,9 @@ function isSolveInProgress( return getSolveInProgress(node, solvekey) > 0 end -""" - $(SIGNATURES) -Get a type from the serialization module. -""" -function getTypeFromSerializationModule(_typeString::AbstractString) - @debug "DFG converting type string to Julia type" _typeString - try - # split the type at last `.` - split_st = split(_typeString, r"\.(?!.*\.)") - #if module is specified look for the module in main, otherwise use Main - if length(split_st) == 2 - m = getfield(Main, Symbol(split_st[1])) - else - m = Main - end - noparams = split(split_st[end], r"{") - ret = if 1 < length(noparams) - # fix #671, but does not work with specific module yet - bidx = findfirst(r"{", split_st[end])[1] - error("getTypeFromSerializationModule eval obsolete") - # Core.eval(m, Base.Meta.parse("$(noparams[1])$(split_st[end][bidx:end])")) - else - getfield(m, Symbol(split_st[end])) - end - - return ret - - catch ex - @error "Unable to deserialize type $(_typeString)" - io = IOBuffer() - showerror(io, ex, catch_backtrace()) - err = String(take!(io)) - @error(err) - end - return nothing -end +getTypeFromSerializationModule(::AbstractString) = error( + "getTypeFromSerializationModule is obsolete, use DFG.parseVariableType or IIF.getTypeFromSerializationModule.", +) ## Version checking #NOTE fixed really bad function but kept similar as fallback #TODO upgrade to use pkgversion(m::Module) @@ -137,8 +104,8 @@ end refMetadata(node) = node.metadata -function packDistribution end -function unpackDistribution end +@deprecate packDistribution(d) pack(d) +@deprecate unpackDistribution(d) unpack(d) function setDescription!(args...) return error("setDescription! was removed and may be implemented later.") @@ -158,8 +125,8 @@ function _getDuplicatedEmptyDFG( return newDfg end -#TODO is Type correct -@deprecate getVariableType(args...) getStateType(args...) +#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) @@ -274,7 +241,9 @@ const PackedObservation = AbstractPackedObservation abstract type AbstractPackedBelief end const PackedBelief = AbstractPackedBelief -getAddHistory(dfg::AbstractDFG) = error("getAddHistory is obsolete.") +#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 @@ -342,6 +311,27 @@ function hasTagsNeighbors( return length(filter(x -> x in alltags, tags)) >= (matchAll ? length(tags) : 1) end +#Obsolete PPEs +abstract type AbstractPointParametricEst end +_ppe_obsolete() = error("PPEs are obsolete and will be replaced soon (IIF.calcMeanMaxSuggested can be used in some cases), see #1133.") +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() + ## ================================================================================ ## Deprecated in v0.28 ##================================================================================= @@ -421,7 +411,7 @@ function lsWho(dfg::AbstractDFG, type::Symbol) vars = getVariables(dfg) labels = Symbol[] for v in vars - varType = typeof(getVariableType(v)) |> nameof + varType = typeof(getStateKind(v)) |> nameof varType == type && push!(labels, v.label) end return labels diff --git a/src/DistributedFactorGraphs.jl b/src/DistributedFactorGraphs.jl index 2604fda3..10867e30 100644 --- a/src/DistributedFactorGraphs.jl +++ b/src/DistributedFactorGraphs.jl @@ -109,6 +109,8 @@ export addStates! export mergeStates! export deleteStates! +export hasState + ## list export listVariables export listFactors @@ -345,6 +347,7 @@ export @format_str # exported from FileIO export @defStateType #TODO Should this be exported? public refStates +public getStateKind # list of unstable functions not exported any more # will move to public or deprecate over time @@ -407,13 +410,11 @@ const unstable_functions::Vector{Symbol} = [ :printNode, :plotDFG, :pack, - :packDistribution, # :packVariable, # :packFactor, :packBlob, :packState, :unpack, - :unpackDistribution, :hasTags, # :unpackVariable, # :unpackFactor, @@ -440,13 +441,15 @@ const unstable_functions::Vector{Symbol} = [ # no set on these #deprecated in v0.29 + :packDistribution, + :unpackDistribution, :hasTagsNeighbors, # :updateBlobstore!,## TODO deprecated or obsolete :emptyMetadata!, #TODO maybe deprecate for just deleteMetadata! # :emptyBlobstore!, #TODO maybe deprecate for just deleteBlobstore! :MetadataTypes, #maybe make public after metadata stable :getVariableTypeName, - :getVariableType, + :getStateKind, :setTimestamp, :setMetadata!, # no set, use add merge :setAgentMetadata!, @@ -577,7 +580,7 @@ include("DataBlobs/services/BlobWrappers.jl") #FIXME function getSolvable end -function getVariableType end +function getStateKind end function isInitialized end function listTags end # In Memory Types diff --git a/src/GraphsDFG/GraphsDFG.jl b/src/GraphsDFG/GraphsDFG.jl index 6c9090b1..945e484f 100644 --- a/src/GraphsDFG/GraphsDFG.jl +++ b/src/GraphsDFG/GraphsDFG.jl @@ -17,7 +17,7 @@ using ...DistributedFactorGraphs: NoSolverParams, filterDFG!, getSolvable, - getVariableType, + getStateKind, getAgentLabel, getGraphLabel, isInitialized, diff --git a/src/GraphsDFG/services/GraphsDFG.jl b/src/GraphsDFG/services/GraphsDFG.jl index 6ec44cfd..1922b7b2 100644 --- a/src/GraphsDFG/services/GraphsDFG.jl +++ b/src/GraphsDFG/services/GraphsDFG.jl @@ -187,7 +187,7 @@ function getVariables( filterDFG!(variables, labelFilter, getLabel) filterDFG!(variables, solvableFilter, getSolvable) filterDFG!(variables, tagsFilter, refTags) - filterDFG!(variables, typeFilter, getVariableType) + filterDFG!(variables, typeFilter, getStateKind) return variables end diff --git a/src/entities/Bloblet.jl b/src/entities/Bloblet.jl index 0871b612..0eb9029a 100644 --- a/src/entities/Bloblet.jl +++ b/src/entities/Bloblet.jl @@ -65,7 +65,7 @@ function addBloblet!(node, bloblet::Bloblet) end function addBloblets!(node, bloblets::Vector{Bloblet}) - addBloblet!.(node, bloblets) + foreach(bl -> addBloblet!(node, bl), bloblets) return bloblets end diff --git a/src/entities/DFGVariable.jl b/src/entities/DFGVariable.jl index 95894537..4e018374 100644 --- a/src/entities/DFGVariable.jl +++ b/src/entities/DFGVariable.jl @@ -78,12 +78,12 @@ end function State{T}(; kwargs...) where {T <: StateType} return State{T, getPointType(T), getDimension(T)}(; kwargs...) end -function State(label, variableType::StateType; kwargs...) +function State(label::Symbol, variableType::StateType; kwargs...) return State{typeof(variableType)}(; label, kwargs...) end function State(state::State; kwargs...) - return State{typeof(getVariableType(state))}(; + return State{typeof(getStateKind(state))}(; (key => deepcopy(getproperty(state, key)) for key in fieldnames(State))..., kwargs..., ) @@ -255,7 +255,7 @@ end function VariableDFG(label::Symbol, state::State; kwargs...) return VariableDFG( label, - getStateType(state); + getStateKind(state); states = OrderedDict(state.label => state), kwargs..., ) @@ -299,8 +299,7 @@ $(TYPEDFIELDS) """Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK]. Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)""" tags::Set{Symbol} - """Symbol for the state type for the underlying variable. - Accessor: [`getStateType`](@ref)""" + """Symbol for the state type for the underlying variable.""" statetype::Symbol """Dictionary of large data associated with this variable. Accessors: [`addBlobentry!`](@ref), [`getBlobentry`](@ref), [`mergeBlobentry!`](@ref), and [`deleteBlobentry!`](@ref)""" diff --git a/src/serialization/PackedSerialization.jl b/src/serialization/PackedSerialization.jl index 84b32439..eb33aeb0 100644 --- a/src/serialization/PackedSerialization.jl +++ b/src/serialization/PackedSerialization.jl @@ -67,6 +67,16 @@ function resolvePackedType(obj::JSON.Object) return Packed{getfield(pkg, Symbol(type.name))} end +function resolveType(obj::DFG.JSON.Object) + type = obj.type + pkg = Base.require(Main, Symbol(type.pkg)) + if !isdefined(Main, Symbol(type.pkg)) + throw(SerializationError("Module $(pkg) is available, but not loaded in `Main`.")) + end + return getfield(pkg, Symbol(type.name)) +end + + @choosetype Packed resolvePackedType # Stash optional TypeMetadata expansion function. diff --git a/src/serialization/StateSerialization.jl b/src/serialization/StateSerialization.jl index 0bef9047..3da9ff42 100644 --- a/src/serialization/StateSerialization.jl +++ b/src/serialization/StateSerialization.jl @@ -99,7 +99,7 @@ function packState(state::State{T}) where {T <: StateType} vecbw = state.bw[:], dimbw = size(state.bw, 1), separator = state.separator, - statetype = stringVariableType(getStateType(state)), + statetype = stringVariableType(getStateKind(state)), initialized = state.initialized, observability = state.observability, marginalized = state.marginalized, diff --git a/src/services/CompareUtils.jl b/src/services/CompareUtils.jl index 3c82532c..69bafe54 100644 --- a/src/services/CompareUtils.jl +++ b/src/services/CompareUtils.jl @@ -21,25 +21,42 @@ implement compare if needed. const GeneratedCompareUnion = Union{ State, Blobentry, - VariableCompute, - VariableDFG, + Bloblet, VariableSummary, VariableSkeleton, - FactorDFG, FactorSummary, FactorSkeleton, FactorState, } @generated function ==(x::T, y::T) where {T <: GeneratedCompareUnion} - ignored = [:solvercache, :solverData, :solvable] #FIXME solvable stopped working- skipping for now (removed getproperty overload) return mapreduce( n -> :(x.$n == y.$n), (a, b) -> :($a && $b), - setdiff(fieldnames(x), ignored), + fieldnames(x), ) end +function ==(x::FactorDFG, y::FactorDFG) + ignored = [:solvercache, :solvable] + tp = mapreduce( + n -> getproperty(x, n) == getproperty(y, n), + (a, b) -> a && b, + setdiff(propertynames(x), ignored), + ) + return tp && getSolvable(x) == getSolvable(y) +end + +function ==(x::VariableDFG, y::VariableDFG) + ignored = [:solvable] + tp = mapreduce( + n -> getproperty(x, n) == getproperty(y, n), + (a, b) -> a && b, + setdiff(propertynames(x), ignored), + ) + return tp && getSolvable(x) == getSolvable(y) +end + ##============================================================================== ## Compare ##============================================================================== @@ -76,7 +93,7 @@ function compareFields( for field in fieldnames(T1) (field in skip) && continue tp = compareField(Al, Bl, field) - show && @debug(" $tp : $field") === nothing + show && !tp && @debug(" $tp : $field") show && !tp && (@debug " $field" a = getproperty(Al, field) b = getproperty(Bl, field)) @@ -220,7 +237,7 @@ function compare(a::State, b::State) # a.dontmargin != b.dontmargin && # @debug("dontmargin is not equal") === nothing && # return false - getVariableType(a) != getVariableType(b) && + getStateKind(a) != getStateKind(b) && @debug("variableType is not equal") === nothing && return false return true @@ -241,12 +258,11 @@ function compareVariable( # skiplist = union( [ - :attributes; :states; - :createdTimestamp; - :lastUpdatedTimestamp; - :timezone; - :zone + :atzone; + :inzone; + :blobentries; + :bloblets ], skip, ) @@ -254,7 +270,7 @@ function compareVariable( varskiplist = skipsamples ? [:val; :bw] : Symbol[] skiplist = union([:variableType;], varskiplist) union!(skiplist, skip) - TP = TP && compareAll(A.states, B.states; skip = skiplist, show = show) + # TP = TP && compareAll(A.states, B.states; skip = skiplist, show = show) Ad = getState(A, :default) #FIXME why onlly comparing default? Bd = getState(B, :default) @@ -263,9 +279,9 @@ function compareVariable( varskiplist = union(varskiplist, [:variableType]) union!(varskiplist, skip) TP = TP && compareAll(Ad, Bd; skip = varskiplist, show = show) - TP = TP && typeof(getVariableType(Ad)) == typeof(getVariableType(Bd)) + TP = TP && typeof(getStateKind(Ad)) == typeof(getStateKind(Bd)) TP = - TP && compareAll(getVariableType(Ad), getVariableType(Bd); show = show, skip = skip) + TP && compareAll(getStateKind(Ad), getStateKind(Bd); show = show, skip = skip) return TP::Bool end diff --git a/src/services/CustomPrinting.jl b/src/services/CustomPrinting.jl index 195730b1..f18d195f 100644 --- a/src/services/CustomPrinting.jl +++ b/src/services/CustomPrinting.jl @@ -16,8 +16,8 @@ function printVariable( ioc = IOContext(io, :limit => limit, :compact => compact) if short - # opmemt = (getVariableType(vert) |> typeof ).name - vari = getStateType(vert) |> typeof + # opmemt = (getStateKind(vert) |> typeof ).name + vari = getStateKind(vert) |> typeof printstyled(ioc, nameof((typeof(vert))), "{"; bold = true) printstyled(ioc, vari; bold = true, color = :blue) printstyled(ioc, "...}"; bold = true) diff --git a/src/services/DFGFactor.jl b/src/services/DFGFactor.jl index 27b97c6d..360ea79c 100644 --- a/src/services/DFGFactor.jl +++ b/src/services/DFGFactor.jl @@ -88,7 +88,7 @@ macro defObservationType(structname, factortype, manifold) return esc( quote # user manifold must be a <:Manifold - @assert ($manifold isa AbstractManifold) "@defObservationType manifold (" * + @assert ($manifold isa AbstractManifold) || ($manifold isa Function) "@defObservationType manifold (" * string($manifold) * ") is not an `AbstractManifold`" @@ -100,7 +100,11 @@ macro defObservationType(structname, factortype, manifold) Z::T & (lower = DFG.Packed, choosetype = DFG.resolvePackedType) end - DFG.getManifold(::Type{<:$structname}) = $manifold + if $manifold isa AbstractManifold + DFG.getManifold(::Type{<:$structname}) = $manifold + elseif $manifold isa Function + DFG.getManifold(obs::$structname) = $manifold(obs) + end end, ) end diff --git a/src/services/DFGVariable.jl b/src/services/DFGVariable.jl index 9bf0862a..c1d21acc 100644 --- a/src/services/DFGVariable.jl +++ b/src/services/DFGVariable.jl @@ -12,13 +12,13 @@ """ $(SIGNATURES) -Get the type of the variable's state, eg. `Pose2`, `Point3`, etc. as an instance of `StateType`. +Get the kind of the variable's state, eg. `Pose2`, `Point3`, etc. as an instance of `StateType`. """ -getStateType(::VariableCompute{T}) where {T} = T() +getStateKind(::VariableCompute{T}) where {T} = T() -getStateType(::State{T}) where {T} = T() +getStateKind(::State{T}) where {T} = T() -getStateType(dfg::AbstractDFG, lbl::Symbol) = getStateType(getVariable(dfg, lbl)) +getStateKind(dfg::AbstractDFG, lbl::Symbol) = getStateKind(getVariable(dfg, lbl)) ##------------------------------------------------------------------------------ ## StateType @@ -116,8 +116,8 @@ end Interface function to return the `<:ManifoldsBase.AbstractManifold` object of `variableType<:StateType`. """ getManifold(::T) where {T <: StateType} = getManifold(T) -getManifold(vari::VariableCompute) = getStateType(vari) |> getManifold -getManifold(state::State) = getStateType(state) |> getManifold +getManifold(vari::VariableCompute) = getStateKind(vari) |> getManifold +getManifold(state::State) = getStateKind(state) |> getManifold # covers both <:StateType and <:AbstractObservation getManifold(dfg::AbstractDFG, lbl::Symbol) = getManifold(dfg[lbl]) @@ -131,7 +131,7 @@ getDimension(::Type{T}) where {T <: StateType} = manifold_dimension(getManifold( getDimension(::T) where {T <: StateType} = manifold_dimension(getManifold(T)) getDimension(M::ManifoldsBase.AbstractManifold) = manifold_dimension(M) getDimension(p::Distributions.Distribution) = length(p) -getDimension(var::VariableCompute) = getDimension(getVariableType(var)) +getDimension(var::VariableCompute) = getDimension(getStateKind(var)) """ $SIGNATURES diff --git a/src/services/list.jl b/src/services/list.jl index e2e37e45..21d3739f 100644 --- a/src/services/list.jl +++ b/src/services/list.jl @@ -180,7 +180,7 @@ function lsTypes(dfg::AbstractDFG) vars = getVariables(dfg) alltypes = Set{DataType}() for v in vars - varType = typeof(getVariableType(v)) + varType = typeof(getStateKind(v)) push!(alltypes, varType) end return collect(alltypes) @@ -195,7 +195,7 @@ function lsTypesDict(dfg::AbstractDFG) vars = getVariables(dfg) alltypes = Dict{DataType, Vector{Symbol}}() for v in vars - varType = typeof(getVariableType(v)) + varType = typeof(getStateKind(v)) d = get!(alltypes, varType, Symbol[]) push!(d, v.label) end diff --git a/test/fileDFGTests.jl b/test/fileDFGTests.jl index f7735ab6..b1af165e 100644 --- a/test/fileDFGTests.jl +++ b/test/fileDFGTests.jl @@ -85,12 +85,12 @@ using UUIDs ) addGraphBlobentry!(dfg, be) - #TODO addAgentBlobentry!(dfg, be) - smallRobotData = Dict{Symbol, MetadataTypes}(:a => "43", :b => "small_robot") - smallSessionData = Dict{Symbol, MetadataTypes}(:a => "44", :b => "small_session") - # setAgentMetadata!(dfg, smallRobotData) #FIXME change to Bloblets - # setGraphMetadata!(dfg, smallSessionData) #FIXME change to Bloblets + agentBloblets = [Bloblet(:a, "43"), Bloblet(:b, "small_robot")] + graphBloblets = [Bloblet(:a, "44"), Bloblet(:b, "small_session")] + + DFG.addAgentBloblets!(dfg, agentBloblets) + DFG.addGraphBloblets!(dfg, graphBloblets) # Save and load the graph to test. saveDFG(filename, dfg) @@ -113,7 +113,7 @@ using UUIDs @test compareFactor( getFactor(dfg, fact), getFactor(retDFG, fact), - skip = [:timezone, :zone, :solverData], + skip = [:timezone, :inzone, :atzone], ) # Timezones # :hypotheses, :certainhypo, :multihypo, # Multihypo # :eliminated, diff --git a/test/iifCompareTests.jl b/test/iifCompareTests.jl index 0cdb5cff..9eda5c8f 100644 --- a/test/iifCompareTests.jl +++ b/test/iifCompareTests.jl @@ -55,7 +55,7 @@ using Test fg, fg2, skipsamples = true, - skip = Symbol[:infoPerCoord; :initialized; :inferdim; :solvedCount], + skip = Symbol[:observability; :initialized; :solves], ) # fg2 has been solved, so it should fail on the estimate dictionary @test !compareSimilarVariables( @@ -84,10 +84,10 @@ using Test skipcompute = true, skip = [ :fullvariables - :infoPerCoord + :observability :initialized :inferdim - :solvedCount + :solves ], ) end diff --git a/test/iifInterfaceTests.jl b/test/iifInterfaceTests.jl index c6aabee7..90fc5565 100644 --- a/test/iifInterfaceTests.jl +++ b/test/iifInterfaceTests.jl @@ -1,5 +1,5 @@ global dfg, v1, v2, f1 - +# dfg = GraphsDFG(; solverParams = SolverParams()) # Building simple graph... @testset "Building a simple Graph" begin global dfg, v1, v2, f1 @@ -145,8 +145,8 @@ end @test ls(dfg, LinearRelative) == [:abf1] @test lsf(dfg, LinearRelative{1, Normal{Float64}}) == [:abf1] - @test getVariableType(v1) isa Position{1} - @test getVariableType(dfg, :a) isa Position{1} + @test getStateKind(v1) isa Position{1} + @test getStateKind(dfg, :a) isa Position{1} @test DFG.lsTypes(dfg) == [Position{1}] @@ -179,9 +179,9 @@ end @test getState(v1, :default) === v1.states[:default] @test refStates(v1) == v1.states - @test typeof(getVariableType(v1)) == Position{1} - @test typeof(getVariableType(v2)) == Position{1} - @test typeof(getVariableType(v1)) == Position{1} + @test typeof(getStateKind(v1)) == Position{1} + @test typeof(getStateKind(v2)) == Position{1} + @test typeof(getStateKind(v1)) == Position{1} @test getLabel(f1) == f1.label @test getTags(f1) == f1.tags @@ -216,41 +216,41 @@ end blobid = uuid4(), label = :key2, blobstore = :test, - mimetype = "image/jpg", + mimetype = MIME("image/jpg"), ) #add v1 = getVariable(dfg, :a) @test addBlobentry!(v1, de1) == de1 - @test addBlobentry!(dfg, :a, de2) == de2 + @test addVariableBlobentry!(dfg, :a, de2) == de2 @test_throws LabelExistsError addBlobentry!(v1, de1) @test de2 in getBlobentries(v1) #get @test deepcopy(de1) == getBlobentry(v1, :key1) - @test deepcopy(de2) == getBlobentry(dfg, :a, :key2) + @test deepcopy(de2) == getVariableBlobentry(dfg, :a, :key2) @test_throws LabelNotFoundError getBlobentry(v2, :key1) - @test_throws LabelNotFoundError getBlobentry(dfg, :b, :key1) + @test_throws LabelNotFoundError getVariableBlobentry(dfg, :b, :key1) #update - @test mergeBlobentry!(dfg, :a, de2_update) == 1 - @test deepcopy(de2_update) == getBlobentry(dfg, :a, :key2) - @test mergeBlobentry!(dfg, :b, de2_update) == 1 + @test mergeVariableBlobentry!(dfg, :a, de2_update) == 1 + @test deepcopy(de2_update) == getVariableBlobentry(dfg, :a, :key2) + @test mergeVariableBlobentry!(dfg, :b, de2_update) == 1 #list - entries = getBlobentries(dfg, :a) + entries = getVariableBlobentries(dfg, :a) @test length(entries) == 2 @test issetequal(map(e -> e.label, entries), [:key1, :key2]) - @test length(getBlobentries(dfg, :b)) == 1 + @test length(getVariableBlobentries(dfg, :b)) == 1 - @test issetequal(listBlobentries(dfg, :a), [:key1, :key2]) - @test listBlobentries(dfg, :b) == Symbol[:key2] + @test issetequal(listVariableBlobentries(dfg, :a), [:key1, :key2]) + @test listVariableBlobentries(dfg, :b) == Symbol[:key2] #delete @test deleteBlobentry!(v1, :key1) == 1 @test listBlobentries(v1) == Symbol[:key2] #delete from ddfg - @test deleteBlobentry!(dfg, :a, :key2) == 1 + @test deleteVariableBlobentry!(dfg, :a, :key2) == 1 @test listBlobentries(v1) == Symbol[] end diff --git a/test/testBlocks.jl b/test/testBlocks.jl index 9f0ed9b8..251c1e94 100644 --- a/test/testBlocks.jl +++ b/test/testBlocks.jl @@ -297,7 +297,7 @@ function DFGVariableSCA() # @test getMetadata(v1) == Dict{Symbol, MetadataTypes}() - @test getVariableType(v1) == TestVariableType1() + @test getStateKind(v1) == TestVariableType1() #TODO here for now, don't reccomend usage. testTags = [:tag1, :tag2] @@ -979,11 +979,11 @@ function testGroup!(fg, v1, v2, f0, f1) @test ls(fg, TestFunctorInferenceType1) == [:abf1] @test lsf(fg, TestAbstractPrior) == [:af1] - @test getVariableType(v1) == TestVariableType1() - @test getVariableType(fg, :a) == TestVariableType1() + @test getStateKind(v1) == TestVariableType1() + @test getStateKind(fg, :a) == TestVariableType1() - @test getVariableType(v1) == TestVariableType1() - @test getVariableType(fg, :a) == TestVariableType1() + @test getStateKind(v1) == TestVariableType1() + @test getStateKind(fg, :a) == TestVariableType1() @test ls2(fg, :a) == [:b] From 6a8cf82d4e9341d848803b8192a8d334278abdef Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 26 Nov 2025 11:28:28 +0200 Subject: [PATCH 2/4] fix formatting --- src/Deprecated.jl | 14 ++++++++++---- src/serialization/PackedSerialization.jl | 1 - src/services/CompareUtils.jl | 13 ++++--------- src/services/DFGFactor.jl | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Deprecated.jl b/src/Deprecated.jl index b5de0ed9..d8d59c3d 100644 --- a/src/Deprecated.jl +++ b/src/Deprecated.jl @@ -85,9 +85,11 @@ function isSolveInProgress( return getSolveInProgress(node, solvekey) > 0 end -getTypeFromSerializationModule(::AbstractString) = error( - "getTypeFromSerializationModule is obsolete, use DFG.parseVariableType or IIF.getTypeFromSerializationModule.", -) +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) @@ -313,7 +315,11 @@ end #Obsolete PPEs abstract type AbstractPointParametricEst end -_ppe_obsolete() = error("PPEs are obsolete and will be replaced soon (IIF.calcMeanMaxSuggested can be used in some cases), see #1133.") +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() diff --git a/src/serialization/PackedSerialization.jl b/src/serialization/PackedSerialization.jl index eb33aeb0..8bbbebcc 100644 --- a/src/serialization/PackedSerialization.jl +++ b/src/serialization/PackedSerialization.jl @@ -76,7 +76,6 @@ function resolveType(obj::DFG.JSON.Object) return getfield(pkg, Symbol(type.name)) end - @choosetype Packed resolvePackedType # Stash optional TypeMetadata expansion function. diff --git a/src/services/CompareUtils.jl b/src/services/CompareUtils.jl index 69bafe54..46dded34 100644 --- a/src/services/CompareUtils.jl +++ b/src/services/CompareUtils.jl @@ -30,11 +30,7 @@ const GeneratedCompareUnion = Union{ } @generated function ==(x::T, y::T) where {T <: GeneratedCompareUnion} - return mapreduce( - n -> :(x.$n == y.$n), - (a, b) -> :($a && $b), - fieldnames(x), - ) + return mapreduce(n -> :(x.$n == y.$n), (a, b) -> :($a && $b), fieldnames(x)) end function ==(x::FactorDFG, y::FactorDFG) @@ -42,7 +38,7 @@ function ==(x::FactorDFG, y::FactorDFG) tp = mapreduce( n -> getproperty(x, n) == getproperty(y, n), (a, b) -> a && b, - setdiff(propertynames(x), ignored), + setdiff(propertynames(x), ignored), ) return tp && getSolvable(x) == getSolvable(y) end @@ -52,7 +48,7 @@ function ==(x::VariableDFG, y::VariableDFG) tp = mapreduce( n -> getproperty(x, n) == getproperty(y, n), (a, b) -> a && b, - setdiff(propertynames(x), ignored), + setdiff(propertynames(x), ignored), ) return tp && getSolvable(x) == getSolvable(y) end @@ -280,8 +276,7 @@ function compareVariable( union!(varskiplist, skip) TP = TP && compareAll(Ad, Bd; skip = varskiplist, show = show) TP = TP && typeof(getStateKind(Ad)) == typeof(getStateKind(Bd)) - TP = - TP && compareAll(getStateKind(Ad), getStateKind(Bd); show = show, skip = skip) + TP = TP && compareAll(getStateKind(Ad), getStateKind(Bd); show = show, skip = skip) return TP::Bool end diff --git a/src/services/DFGFactor.jl b/src/services/DFGFactor.jl index 360ea79c..67d6c2cc 100644 --- a/src/services/DFGFactor.jl +++ b/src/services/DFGFactor.jl @@ -88,9 +88,9 @@ macro defObservationType(structname, factortype, manifold) return esc( quote # user manifold must be a <:Manifold - @assert ($manifold isa AbstractManifold) || ($manifold isa Function) "@defObservationType manifold (" * - string($manifold) * - ") is not an `AbstractManifold`" + manifoldCheck = ($manifold isa AbstractManifold) || ($manifold isa Function) + @assert manifoldCheck string($manifold) * + " must be an `AbstractManifold` or a `Function` returning one." @assert ($factortype <: AbstractObservation) "@defObservationType factortype (" * string($factortype) * From b738d0ac2fcb389aaab3a29a46f5a655ba1b3d94 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 26 Nov 2025 11:56:44 +0200 Subject: [PATCH 3/4] test no longer broken --- test/compareTests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/compareTests.jl b/test/compareTests.jl index fe3419be..49f59766 100644 --- a/test/compareTests.jl +++ b/test/compareTests.jl @@ -27,7 +27,7 @@ v3 = VariableCompute(:x2, TestVariableType2()) @test v1 == v2 setSolvable!(v2, 0) -@test_broken !(v1 == v2) +@test !(v1 == v2) @test !(v1 == v3) @test !( VariableCompute(:x1, TestVariableType1()) == VariableCompute(:x1, TestVariableType2()) From 00a3424284c7d3854f35c841814dd0244ff5f119 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 26 Nov 2025 12:24:36 +0200 Subject: [PATCH 4/4] test IIF again --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c8f4971..61dc0336 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Run tests env: - IIF_TEST: false #FIXME skipping until IIF stable again + IIF_TEST: true uses: julia-actions/julia-runtest@latest - name: Process Coverage uses: julia-actions/julia-processcoverage@v1