Skip to content
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

Simple copy functions #570

Closed
wants to merge 1 commit into from
Closed

Simple copy functions #570

wants to merge 1 commit into from

Conversation

GearsAD
Copy link
Collaborator

@GearsAD GearsAD commented Aug 3, 2020

This work for simple copy functions that we can use in IIF?

@codecov
Copy link

codecov bot commented Aug 3, 2020

Codecov Report

Merging #570 into master will decrease coverage by 0.15%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #570      +/-   ##
==========================================
- Coverage   79.86%   79.71%   -0.16%     
==========================================
  Files          33       33              
  Lines        2111     2115       +4     
==========================================
  Hits         1686     1686              
- Misses        425      429       +4     
Impacted Files Coverage Δ
src/DistributedFactorGraphs.jl 100.00% <ø> (ø)
src/entities/DFGVariable.jl 53.84% <0.00%> (-4.49%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e73933d...1bc023a. Read the comment docs.

@@ -87,6 +87,28 @@ VariableNodeData(val::Array{Float64,2},
VariableNodeData(softtype::T; solverKey::Symbol=:default) where T <: InferenceVariable =
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], softtype, false, 0.0, false, false, 0, 0, solverKey)

## Copying
function copy(vnd::VariableNodeData; solverKey::Union{Nothing,Symbol}=nothing)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldn't overwrite expected behaviour from base copy with deepcopy?
I expect copy to return a shallow copy and deepcopy for this.

Personally I don't think we should provide too many functions. Every function has to be documented and maintained.
The user can rather just do

dcvnd = deepcopy(vnd)
dcvnd.selverKey = newKey

Is the function we are trying to replace updateSolverData!(dfg, label, vnd, newsolvekey)?
Where vnd.solvekey != newsolvekey.
Perhaps something like (although IIF needs to be updated slightly for it):

function deepcopySolverData!(dfg::AbstractDFG, label::Symbol, srcKey::Sybol, dstKey::Symbol)
    vnd = deepcopy(getSolverData!(dfg, label, srcKey))
    vnd.solverKey = dstKey
    updateSolverData!(dfg, vnd)
end  

Now that I'm thinking it through. update is maybe not the correct function to use. Its adding new solverdata so maybe:

function addSolverData!(dfg::AbstractDFG, label::Symbol, vnd, solverKey::Symbol)
    vnd.solverKey = dstKey
    addSolverData!(dfg, vnd)
end  

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, that works, will close this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants