JuliaRobotics / IncrementalInference.jl

@@ -86,12 +86,21 @@
Loading
86 86
end
87 87
88 88
89 +
# FIXME DEPRECATE TO BETTER JSON with ._type field STANDARD
89 90
function convert(::Type{<:PackedSamplableBelief}, obj::SamplableBelief)
90 91
  # FIXME must use string, because unpacking templated e.g. PackedType{T} has problems, see DFG #668
91 92
  string(obj)
92 93
end
93 94
94 95
96 +
# New features towards standardizing distribution serialization
97 +
# # Assumes DFG/IIF serialized distributions have a `PackedType._type::String = "MyModule.MyPackedDistributionDensityType"`
98 +
# # also see DFG #590
99 +
# function convert( ::Type{String}, 
100 +
#                   obj::PackedSamplableBelief )
101 +
#   #
102 +
#   _typ = DFG.getTypeFromSerializationModule(obj._type)
103 +
# end
95 104
96 105
97 106
## DEPRECATE BELOW ========================================================================
@@ -143,61 +152,79 @@
Loading
143 152
## ===========================================================================================
144 153
145 154
146 -
mutable struct PackedHeatmapDensityRegular <: PackedSamplableBelief
155 +
mutable struct PackedHeatmapGridDensity <: PackedSamplableBelief
156 +
  _type::String
147 157
  data::Vector{Vector{Float64}}
148 158
  domain::Tuple{Vector{Float64}, Vector{Float64}}
149 159
  hint_callback::String
150 -
  level::Float64
151 -
  sigma::Float64
152 -
  sigma_scale::Float64
153 160
  bw_factor::Float64
154 161
  densityFnc::String
155 162
end
156 163
157 164
158 -
function convert( ::Union{Type{<:SamplableBelief},Type{<:HeatmapDensityRegular}}, 
159 -
                  obj::PackedHeatmapDensityRegular)
165 +
function convert( ::Union{Type{<:SamplableBelief},Type{<:HeatmapGridDensity}}, 
166 +
                  obj::PackedHeatmapGridDensity)
160 167
  #
161 168
162 169
  # do intermediate conversions
163 170
  data_ = obj.data
164 171
  data__ = map(x->collect(x), data_)
165 172
  @cast data[i,j] := data__[j][i]
166 -
  data__ = collect(data)
173 +
  _data__ = collect(data)
167 174
  densFnc = convert(SamplableBelief, obj.densityFnc)
168 -
  # build the final object
169 -
  HeatmapDensityRegular(data__,
170 -
                        obj.domain,
171 -
                        obj.hint_callback == "" ? nothing : nothing,
172 -
                        obj.level,
173 -
                        obj.sigma,
174 -
                        obj.sigma_scale,
175 -
                        obj.bw_factor,
176 -
                        densFnc )
175 +
  # build the final object, misses the hint...
176 +
  HeatmapGridDensity( _data__,
177 +
                      obj.domain,
178 +
                      obj.hint_callback == "" ? nothing : nothing,
179 +
                      obj.bw_factor,
180 +
                      densFnc )
177 181
end
178 182
179 -
function convert( ::Union{Type{<:PackedSamplableBelief},Type{<:PackedHeatmapDensityRegular}}, 
180 -
                  obj::HeatmapDensityRegular )
183 +
function convert( ::Union{Type{<:PackedSamplableBelief},Type{<:PackedHeatmapGridDensity}}, 
184 +
                  obj::HeatmapGridDensity )
181 185
  #
182 -
183 186
  data_ = obj.data
184 -
185 187
  @cast data[j][i] := data_[i,j]
186 -
  
187 188
  str = convert(SamplableBelief, obj.densityFnc)
189 +
  # TODO misses the hint...
190 +
  PackedHeatmapGridDensity( "IncrementalInference.PackedHeatmapGridDensity",
191 +
                            data,
192 +
                            obj.domain,
193 +
                            "", 
194 +
                            obj.bw_factor,
195 +
                            str )
