@@ -67,7 +67,8 @@ def perform(self, node, inputs, outputs):
6767
6868 test_input = SomeType ()()
6969 orig_object = object ()
70- test_input .tag .test_value = orig_object
70+ with pytest .warns (FutureWarning ):
71+ test_input .tag .test_value = orig_object
7172
7273 res = InplaceOp (False )(test_input )
7374 assert res .tag .test_value is orig_object
@@ -76,10 +77,11 @@ def perform(self, node, inputs, outputs):
7677 assert res .tag .test_value is not orig_object
7778
7879 def test_variable_only (self ):
79- x = matrix ("x" )
80- x .tag .test_value = np .random .random ((3 , 4 )).astype (config .floatX )
81- y = matrix ("y" )
82- y .tag .test_value = np .random .random ((4 , 5 )).astype (config .floatX )
80+ with pytest .warns (FutureWarning ):
81+ x = matrix ("x" )
82+ x .tag .test_value = np .random .random ((3 , 4 )).astype (config .floatX )
83+ y = matrix ("y" )
84+ y .tag .test_value = np .random .random ((4 , 5 )).astype (config .floatX )
8385
8486 # should work
8587 z = dot (x , y )
@@ -88,14 +90,16 @@ def test_variable_only(self):
8890 assert _allclose (f (x .tag .test_value , y .tag .test_value ), z .tag .test_value )
8991
9092 # this test should fail
91- y .tag .test_value = np .random .random ((6 , 5 )).astype (config .floatX )
93+ with pytest .warns (FutureWarning ):
94+ y .tag .test_value = np .random .random ((6 , 5 )).astype (config .floatX )
9295 with pytest .raises (ValueError ):
9396 dot (x , y )
9497
9598 def test_compute_flag (self ):
9699 x = matrix ("x" )
97100 y = matrix ("y" )
98- y .tag .test_value = np .random .random ((4 , 5 )).astype (config .floatX )
101+ with pytest .warns (FutureWarning ):
102+ y .tag .test_value = np .random .random ((4 , 5 )).astype (config .floatX )
99103
100104 # should skip computation of test value
101105 with config .change_flags (compute_test_value = "off" ):
@@ -111,10 +115,11 @@ def test_compute_flag(self):
111115 dot (x , y )
112116
113117 def test_string_var (self ):
114- x = matrix ("x" )
115- x .tag .test_value = np .random .random ((3 , 4 )).astype (config .floatX )
116- y = matrix ("y" )
117- y .tag .test_value = np .random .random ((4 , 5 )).astype (config .floatX )
118+ with pytest .warns (FutureWarning ):
119+ x = matrix ("x" )
120+ x .tag .test_value = np .random .random ((3 , 4 )).astype (config .floatX )
121+ y = matrix ("y" )
122+ y .tag .test_value = np .random .random ((4 , 5 )).astype (config .floatX )
118123
119124 z = pytensor .shared (np .random .random ((5 , 6 )).astype (config .floatX ))
120125
@@ -134,7 +139,8 @@ def f(x, y, z):
134139
135140 def test_shared (self ):
136141 x = matrix ("x" )
137- x .tag .test_value = np .random .random ((3 , 4 )).astype (config .floatX )
142+ with pytest .warns (FutureWarning ):
143+ x .tag .test_value = np .random .random ((3 , 4 )).astype (config .floatX )
138144 y = pytensor .shared (np .random .random ((4 , 6 )).astype (config .floatX ), "y" )
139145
140146 # should work
@@ -190,30 +196,31 @@ def test_constant(self):
190196 def test_incorrect_type (self ):
191197 x = vector ("x" )
192198 with pytest .raises (TypeError ):
193- # Incorrect shape for test value
194- x .tag .test_value = np .empty ((2 , 2 ))
199+ with pytest .warns (FutureWarning ):
200+ # Incorrect shape for test value
201+ x .tag .test_value = np .empty ((2 , 2 ))
195202
196203 x = fmatrix ("x" )
197204 with pytest .raises (TypeError ):
198- # Incorrect dtype (float64) for test value
199- x .tag .test_value = np .random .random ((3 , 4 ))
205+ with pytest .warns (FutureWarning ):
206+ # Incorrect dtype (float64) for test value
207+ x .tag .test_value = np .random .random ((3 , 4 ))
200208
201209 def test_overided_function (self ):
202210 # We need to test those as they mess with Exception
203211 # And we don't want the exception to be changed.
204212 x = matrix ()
205- x .tag .test_value = np .zeros ((2 , 3 ), dtype = config .floatX )
206213 y = matrix ()
207- y .tag .test_value = np .zeros ((2 , 2 ), dtype = config .floatX )
208214 with pytest .raises (ValueError ):
209215 x .__mul__ (y )
210216
211217 def test_scan (self ):
212218 # Test the compute_test_value mechanism Scan.
213219 k = iscalar ("k" )
214220 A = vector ("A" )
215- k .tag .test_value = 3
216- A .tag .test_value = np .random .random ((5 ,)).astype (config .floatX )
221+ with pytest .warns (FutureWarning ):
222+ k .tag .test_value = 3
223+ A .tag .test_value = np .random .random ((5 ,)).astype (config .floatX )
217224
218225 def fx (prior_result , A ):
219226 return prior_result * A
@@ -233,8 +240,9 @@ def test_scan_err1(self):
233240 # This test should fail when building fx for the first time
234241 k = iscalar ("k" )
235242 A = matrix ("A" )
236- k .tag .test_value = 3
237- A .tag .test_value = np .random .random ((5 , 3 )).astype (config .floatX )
243+ with pytest .warns (FutureWarning ):
244+ k .tag .test_value = 3
245+ A .tag .test_value = np .random .random ((5 , 3 )).astype (config .floatX )
238246
239247 def fx (prior_result , A ):
240248 return dot (prior_result , A )
@@ -253,8 +261,9 @@ def test_scan_err2(self):
253261 # but when calling the scan's perform()
254262 k = iscalar ("k" )
255263 A = matrix ("A" )
256- k .tag .test_value = 3
257- A .tag .test_value = np .random .random ((5 , 3 )).astype (config .floatX )
264+ with pytest .warns (FutureWarning ):
265+ k .tag .test_value = 3
266+ A .tag .test_value = np .random .random ((5 , 3 )).astype (config .floatX )
258267
259268 def fx (prior_result , A ):
260269 return dot (prior_result , A )
@@ -288,7 +297,8 @@ def perform(self, node, inputs, outputs):
288297 output [0 ] = input + 1
289298
290299 i = ps .int32 ("i" )
291- i .tag .test_value = 3
300+ with pytest .warns (FutureWarning ):
301+ i .tag .test_value = 3
292302
293303 o = IncOnePython ()(i )
294304
@@ -304,7 +314,8 @@ def perform(self, node, inputs, outputs):
304314 )
305315 def test_no_perform (self ):
306316 i = ps .int32 ("i" )
307- i .tag .test_value = 3
317+ with pytest .warns (FutureWarning ):
318+ i .tag .test_value = 3
308319
309320 # Class IncOneC is defined outside of the TestComputeTestValue
310321 # so it can be pickled and unpickled
0 commit comments