Skip to content

Commit ff106fa

Browse files
committed
Change to error
1 parent 68a817e commit ff106fa

File tree

3 files changed

+69
-123
lines changed

3 files changed

+69
-123
lines changed

src/graph_engine.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,9 @@ Base.:(==)(left::VariableRef, right::VariableRef) =
883883
left.model == right.model && left.context == right.context && left.name == right.name && left.index == right.index
884884

885885
function Base.:(==)(left::VariableRef, right)
886-
@warn "Comparing Factor Graph variable `$left` with a value. This is not possible as the value of `$left` is not known at model construction time."
887-
return false
886+
error(
887+
"Comparing Factor Graph variable `$left` with a value. This is not possible as the value of `$left` is not known at model construction time."
888+
)
888889
end
889890
Base.:(==)(left, right::VariableRef) = right == left
890891

test/graph_construction_tests.jl

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,10 +1729,9 @@ end
17291729
end
17301730
end
17311731

1732-
@test_logs (
1733-
:warn,
1734-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
1735-
) create_model(test_model(y = 1))
1732+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." create_model(
1733+
test_model(y = 1)
1734+
)
17361735

17371736
@model function test_model(y)
17381737
x ~ Normal(0.0, 1.0)
@@ -1743,11 +1742,9 @@ end
17431742
end
17441743
end
17451744

1746-
@test_logs (
1747-
:warn,
1748-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
1749-
) create_model(test_model(y = 1))
1750-
1745+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." create_model(
1746+
test_model(y = 1)
1747+
)
17511748
@model function test_model(y)
17521749
x ~ Normal(0.0, 1.0)
17531750
if x < 0
@@ -1757,10 +1754,9 @@ end
17571754
end
17581755
end
17591756

1760-
@test_logs (
1761-
:warn,
1762-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
1763-
) create_model(test_model(y = 1))
1757+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." create_model(
1758+
test_model(y = 1)
1759+
)
17641760

17651761
@model function test_model(y)
17661762
x ~ Normal(0.0, 1.0)
@@ -1771,8 +1767,7 @@ end
17711767
end
17721768
end
17731769

1774-
@test_logs (
1775-
:warn,
1776-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
1777-
) create_model(test_model(y = 1))
1770+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." create_model(
1771+
test_model(y = 1)
1772+
)
17781773
end

test/graph_engine_tests.jl

Lines changed: 54 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -840,112 +840,62 @@ end
840840
ctx = getcontext(model)
841841
xref = VariableRef(model, ctx, NodeCreationOptions(), :x, (nothing,))
842842
@test xref == xref
843-
@test_logs (
844-
:warn,
845-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
846-
) xref != 1
847-
@test_logs (
848-
:warn,
849-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
850-
) 1 != xref
851-
@test_logs (
852-
:warn,
853-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
854-
) xref == 1
855-
@test_logs (
856-
:warn,
857-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
858-
) 1 == xref
859-
@test_logs (
860-
:warn,
861-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
862-
) xref > 0
863-
@test_logs (
864-
:warn,
865-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
866-
) 0 < xref
867-
@test_logs (
868-
:warn,
869-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
870-
) "something" == xref
871-
@test_logs (
872-
:warn,
873-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
874-
) 10 > xref
875-
@test_logs (
876-
:warn,
877-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
878-
) xref < 10
879-
@test_logs (
880-
:warn,
881-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
882-
) 0 <= xref
883-
@test_logs (
884-
:warn,
885-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
886-
) xref >= 0
887-
@test_logs (
888-
:warn,
889-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
890-
) xref <= 0
891-
@test_logs (
892-
:warn,
893-
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time."
894-
) 0 >= xref
843+
@test_throws(
844+
"Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time.",
845+
xref != 1
846+
)
847+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." 1 !=
848+
xref
849+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." xref ==
850+
1
851+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." 1 ==
852+
xref
853+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." xref >
854+
0
855+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." 0 <
856+
xref
857+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." "something" ==
858+
xref
859+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." 10 >
860+
xref
861+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." xref <
862+
10
863+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." 0 <=
864+
xref
865+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." xref >=
866+
0
867+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." xref <=
868+
0
869+
@test_throws "Comparing Factor Graph variable `x` with a value. This is not possible as the value of `x` is not known at model construction time." 0 >=
870+
xref
895871

896872
xref = VariableRef(model, ctx, NodeCreationOptions(), :x, (1, 2))
897-
@test_logs (
898-
:warn,
899-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
900-
) xref != 1
901-
@test_logs (
902-
:warn,
903-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
904-
) 1 != xref
905-
@test_logs (
906-
:warn,
907-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
908-
) xref == 1
909-
@test_logs (
910-
:warn,
911-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
912-
) 1 == xref
913-
@test_logs (
914-
:warn,
915-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
916-
) xref > 0
917-
@test_logs (
918-
:warn,
919-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
920-
) 0 < xref
921-
@test_logs (
922-
:warn,
923-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
924-
) "something" == xref
925-
@test_logs (
926-
:warn,
927-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
928-
) 10 > xref
929-
@test_logs (
930-
:warn,
931-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
932-
) xref < 10
933-
@test_logs (
934-
:warn,
935-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
936-
) 0 <= xref
937-
@test_logs (
938-
:warn,
939-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
940-
) xref >= 0
941-
@test_logs (
942-
:warn,
943-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
944-
) xref <= 0
945-
@test_logs (
946-
:warn,
947-
"Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time."
948-
) 0 >= xref
873+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." xref !=
874+
1
875+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." 1 !=
876+
xref
877+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." xref ==
878+
1
879+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." 1 ==
880+
xref
881+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." xref >
882+
0
883+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." 0 <
884+
xref
885+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." "something" ==
886+
xref
887+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." 10 >
888+
xref
889+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." xref <
890+
10
891+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." 0 <=
892+
xref
893+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." xref >=
894+
0
895+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." xref <=
896+
0
897+
@test_throws "Comparing Factor Graph variable `x[1,2]` with a value. This is not possible as the value of `x[1,2]` is not known at model construction time." 0 >=
898+
xref
949899
end
950900

951901
@testitem "NodeLabel properties" begin

0 commit comments

Comments
 (0)