196 +
end
188 197
189 -
  PackedHeatmapDensityRegular(data,
190 -
                              obj.domain,
191 -
                              "",
192 -
                              obj.level,
193 -
                              obj.sigma,
194 -
                              obj.sigma_scale,
195 -
                              obj.bw_factor,
196 -
                              str )
198 +
199 +
mutable struct PackedLevelSetGridNormal <: PackedSamplableBelief
200 +
  _type::String
201 +
  level::Float64
202 +
  sigma::Float64
203 +
  sigma_scale::Float64
204 +
  # make sure the JSON nested packing works with the serialization overlords
205 +
  heatmap::PackedHeatmapGridDensity
197 206
end
198 207
199 208
209 +
function convert( ::Union{Type{<:SamplableBelief},Type{<:LevelSetGridNormal}}, 
210 +
                  obj::PackedLevelSetGridNormal)
211 +
  #
212 +
  LevelSetGridNormal( obj.level,
213 +
                      obj.sigma,
214 +
                      obj.sigma_scale,
215 +
                      convert(HeatmapGridDensity, obj.heatmap) )
216 +
end
217 +
200 218
219 +
function convert( ::Union{Type{<:PackedSamplableBelief},Type{<:PackedLevelSetGridNormal}}, 
220 +
                  obj::LevelSetGridNormal)
221 +
  #
222 +
  PackedLevelSetGridNormal( "IncrementalInference.PackedLevelSetGridNormal",
223 +
                            obj.level,
224 +
                            obj.sigma,
225 +
                            obj.sigma_scale,
226 +
                            convert(PackedHeatmapGridDensity, obj.heatmap) )
227 +
end
201 228
202 229
203 230
#

@@ -19,7 +19,7 @@
Loading
19 19
20 20
abstract type PackedSamplableBelief end
21 21
22 -
const SamplableBelief = Union{Distributions.Distribution, KDE.BallTreeDensity, AMP.ManifoldKernelDensity, AliasingScalarSampler, FluxModelsDistribution, HeatmapDensityRegular}
22 +
const SamplableBelief = Union{Distributions.Distribution, KDE.BallTreeDensity, AMP.ManifoldKernelDensity, AliasingScalarSampler, FluxModelsDistribution, HeatmapGridDensity, LevelSetGridNormal}
23 23
24 24
25 25
#Supported types for parametric

@@ -32,40 +32,35 @@
Loading
32 32
  - Mostly aimed at limiting compute when faced with massive heatmaps, e.g. nav units are 10's but map is ~1e6.
33 33
- Density approximation is constructed on Guassian measurement assumption of level set and sigma variation.
34 34
- Assume data is on a regular grid on TranslationGroup(2)
35 +
  - Assume on early implementation `x_grid, y_grid = domain`
35 36
36 37
DevNotes:
37 38
- Generalize to scalar fields on any Manifold.
38 39
- Generalize to vector fields if interpolation is sensible.
39 40
"""
40 -
struct HeatmapDensityRegular{T <: Real, H <: Union{<:Function, Nothing}, B <: Union{ManifoldKernelDensity, BallTreeDensity}}
41 -
  """intensity data, assume regular grid for now"""
41 +
struct HeatmapGridDensity{T <: Real, H <: Union{<:Function, Nothing}, B <: Union{ManifoldKernelDensity, BallTreeDensity}}
42 +
  """intensity data, on regular grid"""
42 43
  data::Matrix{T}
43 -
  """domain as grid or locations at which intensity elements exist"""
44 +
  """domain as grid or locations at which scalar intensity elements exist"""
44 45
  domain::Tuple{<:AbstractVector{T},<:AbstractVector{T}}
45 46
  """use location hint to focus sampling to specific area of data, requires additional info at `getSample`
46 47
      assumed the callback will return _____ NOT ACTIVE YET"""
47 48
  hint_callback::H
48 -
  """level at which to extract the set of interest"""
49 -
  level::T
50 -
  """one sigma value associated with measurement noise of `level` against `data`"""
51 -
  sigma::T
52 -
  """make samplible region of interest from data be `sigma_scale` from `level`, e.g. 3*sigma."""
53 -
  sigma_scale::T
54 49
  """general rule for kernel bandwidths used in construction of density, e.g. 0.7 of domain grid spacing"""
55 50
  bw_factor::T 
56 51
  """density function as samplable representation of the data over the domain"""
57 52
  densityFnc::B # TODO change to ::ManifoldKernelDensity{TranslationGroup(2),BallTreeDensity}
58 53
end
59 54
60 -
(hmd::HeatmapDensityRegular)(w...;kw...) = hmd.densityFnc(w...;kw...)
55 +
(hmd::HeatmapGridDensity)(w...;kw...) = hmd.densityFnc(w...;kw...)
61 56
62 -
function sampleTangent(M::AbstractManifold, hms::HeatmapDensityRegular)
57 +
function sampleTangent(M::AbstractManifold, hms::HeatmapGridDensity)
63 58
  sampleTangent(M, hms.densityFnc)
64 59
end
65 60
66 61
67 -
function Base.show(io::IO, x::HeatmapDensityRegular{T,H,B}) where {T,H,B}
68 -
  printstyled(io, "HeatmapDensityRegular{", bold=true, color=:blue)
62 +
function Base.show(io::IO, x::HeatmapGridDensity{T,H,B}) where {T,H,B}
63 +
  printstyled(io, "HeatmapGridDensity{", bold=true, color=:blue)
69 64
  println(io)
70 65
  printstyled(io, "    T", color=:magenta, bold=true )
71 66
  println(io, "      = ", T)
@@ -80,18 +75,74 @@
Loading
80 75
  println(io, "  domain:     ", size(x.domain[1]), ", ", size(x.domain[2]))
81 76
  println(io, "    min/max:    ", round(minimum(x.domain[1]),digits=5), " / ", round(maximum(x.domain[1]),digits=5))
82 77
  println(io, "    min/max:    ", round(minimum(x.domain[2]),digits=5), " / ", round(maximum(x.domain[2]),digits=5))
83 -
  println(io, "  level:      ", x.level)
84 -
  println(io, "  sigma:      ", x.sigma)
85 -
  println(io, "  sig.scale:  ", x.sigma_scale)
86 78
  println(io, "  bw_factor:  ", x.bw_factor)
87 79
  print(io, "  ")
88 80
  show(io, x.densityFnc)
89 81
  nothing
90 82
end
91 83
92 -
Base.show(io::IO, ::MIME"text/plain", x::HeatmapDensityRegular) = show(io, x)
84 +
Base.show(io::IO, ::MIME"text/plain", x::HeatmapGridDensity) = show(io, x)
85 +
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::HeatmapGridDensity) = show(io,x)
86 +
87 +
88 +
##
89 +
90 +
91 +
92 +
"""
93 +
    $TYPEDEF
94 +
95 +
Generate a `<:SamplableBelief` by selecing normal (Gaussian) deviation from a Level Set of a heatmap, e.g. known altitude on a digital elevation model (DEM).
96 +
97 +
Notes
98 +
- Give in heatmap and grid, a level set gets generated, and the object becomes a density function for sampling.
99 +
- Sampling can be more nuanced by injecting a hint, or location of interest:
100 +
  - Mostly aimed at limiting compute when faced with massive heatmaps, e.g. nav units are 10's but map is ~1e6.
101 +
- Density approximation is constructed on Guassian measurement assumption of level set and sigma variation.
102 +
- Assume data is on a regular grid on TranslationGroup(2)
103 +
104 +
DevNotes:
105 +
- Generalize to scalar fields on any Manifold.
106 +
- Generalize to vector fields if interpolation is sensible.
107 +
108 +
See also: [`HeatmapGridDensity`](@ref), [`ManifoldKernelDensity`](@ref)
109 +
"""
110 +
struct LevelSetGridNormal{T <: Real, H <: HeatmapGridDensity}
111 +
  level::T
112 +
  """one sigma value associated with measurement noise of `level` against `data`"""
113 +
  sigma::T
114 +
  """make samplible region of interest from data be `sigma_scale` from `level`, e.g. 3*sigma."""
115 +
  sigma_scale::T
116 +
  """HeatmapDensityGrid is used to sample the LevelSet regions of interest"""
117 +
  heatmap::H
118 +
end
119 +
120 +
(lsg::LevelSetGridNormal)(w...;kw...) = lsg.densityFnc(w...;kw...)
121 +
122 +
function sampleTangent(M::AbstractManifold, lsg::LevelSetGridNormal)
123 +
  sampleTangent(M, lsg.heatmap.densityFnc)
124 +
end
125 +
126 +
127 +
function Base.show(io::IO, x::LevelSetGridNormal{T,H}) where {T,H}
128 +
  printstyled(io, "LevelSetGridNormal{", bold=true, color=:blue)
129 +
  println(io)
130 +
  printstyled(io, "    T", color=:magenta, bold=true )
131 +
  println(io, "      = ", T)
132 +
  printstyled(io, "    H", color=:magenta, bold=true )
133 +
  println(io, "`int  = ", H )
134 +
  printstyled(io, " }", color=:blue, bold=true)
135 +
  println(io, "(")
136 +
  println(io, "  level:      ", x.level)
137 +
  println(io, "  sigma:      ", x.sigma)
138 +
  println(io, "  sig.scale:  ", x.sigma_scale)
139 +
  println(io, "  heatmap:    ")
140 +
  show(io, x.heatmap)
141 +
  nothing
142 +
end
93 143
94 -
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::HeatmapDensityRegular) = show(io,x)
144 +
Base.show(io::IO, ::MIME"text/plain", x::LevelSetGridNormal) = show(io, x)
145 +
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::LevelSetGridNormal) = show(io,x)
95 146
96 147
97 148

@@ -5,45 +5,44 @@
Loading
5 5
using .Interpolations 
6 6
7 7
# only export on Requires.jl
8 -
export HeatmapDensityRegular
8 +
export HeatmapGridDensity, PackedHeatmapGridDensity
9 +
export LevelSetGridNormal, PackedLevelSetGridNormal
10 +
11 +
export sampleHeatmap
9 12
10 13
##
11 14
15 +
getManifold(hgd::HeatmapGridDensity) = getManifold(hgd.densityFnc)
16 +
getManifold(lsg::LevelSetGridNormal) = getManifold(lsg.heatmap)
12 17
13 18
"""
14 19
    $SIGNATURES
