|
1 | 1 | # heatmap sampler (experimental) |
2 | 2 |
|
| 3 | + |
| 4 | +(hmd::HeatmapGridDensity)(w...; kw...) = hmd.densityFnc(w...; kw...) |
| 5 | + |
| 6 | +function sampleTangent(M::AbstractManifold, hms::HeatmapGridDensity) |
| 7 | + return sampleTangent(M, hms.densityFnc) |
| 8 | +end |
| 9 | + |
| 10 | +function Base.show(io::IO, x::HeatmapGridDensity{T, H, B}) where {T, H, B} |
| 11 | + printstyled(io, "HeatmapGridDensity{"; bold = true, color = :blue) |
| 12 | + println(io) |
| 13 | + printstyled(io, " T"; color = :magenta, bold = true) |
| 14 | + println(io, " = ", T) |
| 15 | + printstyled(io, " H"; color = :magenta, bold = true) |
| 16 | + println(io, "`int = ", H) |
| 17 | + printstyled(io, " B"; color = :magenta, bold = true) |
| 18 | + println(io, " = ", B) |
| 19 | + printstyled(io, " }"; color = :blue, bold = true) |
| 20 | + println(io, "(") |
| 21 | + println(io, " data: ", size(x.data)) |
| 22 | + println( |
| 23 | + io, |
| 24 | + " min/max: ", |
| 25 | + round(minimum(x.data); digits = 5), |
| 26 | + " / ", |
| 27 | + round(maximum(x.data); digits = 5), |
| 28 | + ) |
| 29 | + println(io, " domain: ", size(x.domain[1]), ", ", size(x.domain[2])) |
| 30 | + println( |
| 31 | + io, |
| 32 | + " min/max: ", |
| 33 | + round(minimum(x.domain[1]); digits = 5), |
| 34 | + " / ", |
| 35 | + round(maximum(x.domain[1]); digits = 5), |
| 36 | + ) |
| 37 | + println( |
| 38 | + io, |
| 39 | + " min/max: ", |
| 40 | + round(minimum(x.domain[2]); digits = 5), |
| 41 | + " / ", |
| 42 | + round(maximum(x.domain[2]); digits = 5), |
| 43 | + ) |
| 44 | + println(io, " bw_factor: ", x.bw_factor) |
| 45 | + print(io, " ") |
| 46 | + show(io, x.densityFnc) |
| 47 | + return nothing |
| 48 | +end |
| 49 | + |
| 50 | +Base.show(io::IO, ::MIME"text/plain", x::HeatmapGridDensity) = show(io, x) |
| 51 | +Base.show(io::IO, ::MIME"application/prs.juno.inline", x::HeatmapGridDensity) = show(io, x) |
| 52 | + |
| 53 | +""" |
| 54 | + $SIGNATURES |
| 55 | +
|
| 56 | +Internal function for updating HGD. |
| 57 | + |
| 58 | +Notes |
| 59 | +- Likely to be used for [unstashing packed factors](@ref section_stash_unstash) via [`preambleCache`](@ref). |
| 60 | +- Counterpart to `AMP._update!` function for stashing of either MKD or HGD. |
| 61 | +""" |
| 62 | +function _update!( |
| 63 | + dst::HeatmapGridDensity{T, H, B}, |
| 64 | + src::HeatmapGridDensity{T, H, B}, |
| 65 | +) where {T, H, B} |
| 66 | + @assert size(dst.data) == size(src.data) "Updating HeatmapDensityGrid can only be done for data of the same size" |
| 67 | + dst.data .= src.data |
| 68 | + if !isapprox(dst.domain[1], src.domain[1]) |
| 69 | + dst.domain[1] .= src.domain[1] |
| 70 | + end |
| 71 | + if !isapprox(dst.domain[2], src.domain[2]) |
| 72 | + dst.domain[2] .= src.domain[2] |
| 73 | + end |
| 74 | + AMP._update!(dst.densityFnc, src.densityFnc) |
| 75 | + return dst |
| 76 | +end |
| 77 | + |
| 78 | + |
| 79 | +## |
| 80 | + |
| 81 | +(lsg::LevelSetGridNormal)(w...; kw...) = lsg.densityFnc(w...; kw...) |
| 82 | + |
| 83 | +function sampleTangent(M::AbstractManifold, lsg::LevelSetGridNormal) |
| 84 | + return sampleTangent(M, lsg.heatmap.densityFnc) |
| 85 | +end |
| 86 | + |
| 87 | +function Base.show(io::IO, x::LevelSetGridNormal{T, H}) where {T, H} |
| 88 | + printstyled(io, "LevelSetGridNormal{"; bold = true, color = :blue) |
| 89 | + println(io) |
| 90 | + printstyled(io, " T"; color = :magenta, bold = true) |
| 91 | + println(io, " = ", T) |
| 92 | + printstyled(io, " H"; color = :magenta, bold = true) |
| 93 | + println(io, "`int = ", H) |
| 94 | + printstyled(io, " }"; color = :blue, bold = true) |
| 95 | + println(io, "(") |
| 96 | + println(io, " level: ", x.level) |
| 97 | + println(io, " sigma: ", x.sigma) |
| 98 | + println(io, " sig.scale: ", x.sigma_scale) |
| 99 | + println(io, " heatmap: ") |
| 100 | + show(io, x.heatmap) |
| 101 | + return nothing |
| 102 | +end |
| 103 | + |
| 104 | +Base.show(io::IO, ::MIME"text/plain", x::LevelSetGridNormal) = show(io, x) |
| 105 | +Base.show(io::IO, ::MIME"application/prs.juno.inline", x::LevelSetGridNormal) = show(io, x) |
| 106 | + |
| 107 | + |
3 | 108 | ## |
4 | 109 |
|
5 | 110 | getManifold(hgd::HeatmapGridDensity) = getManifold(hgd.densityFnc) |
|
0 commit comments