@@ -1156,3 +1156,30 @@ def test_nested_ifelse():
1156
1156
np .testing .assert_almost_equal (mix_logp_fn (0 , test_value ), sp .norm .logpdf (test_value , - 5 , 1 ))
1157
1157
np .testing .assert_almost_equal (mix_logp_fn (1 , test_value ), sp .norm .logpdf (test_value , 0 , 1 ))
1158
1158
np .testing .assert_almost_equal (mix_logp_fn (2 , test_value ), sp .norm .logpdf (test_value , 5 , 1 ))
1159
+
1160
+
1161
+ def test_advanced_subtensor_none_and_integer ():
1162
+ """
1163
+ Test for correct error handling when the logp graph is over-specified.
1164
+
1165
+ Providing values for both a random variable ('a') and its deterministic
1166
+ child ('b') creates a logical conflict. The system should detect this
1167
+ and raise a controlled RuntimeError.
1168
+
1169
+ This test fails if the rewriter instead crashes with the old internal
1170
+ AttributeError bug, which would indicate a regression. Please see: #7762
1171
+ """
1172
+ a = pt .random .normal (0 , 1 , size = (10 ,), name = "a" )
1173
+ inds = np .array ([0 , 1 , 2 , 3 ], dtype = "int32" )
1174
+ b = a [None , inds ]
1175
+
1176
+ b_val = b .type ()
1177
+ b_val .name = "b_val"
1178
+ a_val = a .type ()
1179
+ a_val .name = "a_val"
1180
+
1181
+ with pytest .raises (
1182
+ RuntimeError ,
1183
+ match = "logprob terms of the following value variables could not be derived: {b_val}" ,
1184
+ ):
1185
+ conditional_logp ({b : b_val , a : a_val })
0 commit comments