15 20
16 21
Get the grid positions at the specified height (within the provided spreads)
22 +
23 +
DevNotes
24 +
- TODO Should this be consolidated with AliasingScalarSampler?
17 25
"""
18 -
function getLevelSetSigma(  data::AbstractMatrix{<:Real},
19 -
                            level::Real,
20 -
                            sigma::Real,
21 -
                            x_grid::AbstractVector{<:Real}, 
22 -
                            y_grid::AbstractVector{<:Real};
23 -
                            sigma_scale::Real=3  )
26 +
function sampleHeatmap( roi::AbstractMatrix{<:Real},
27 +
                        x_grid::AbstractVector{<:Real}, 
28 +
                        y_grid::AbstractVector{<:Real},
29 +
                        thres::Real = 0  )
24 30
  #
25 -
  # make Gaussian
26 -
  roi = data .- level
27 -
  roi .^= 2
28 -
  roi .*= 0.5/(sigma^2)
29 -
  thres = (sigma_scale^2) # IS THIS RIGHT ???? TODO, maybe 1/????????
30 31
31 -
  # truncate at sigma_scale*sigma
32 -
  mask = roi .<= thres
33 -
  _roi = thres .- roi
32 +
  # mask the region of interest above the sampling threshold value
33 +
  mask = thres .<= roi
34 34
35 35
  idx2d = findall(mask)  # 2D indices
36 36
  pos = (v->[x_grid[v[1]],y_grid[v[2]]]).(idx2d)
37 -
  weights = (v->_roi[v[1],v[2]]).(idx2d)
37 +
  weights = (v->roi[v[1],v[2]]).(idx2d)
38 38
  weights ./= sum(weights)
39 39
40 -
  # recast to the appropriate shape
41 -
  @cast kp[i,j] := pos[j][i]
42 -
  collect(kp), weights, roi
40 +
  pos, weights
43 41
end
44 42
43 +
45 44
# TODO make n-dimensional, and later on-manifold
46 -
# TODO better standardize for heatmaps on manifolds
45 +
# TODO better standardize for heatmaps on manifolds w MKD
47 46
function fitKDE(support,
48 47
                weights,
49 48
                x_grid::AbstractVector{<:Real}, 
@@ -59,30 +58,26 @@
Loading
59 58
  kde!(support, kernel_bw, weights)
60 59
end
61 60
62 -
63 -
64 -
65 -
function HeatmapDensityRegular( data::AbstractMatrix{<:Real}, 
66 -
                                domain::Tuple{<:AbstractVector{<:Real},<:AbstractVector{<:Real}},
67 -
                                level::Real,
68 -
                                sigma::Real;
69 -
                                sigma_scale::Real=3,
70 -
                                hist_callback::Union{<:Function, Nothing}=nothing,
71 -
                                bw_factor::Real=0.7,  # kde spread between domain points 
72 -
                                N::Int=10000  )
61 +
# Helper function to construct HGD
62 +
function HeatmapGridDensity(data::AbstractMatrix{<:Real}, 
63 +
                            domain::Tuple{<:AbstractVector{<:Real},<:AbstractVector{<:Real}},
64 +
                            hist_callback::Union{<:Function, Nothing}=nothing,
65 +
                            bw_factor::Real=0.7;  # kde spread between domain points 
66 +
                            N::Int=10000  )
73 67
  #
68 +
  pos, weights_ = sampleHeatmap(data, domain..., 0)
69 +
  # recast to the appropriate shape
70 +
  @cast support_[i,j] := pos[j][i]
74 71
75 -
  # select the support from raw data
76 -
  support_, weights_, roi = getLevelSetSigma(data, level, sigma, domain...; sigma_scale=sigma_scale)
77 -
  
78 72
  # constuct a pre-density from which to draw intermediate samples
79 -
  density_ = fitKDE(support_, weights_, domain...; bw_factor=bw_factor)
73 +
  # TODO remove extraneous collect()
74 +
  density_ = fitKDE(collect(support_), weights_, domain...; bw_factor=bw_factor)
80 75
  pts_preIS, = sample(density_, N)
81 76
  
82 77
  @cast vec_preIS[j][i] := pts_preIS[i,j]
83 78
  
84 79
  # weight the intermediate samples according to interpolation of raw data
85 -
  hm = Interpolations.LinearInterpolation( domain, roi ) # interpolated heatmap
80 +
  hm = Interpolations.LinearInterpolation( domain, data ) # interpolated heatmap
86 81
  d_scalar = Vector{Float64}( undef, length(vec_preIS) )
87 82
  
88 83
  # interpolate d_scalar for intermediate test points
@@ -106,7 +101,36 @@
Loading
106 101
  density = ManifoldKernelDensity(TranslationGroup(Ndim(bel)), bel)
107 102
108 103
  # return `<:SamplableBelief` object
109 -
  HeatmapDensityRegular(data, domain, hist_callback, level, sigma, float(sigma_scale), bw_factor, density)
104 +
  HeatmapGridDensity(data, domain, hist_callback, bw_factor, density)
105 +
end
106 +
107 +
108 +
# legacy construct helper
109 +
function LevelSetGridNormal(data::AbstractMatrix{<:Real}, 
110 +
                            domain::Tuple{<:AbstractVector{<:Real},<:AbstractVector{<:Real}},
111 +
                            level::Real,
112 +
                            sigma::Real;
113 +
                            sigma_scale::Real=3,
114 +
                            hist_callback::Union{<:Function, Nothing}=nothing,
115 +
                            bw_factor::Real=0.7,  # kde spread between domain points 
116 +
                            N::Int=10000  )
117 +
  #
118 +
119 +
  # select the support from raw data
120 +
  roi = data.-level
121 +
  # make Gaussian
122 +
  roi .^= 2
123 +
  roi .*= 0.5/(sigma^2)
124 +
  roi .-= sigma_scale^2
125 +
  roi .*= -1
126 +
  # truncate sigma_scale*sigma below zero
127 +
  #   h = heatmap;  z = measurement
128 +
  #   l = 1/2 (h-z/σ)^2
129 +
  #   masked_roi = 0 .< κ^2 - l
130 +
  
131 +
  hgd = HeatmapGridDensity(data, domain, hist_callback, bw_factor; N=N)
132 +
133 +
  LevelSetGridNormal(level, sigma, float(sigma_scale), hgd)
110 134
end
111 135
112 136

@@ -3,28 +3,54 @@
Loading
3 3
## LEGACY SUPPORT FOR ZMQ IN CAESAR
4 4
##==============================================================================
5 5
6 -
export listSolvekeys
7 -
8 -
export _evalType
9 -
10 -
# not sure if and where this is still being used
11 -
function _evalType(pt::String)::Type
12 -
  @error "_evalType has been deprecated, use DFG serialization methods instead."
13 -
  try
14 -
    getfield(Main, Symbol(pt))
15 -
  catch ex
16 -
    io = IOBuffer()
17 -
    showerror(io, ex, catch_backtrace())
18 -
    err = String(take!(io))
19 -
    error("_evalType: Unable to locate factor/distribution type '$pt' in main context (e.g. do a using on all your factor libraries). Please check that this factor type is loaded into main. Stack trace = $err")
20 -
  end
21 -
end
6 +
@deprecate _evalType(pt::String) DFG.getTypeFromSerializationModule(pt)
7 +
# # FIXME, replace with T = DFG.getTypeFromSerializationModule(obj._type)
8 +
# export _evalType
9 +
# # not sure if and where this is still being used
10 +
# function _evalType(pt::String)::Type
11 +
#   @error "_evalType has been deprecated, use DFG serialization methods instead."
12 +
#   try
13 +
#     getfield(Main, Symbol(pt))
14 +
#   catch ex
15 +
#     io = IOBuffer()
16 +
#     showerror(io, ex, catch_backtrace())
17 +
#     err = String(take!(io))
18 +
#     error("_evalType: Unable to locate factor/distribution type '$pt' in main context (e.g. do a using on all your factor libraries). Please check that this factor type is loaded into main. Stack trace = $err")
19 +
#   end
20 +
# end
22 21
23 22
24 23
##==============================================================================
25 24
## Deprecate code below before v0.27
26 25
##==============================================================================
27 26
27 +
# """
28 +
#     $SIGNATURES
29 +
30 +
# Sample points from a regular grid scalar field level set.
31 +
32 +
# Notes
33 +
# - modifies first argument roi to save on memory allocations
34 +
# - user should duplicate if with a deepcopy if needed
35 +
# """
36 +
# function sampleLevelSetGaussian!( roi::AbstractMatrix{<:Real},
37 +
#                                   sigma::Real,
38 +
#                                   x_grid::AbstractVector{<:Real}, 
39 +
#                                   y_grid::AbstractVector{<:Real};
40 +
#                                   sigma_scale::Real=3  )
41 +
#   #
42 +
#   # make Gaussian
43 +
#   roi .^= 2
44 +
#   roi .*= 0.5/(sigma^2)
45 +
#     # truncate at sigma_scale*sigma
46 +
#     _roi = thres .- roi
47 +
48 +
#   sampleHeatmap(roi, x_grid, y_grid, sigma_scale^2)
49 +
# end
50 +
51 +
@deprecate HeatmapDensityRegular(w...;kw...) LevelSetGridNormal(w...;kw...)
52 +
53 +
# @deprecate getLevelSetSigma(data::AbstractMatrix{<:Real}, level::Real, w...; kw...) sampleLevelSetGaussian!(data.-level, w...; kw...)
28 54
29 55
getOutNeighbors(w...;kw...) = error("Obsolete, use DFG.getNeighbors instead.")
30 56
@@ -416,6 +442,8 @@
Loading
416 442
## Deprecate code below before v0.26
417 443
##==============================================================================
418 444
445 +
export listSolvekeys
446 +
419 447
# wow, that was quite far off -- needs testing
420 448
# function factorCanInitFromOtherVars(dfg::T,
421 449
#                                     fct::Symbol,

@@ -177,7 +177,7 @@
Loading
177 177
178 178
  # density passed through directly from PartialPriorPassThrough.Z
179 179
  fctFnc = getFactorType(fct)
180 -
  proposal = fctFnc.Z.densityFnc
180 +
  proposal = fctFnc.Z.heatmap.densityFnc
181 181
182 182
  # in case of partial, place the proposal into larger marginal/partial MKD
183 183
  proposal_ = if isPartial(fctFnc)

@@ -3,12 +3,12 @@
Loading
3 3
export PartialPriorPassThrough, PackedPartialPriorPassThrough
4 4
5 5
6 -
struct PartialPriorPassThrough{B <: HeatmapDensityRegular, T <:Tuple} <: AbstractPrior
6 +
struct PartialPriorPassThrough{B <: Union{<:HeatmapGridDensity,<:LevelSetGridNormal}, T <:Tuple} <: AbstractPrior
7 7
  Z::B
8 8
  partial::T
9 9
end
10 10
11 -
getManifold(pppt::PartialPriorPassThrough{<:HeatmapDensityRegular{T,H,<:ManifoldKernelDensity}}) where {T,H} = (pppt.Z.densityFnc.manifold)
11 +
getManifold(pppt::PartialPriorPassThrough) = getManifold(pppt.Z)
12 12
13 13
# this step is skipped during main inference process
14 14
getSample(cf::CalcFactor{<:PartialPriorPassThrough}) = sampleTangent(getManifold(cf.factor), cf.factor.Z)
@@ -19,8 +19,13 @@
Loading
19 19
## ====================================================================================================
20 20
21 21
22 +
"""
23 +
    $TYPEDEF
24 +
25 +
Required internal density to store its type
26 +
"""
22 27
mutable struct PackedPartialPriorPassThrough <: AbstractPackedFactor
23 -
  Z::PackedHeatmapDensityRegular
