Skip to content
Open
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\## \[Unreleased]



\### Fixed

\- Fixed `Colon()` not working in the middle of indices for `NodeLabel` getindex (\[#303](https://github.com/ReactiveBayes/GraphPPL.jl/pull/303))

1 change: 1 addition & 0 deletions src/graph_engine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ end
Base.length(label::NodeLabel) = 1
Base.size(label::NodeLabel) = ()
Base.getindex(label::NodeLabel, any) = label
Base.getindex(label::NodeLabel, i1, is...) = label
Base.:(<)(left::NodeLabel, right::NodeLabel) = left.global_counter < right.global_counter
Base.broadcastable(label::NodeLabel) = Ref(label)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ function materialize_constraints!(model::Model, node_label::NodeLabel, node_data

if !is_valid_partition(constraint_set)
error(
lazy"Factorization constraint set at node $node_label is not a valid constraint set. Please check your model definition and constraint specification. (Constraint set: $constraint_bitset)"
lazy"Factorization constraint set at node $node_label is not a valid constraint set. Please check your model definition and constraint specification. (Constraint set: $constraint_bitset)\n\nHint: A valid constraint set requires that each interface belongs to exactly one factorization group. In the constraint matrix, each column must have exactly one non-zero entry per group. Make sure all variables appearing in your model are included in your factorization constraint."
)
end

Expand Down
17 changes: 17 additions & 0 deletions test/test_colon_index.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Test
using GraphPPL
using Distributions

@model function test_colon_bug(media)
for g in 1:2
for i in 1:3
media_effect[g, i] := media[g, :, i]
end
end
end

@testset "Colon index in middle of indices" begin
media_data = rand(2, 5, 3)
model = create_model(test_colon_bug(media = media_data))
@test model !== nothing
end