@@ -31,10 +31,13 @@ def setUp(self):
3131 """Create fake models which act like models but are actually much simpler."""
3232 # Fake model which solves to be a uniform distribution
3333 class FakeUniformModel (ddm .Model ):
34+ def __init__ (self , * args , p_undecided = .2 , ** kwargs ):
35+ self .p_undecided = p_undecided
36+ return super ().__init__ (* args , ** kwargs )
3437 def solve (self , conditions = {}, * args , ** kwargs ):
35- choice_upper = self .t_domain ()* 0 + .4 / len (self .t_domain ())
36- choice_lower = self .t_domain ()* 0 + .4 / len (self .t_domain ())
37- undec = self .x_domain (conditions = conditions )* 0 + .2 / len (self .x_domain (conditions = conditions ))
38+ choice_upper = self .t_domain ()* 0 + ( 1 - self . p_undecided ) / 2 / len (self .t_domain ())
39+ choice_lower = self .t_domain ()* 0 + ( 1 - self . p_undecided ) / 2 / len (self .t_domain ())
40+ undec = self .x_domain (conditions = conditions )* 0 + self . p_undecided / len (self .x_domain (conditions = conditions ))
3841 return ddm .Solution (choice_upper , choice_lower , self , conditions , undec )
3942 FakeUniformModel .solve_analytical = FakeUniformModel .solve
4043 FakeUniformModel .solve_numerical = FakeUniformModel .solve
@@ -213,14 +216,9 @@ def test_OverlayUniformMixture(self):
213216 s = ddm .Model (drift = ddm .models .DriftConstant (drift = 2 ), noise = ddm .models .NoiseConstant (noise = 3 )).solve ()
214217 smix = ddm .models .OverlayUniformMixture (umixturecoef = 1 ).apply (s )
215218 assert np .isclose (np .sum (smix .choice_upper ) + np .sum (smix .choice_lower ), 1 , atol = 1e-4 )
216- # Should not change uniform distribution
217- s = self .FakeUniformModel (dt = .001 ).solve ()
219+ # Should not change uniform distribution if no undecideds
220+ s = self .FakeUniformModel (p_undecided = 0 , dt = .001 ).solve ()
218221 assert s == ddm .models .OverlayUniformMixture (umixturecoef = .2 ).apply (s )
219- # Don't change total probability
220- s = ddm .Model (drift = ddm .models .DriftConstant (drift = 1 )).solve ()
221- smix = ddm .models .OverlayUniformMixture (umixturecoef = .2 ).apply (s )
222- assert np .isclose (np .sum (s .choice_upper ) + np .sum (s .choice_lower ),
223- np .sum (smix .choice_upper ) + np .sum (smix .choice_lower ))
224222
225223 def test_OverlayPoissonMixture (self ):
226224 """Poisson mixture model overlay: an exponential distribution plus the model's solved distribution"""
0 commit comments