Skip to content

Fix julia 1.8 bug on tree deepcopy #1601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
version:
- '1.6'
- '1.7'
- '1.8'
- 'nightly'
os:
- ubuntu-latest
Expand Down
31 changes: 31 additions & 0 deletions src/entities/JunctionTreeTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,37 @@ end

const BayesTree = MetaBayesTree

# NOTE Temporary fix? Overwrite deepcopy on MetaBayesTree to strip out copying the channels.
# see https://github.com/JuliaRobotics/IncrementalInference.jl/issues/1530
# possible fix in https://github.com/JuliaLang/julia/pull/46406
import Base.deepcopy_internal
function Base.deepcopy_internal(bt::MetaBayesTree, stackdict::IdDict)

if haskey(stackdict, bt)
return stackdict[bt]
end

mg = bt.bt

graph = deepcopy_internal(mg.graph, stackdict)
vprops = deepcopy_internal(mg.vprops, stackdict)
T = eltype(mg)
# dropping all edge data
eprops = Dict{MetaGraphs.SimpleEdge{T},MetaGraphs.PropDict}()
gprops = deepcopy_internal(mg.gprops, stackdict)
weightfield = deepcopy_internal(mg.weightfield, stackdict)
defaultweight = deepcopy_internal(mg.defaultweight, stackdict)
metaindex = deepcopy_internal(mg.metaindex, stackdict)
indices = deepcopy_internal(mg.indices, stackdict)

mg_cpy = MetaDiGraph(graph, vprops, eprops, gprops, weightfield, defaultweight, metaindex, indices)

bt_cpy = MetaBayesTree(mg_cpy, bt.btid, deepcopy_internal(bt.frontals, stackdict), deepcopy_internal(bt.eliminationOrder, stackdict), bt.buildTime)

stackdict[bt] = bt_cpy
return bt_cpy
end

"""
$TYPEDEF

Expand Down