fix: support Colon() in middle of indices for NodeLabel (#275)#303
Open
ArpanC6 wants to merge 3 commits into
Open
fix: support Colon() in middle of indices for NodeLabel (#275)#303ArpanC6 wants to merge 3 commits into
ArpanC6 wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #275
Fixes #293
While working with multi-dimensional latent variables in a model I noticed that using a colon
:in the middle of an index expression likemedia[g, :, i]causes a crash with aMethodError. For example, this modelwould throw
The issue is that
NodeLabelonly had a single-argumentgetindexoverload:When Julia sees
media[g, :, i]on aNodeLabel, it tries to callgetindexwith three arguments, which didn't have a matching method. SinceNodeLabelrepresents a node in the factor graph and not an actual array the right behaviour is to just return the label itself regardless of the indices which is exactly what the existing single index overload already does.The fix is a one-line addition:
I also added a test that covers this case to make sure it doesn't regress.