@@ -145,9 +145,29 @@ def test_density_dist_with_random(self, size):
145145 random = lambda mu , rng = None , size = None : rng .normal (loc = mu , scale = 1 , size = size ),
146146 observed = np .random .randn (100 , * size ),
147147 )
148-
149148 assert obs .eval ().shape == (100 ,) + size
150149
150+ def test_density_dist_with_random_invalid_observed (self ):
151+ with pytest .raises (
152+ TypeError ,
153+ match = (
154+ "Since ``v4.0.0`` the ``observed`` parameter should be of type"
155+ " ``pd.Series``, ``np.array``, or ``pm.Data``."
156+ " Previous versions allowed passing distribution parameters as"
157+ " a dictionary in ``observed``, in the current version these "
158+ "parameters are positional arguments."
159+ ),
160+ ):
161+ size = (3 ,)
162+ with pm .Model () as model :
163+ mu = pm .Normal ("mu" , 0 , 1 )
164+ pm .DensityDist (
165+ "density_dist" ,
166+ mu ,
167+ random = lambda mu , rng = None , size = None : rng .normal (loc = mu , scale = 1 , size = size ),
168+ observed = {"values" : np .random .randn (100 , * size )},
169+ )
170+
151171 def test_density_dist_without_random (self ):
152172 with pm .Model () as model :
153173 mu = pm .Normal ("mu" , 0 , 1 )
0 commit comments