Skip to content

Commit 93d4df8

Browse files
committed
fix some tests
1 parent 45d075a commit 93d4df8

File tree

11 files changed

+62
-116
lines changed

11 files changed

+62
-116
lines changed

src/DataBlobs/entities/BlobEntry.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ StructUtils.@kwarg struct Blobentry
5050
end
5151
version(::Type{Blobentry}) = v"0.1.0"
5252

53-
function Blobentry(label::Symbol, blobstore = :default; metadata, kwargs...)
53+
function Blobentry(
54+
label::Symbol,
55+
blobstore = :default;
56+
metadata = JSONText("{}"),
57+
kwargs...,
58+
)
5459
if !(metadata isa JSONText)
5560
metadata = JSONText(JSON.json(metadata))
5661
end

src/DistributedFactorGraphs.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ export @defStateType #TODO Should this be exported?
331331
# list of unstable functions not exported any more
332332
# will move to public or deprecate over time
333333
const unstable_functions::Vector{Symbol} = [
334+
:refStates, #internal maybe make public
334335
:InMemoryBlobstore,
335336
:MetadataTypes, #maybe make public after metadata stable
336337
:getFactorState, # FIXME getFactorState were questioned and being reviewed again for name, other than that they are checked.
@@ -396,7 +397,7 @@ const unstable_functions::Vector{Symbol} = [
396397
:plotDFG,
397398
:pack,
398399
:packDistribution,
399-
:packVariable,
400+
# :packVariable,
400401
# :packFactor,
401402
:packBlob,
402403
:packState,
@@ -468,7 +469,7 @@ const unstable_functions::Vector{Symbol} = [
468469
:DFGFactor,
469470
:PackedFactor,
470471
:Factor,
471-
:AbstractPointParametricEst,
472+
# :AbstractPointParametricEst,
472473
# :MeanMaxPPE,
473474
# :getPPEMax,
474475
# :getPPEMean,

src/entities/DFGFactor.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,16 @@ function FactorDFG(
188188
solvercache = Ref(cache)
189189
end
190190

191-
# deprecated in v0.29
191+
# TODO v0.29 deprecate ZonedDateTime or convert internally
192192
if timestamp isa ZonedDateTime
193-
Base.depwarn(
194-
"`FactorDFG` timestamp as `ZonedDateTime` is deprecated, use `TimeDateZone(timestamp.utc_datetime)` instead",
195-
:FactorDFG,
196-
)
197-
nd_timestamp = TimeDateZone(timestamp.utc_datetime)
198-
else
199-
nd_timestamp = timestamp
193+
timestamp = TimeDateZone(timestamp)
200194
end
201195

202196
return FactorDFG(
203197
label,
204198
tags,
205199
Tuple(variableorder),
206-
nd_timestamp,
200+
timestamp,
207201
Ref(solvable),
208202
bloblets,
209203
observation,

src/entities/DFGVariable.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ $(TYPEDFIELDS)
5454
"""
5555
observability::Vector{Float64} = Float64[]#zeros(getDimension(T)) #TODO renamed from infoPerCoord
5656
"""
57-
Should this variable solveKey be treated as marginalized in inference computations.
57+
Should this state be treated as marginalized in inference computations.
5858
"""
5959
marginalized::Bool = false #TODO renamed from ismargin
6060
# """
6161
# Should this variable solveKey always be kept fluid and not be automatically marginalized.
6262
# """
6363
# dontmargin::Bool = false
6464
"""
65-
How many times has a solver updated this variable solveKey estimte.
65+
How many times has a solver updated this state estimate.
6666
"""
6767
solves::Int = 0 # TODO renamed from solvedCount
6868
# """
@@ -242,6 +242,9 @@ function VariableDFG(
242242
Base.depwarn("smalldata kwarg is deprecated, use bloblets instead", :VariableDFG)
243243
#TODO convert smalldata to bloblets
244244
end
245+
if solvable isa Int
246+
solvable = Ref(solvable)
247+
end
245248
union!(tags, [:VARIABLE])
246249

247250
N = getDimension(T)
@@ -250,7 +253,12 @@ function VariableDFG(
250253
end
251254

252255
function VariableDFG(label::Symbol, state::State; kwargs...)
253-
return VariableCompute(; label, states = OrderedDict(state.label => state), kwargs...)
256+
return VariableDFG(
257+
label,
258+
getStateType(state);
259+
states = OrderedDict(state.label => state),
260+
kwargs...,
261+
)
254262
end
255263

256264
# Base.getproperty(x::VariableCompute, f::Symbol) = begin

src/services/AbstractDFG.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ end
756756
Find and return the closest timestamp from two sets of Tuples. Also return the minimum delta-time (`::Millisecond`) and how many elements match from the two sets are separated by the minimum delta-time.
757757
"""
758758
function findClosestTimestamp(
759-
setA::Vector{Tuple{ZonedDateTime, T}},
760-
setB::Vector{Tuple{ZonedDateTime, S}},
759+
setA::Vector{Tuple{TimeDateZone, T}},
760+
setB::Vector{Tuple{TimeDateZone, S}},
761761
) where {S, T}
762762
#
763763
# build matrix of delta times, ranges on rows x vars on columns
@@ -798,7 +798,7 @@ ls, listVariables, findClosestTimestamp
798798
"""
799799
function findVariableNearTimestamp(
800800
dfg::AbstractDFG,
801-
timest::ZonedDateTime,
801+
timest::TimeDateZone,#ZonedDateTime,
802802
regexFilter::Union{Nothing, Regex} = nothing;
803803
tags::Vector{Symbol} = Symbol[],
804804
solvable::Int = 0,
@@ -848,7 +848,7 @@ function findVariableNearTimestamp(
848848
)
849849
return findVariableNearTimestamp(
850850
dfg,
851-
ZonedDateTime(timest, timezone),
851+
TimeDateZone(timest, timezone),
852852
regexFilter;
853853
kwargs...,
854854
)

src/services/CompareUtils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function compareVariable(
241241
skiplist = union(
242242
[
243243
:attributes;
244-
:solverDataDict;
244+
:states;
245245
:createdTimestamp;
246246
:lastUpdatedTimestamp;
247247
:timezone;

src/services/CustomPrinting.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function printVariable(
7474
printstyled(ioc, summary(vert); bold = true, color = :blue)
7575
println(ioc, "")
7676

77-
:solver in skipfields && push!(skipfields, :solverDataDict)
77+
:solver in skipfields && push!(skipfields, :states)
7878

7979
t = typeof(vert)
8080
fields = setdiff(fieldnames(t), skipfields)

src/services/DFGVariable.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -578,16 +578,10 @@ function copytoState!(
578578
stateLabel::Symbol,
579579
state::State,
580580
)
581-
newstate = State(
582-
getVariableType(state);
583-
(k => deepcopy(getproperty(state, k)) for k in fieldnames(State))...,
584-
solveKey = stateLabel,
585-
)
581+
newstate = State(state; label = stateLabel)
586582
return mergeState!(dfg, variableLabel, newstate)
587583
end
588584

589-
#
590-
591585
"""
592586
$(SIGNATURES)
593587
Delete the variable `State` by label, returns the number of deleted elements.

src/services/Serialization.jl

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -178,61 +178,3 @@ function unpackState(d)
178178
solves = d.solves,
179179
)
180180
end
181-
182-
##==============================================================================
183-
## Variable Packing and unpacking
184-
##==============================================================================
185-
186-
function packVariable(
187-
v::VariableCompute;
188-
includeSolveData::Bool = true,
189-
includeDataEntries::Bool = true,
190-
)
191-
return (
192-
id = v.id,
193-
label = v.label,
194-
timestamp = v.timestamp,
195-
nstime = string(v.nstime.value),
196-
tags = collect(v.tags), # Symbol.()
197-
solverData = packState.(collect(values(v.states))),
198-
metadata = base64encode(JSON.json(v.smallData)),
199-
solvable = getSolvable(v),
200-
variableType = stringVariableType(DFG.getVariableType(v)),
201-
blobEntries = collect(values(v.blobentries)),
202-
_version = _getDFGVersion(),
203-
)
204-
end
205-
206-
function unpackVariable(variable; skipVersionCheck::Bool = false)
207-
!skipVersionCheck && _versionCheck(variable)
208-
209-
# Variable and point type
210-
variableType = parseVariableType(variable.variableType)
211-
isnothing(variableType) && error(
212-
"Cannot deserialize variableType '$(variable.variableType)' in variable '$(variable.label)'",
213-
)
214-
pointType = DFG.getPointType(variableType)
215-
216-
N = getDimension(variableType)
217-
solverDict = Dict{Symbol, State{variableType, pointType, N}}(
218-
map(sd -> sd.label, variable.solverData) .=>
219-
map(sd -> DFG.unpackState(sd), variable.solverData),
220-
)
221-
dataDict = Dict{Symbol, Blobentry}(
222-
map(de -> de.label, variable.blobEntries) .=> variable.blobEntries,
223-
)
224-
metadata = JSON.parse(base64decode(variable.metadata), Dict{Symbol, DFG.MetadataTypes})
225-
226-
return VariableCompute(
227-
variable.label,
228-
variableType;
229-
id = variable.id,
230-
timestamp = variable.timestamp,
231-
nstime = Nanosecond(variable.nstime),
232-
tags = Set(variable.tags),
233-
solverDataDict = solverDict,
234-
smallData = metadata,
235-
dataDict = dataDict,
236-
solvable = variable.solvable,
237-
)
238-
end

test/interfaceTests.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ if false
2222
global_logger(logger)
2323
end
2424

25+
# DFG.@usingDFG true
26+
# include("testBlocks.jl")
27+
2528
# DFG Accessors
2629
@testset "DFG Structure and Accessors" begin
2730
# Constructors
@@ -64,13 +67,13 @@ end
6467
@test printVariable(iobuf, var1; skipfields = [:timestamp, :solver, :ppe, :nstime]) ===
6568
nothing
6669

67-
@test String(take!(iobuf)) ==
68-
"VariableCompute{TestVariableType1, Vector{Float64}, 1}\nid:\nnothing\nlabel:\n:a\ntags:\nSet([:VARIABLE, :POSE])\nsmallData:\nDict{Symbol, Union{Bool, Float64, Int64, Vector{Bool}, Vector{Float64}, Vector{Int64}, Vector{String}, String}}()\ndataDict:\nDict{Symbol, Blobentry}()\nsolvable:\nRefValue{Int64}(0)\n"
69-
# "VariableCompute{TestVariableType1, Vector{Float64}, 1}\nid:\nnothing\nlabel:\n:a\ntags:\nSet([:VARIABLE, :POSE])\nsmallData:\nDict{Symbol, Union{Bool, Float64, Int64, Vector{Bool}, Vector{Float64}, Vector{Int64}, Vector{String}, String}}(:small=>\"data\")\ndataDict:\nDict{Symbol, Blobentry}()\nsolvable:\n0\n"
70+
varstr = String(take!(iobuf))
71+
@test occursin(r"VariableDFG", varstr)
72+
@test occursin(r"label", varstr)
7073

7174
@test printVariable(iobuf, var1; short = true) === nothing
7275
varstr = String(take!(iobuf))
73-
@test occursin(r"VariableCompute", varstr)
76+
@test occursin(r"VariableDFG", varstr)
7477
@test occursin(r"timestamp", varstr)
7578
@test occursin(r"label", varstr)
7679
@test occursin(r"bandwidths", varstr)

0 commit comments

Comments
 (0)