Skip to content

Commit

Permalink
Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdmitri committed May 17, 2024
1 parent 0c59ef2 commit 82f598e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/graph_engine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function unroll(proxylabel::ProxyLabel, proxied::ProxyLabel, index, maycreate, l
end

function unroll(proxylabel::ProxyLabel, something::Any, index, maycreate, liftedindex)
return something
return checked_getindex(something, index)
end

checked_getindex(something, index::FunctionalIndex) = Base.getindex(something, index)
Expand Down
14 changes: 7 additions & 7 deletions test/graph_construction_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ end
@testitem "Simple model with lazy data (vector) creation" begin
using Distributions
import GraphPPL:
create_model, getorcreate!, LazyIndex, NodeCreationOptions, MissingCollection, index, getproperties, is_kind, VariableRef, datalabel
create_model, getorcreate!, LazyIndex, NodeCreationOptions, MissingCollection, index, getproperties, is_kind, VariableRef, datalabel, VariableKindData

include("testutils.jl")

Expand All @@ -138,9 +138,9 @@ end

@testset for n in 5:10
model = create_model(simple_model_3(n = n)) do model, ctx
T = datalabel(model, ctx, NodeCreationOptions(kind = :data_for_T), :T)
y = datalabel(model, ctx, NodeCreationOptions(kind = :data_for_y), :y)
Σ = datalabel(model, ctx, NodeCreationOptions(kind = :data_for_Σ), )
T = datalabel(model, ctx, NodeCreationOptions(kind = VariableKindData), :T)
y = datalabel(model, ctx, NodeCreationOptions(kind = VariableKindData), :y)
Σ = datalabel(model, ctx, NodeCreationOptions(kind = VariableKindData), )
return (T = T, y = y, Σ = Σ)
end

Expand All @@ -151,9 +151,9 @@ end
@test length(collect(filter(as_variable(:y), model))) === n

# test that options are preserved
@test all(label -> is_kind(getproperties(model[label]), :data_for_T), collect(filter(as_variable(:T), model)))
@test all(label -> is_kind(getproperties(model[label]), :data_for_y), collect(filter(as_variable(:y), model)))
@test all(label -> is_kind(getproperties(model[label]), :data_for_Σ), collect(filter(as_variable(), model)))
@test all(label -> is_kind(getproperties(model[label]), VariableKindData), collect(filter(as_variable(:T), model)))
@test all(label -> is_kind(getproperties(model[label]), VariableKindData), collect(filter(as_variable(:y), model)))
@test all(label -> is_kind(getproperties(model[label]), VariableKindData), collect(filter(as_variable(), model)))

# test that indices are of expected shape
Tsindices = map((label) -> index(getproperties(model[label])), collect(filter(as_variable(:T), model)))
Expand Down
7 changes: 3 additions & 4 deletions test/graph_engine_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ end
end

@testitem "Lift index" begin
import GraphPPL: lift_index, True, False
import GraphPPL: lift_index, True, False, checked_getindex

@test lift_index(True(), nothing, nothing) === nothing
@test lift_index(True(), (1,), nothing) === (1,)
Expand All @@ -653,11 +653,10 @@ end
GraphPPL.is_proxied(::Type{LiftingTest}) = GraphPPL.True()

function GraphPPL.unroll(proxy::ProxyLabel, ::LiftingTest, index, maycreate, liftedindex)
@test maycreate === True()
if liftedindex === nothing
return "Hello"
return checked_getindex("Hello", index)
else
return "World"
return checked_getindex("World", index)
end
end

Expand Down

0 comments on commit 82f598e

Please sign in to comment.