28 +
  Z::String # PackedHeatmapGridDensity
24 29
  partial::Vector{Int}
25 30
end
26 31
@@ -28,20 +33,24 @@
Loading
28 33
function convert( ::Union{Type{<:AbstractPackedFactor}, Type{<:PackedPartialPriorPassThrough}},
29 34
                  obj::PartialPriorPassThrough )
30 35
  #
31 -
  
32 -
  st = convert(PackedHeatmapDensityRegular, obj.Z)
33 -
  
34 -
  PackedPartialPriorPassThrough(st, Int[obj.partial...])
36 +
37 +
  po = convert(PackedSamplableBelief, obj.Z)
38 +
  str = JSON2.write(po)
39 +
  PackedPartialPriorPassThrough(str, Int[obj.partial...])
35 40
end
36 41
37 42
38 43
function convert( ::Union{Type{<:AbstractFactor}, Type{<:PartialPriorPassThrough}},
39 44
                  obj::PackedPartialPriorPassThrough )
40 45
  #
41 -
  
42 -
  st = convert(HeatmapDensityRegular, obj.Z)
43 -
  
44 -
  PartialPriorPassThrough(st, tuple(obj.partial...))
46 +
47 +
  # get as bland obj to extract type
48 +
  _up = JSON2.read(obj.Z)
49 +
  _typ = DFG.getTypeFromSerializationModule(_up._type)
50 +
  # now redo with type
51 +
  pdens = JSON2.read(obj.Z, _typ)
52 +
  dens = convert(SamplableBelief, pdens)
53 +
  PartialPriorPassThrough(dens, tuple(obj.partial...))
45 54
end
46 55
47 56

@@ -170,7 +170,7 @@
Loading
170 170
  # piggy back on serialization of InferenceVariable rather than try serialize anything Manifolds.jl
171 171
  M = DFG.getTypeFromSerializationModule(obj.varType) |> getManifold
172 172
  
173 -
  # TODO this is too excesssive
173 +
  # TODO this is too excessive
174 174
  e0 = identity_element(M)
175 175
  p = AMP.makePointFromCoords(M, obj.p, e0)
176 176
Files Coverage
src 77.23%
Project Totals (67 files) 77.23%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading