Skip to content

implement mergeVariableStates! #1145

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

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

implement mergeVariableStates! #1145

wants to merge 4 commits into from

Conversation

Affie
Copy link
Member

@Affie Affie commented Jun 25, 2025

I went back and forth on mergeVariableStates! and comparing it with updateVariableNodeData! and settled on following the verb by still providing a container. The same concept can be followed for all satellite levels (such as Blobentry)

@dehann would you mind giving your inputs.

@Affie Affie self-assigned this Jun 25, 2025
@Affie Affie added enhancement New feature or request API labels Jun 25, 2025
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@Affie
Copy link
Member Author

Affie commented Jun 25, 2025

I think variable should also be plural, so mergeVariablesStates! as mergeVariableStates merges on one variable.

Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.71%. Comparing base (1b6116f) to head (1f2adf8).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1145      +/-   ##
===========================================
+ Coverage    73.58%   73.71%   +0.12%     
===========================================
  Files           28       28              
  Lines         2442     2450       +8     
===========================================
+ Hits          1797     1806       +9     
+ Misses         645      644       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Affie Affie modified the milestones: v0.27.0, v0.28.0 Jun 27, 2025
return sum(cnt)
end

function mergeVariableStates!(
Copy link
Member

Choose a reason for hiding this comment

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

I would have expected the default implementation signature to be

function mergeState!(<:Variable, <:VariableState)
  # actual implementation lives here
end

mergeState!(dfg::Factorgraph, lb::Symbol, state::VariableState) = mergeState!(getVariable(fg, lb), state)

mergeStates!(dfg::Factorgraph, ::Vector{<:Pair_}) = # pmap over vector mergeState!(dfg, pair[1], pair[2])

mergeVariableState!(w...;kw...) = mergeState!(w...;kw...) # alias

Copy link
Member Author

Choose a reason for hiding this comment

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

mergeState! is not consistent with the rest of the API as we have getVariableState and therefore would expect mergeVariableState!. We need the Variable noun in get explicit to avoid ambiguities, to have a type stable implementation in julia, and to help with SDKs without multiple dispatch. It also makes for more readable and maintainable code to be more explicit -- when updating from getSolverData, it was a pain to distinguish between Variable and Factor. We can still do the alias, but that would likely be a DFG only function and not across SDKs. I would also not include [get/add/merge/delete]State[!] for DFGv1 beta work.

Does the comment ... ::Vector{<:Pair_}) mean you are happy with the new signature, what I wanted to know form this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants