@@ -67,7 +67,8 @@ def perform(self, node, inputs, outputs):
67
67
68
68
test_input = SomeType ()()
69
69
orig_object = object ()
70
- test_input .tag .test_value = orig_object
70
+ with pytest .warns (FutureWarning ):
71
+ test_input .tag .test_value = orig_object
71
72
72
73
res = InplaceOp (False )(test_input )
73
74
assert res .tag .test_value is orig_object
@@ -76,10 +77,11 @@ def perform(self, node, inputs, outputs):
76
77
assert res .tag .test_value is not orig_object
77
78
78
79
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 )
83
85
84
86
# should work
85
87
z = dot (x , y )
@@ -88,14 +90,16 @@ def test_variable_only(self):
88
90
assert _allclose (f (x .tag .test_value , y .tag .test_value ), z .tag .test_value )
89
91
90
92
# 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 )
92
95
with pytest .raises (ValueError ):
93
96
dot (x , y )
94
97
95
98
def test_compute_flag (self ):
96
99
x = matrix ("x" )
97
100
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 )
99
103
100
104
# should skip computation of test value
101
105
with config .change_flags (compute_test_value = "off" ):
@@ -111,10 +115,11 @@ def test_compute_flag(self):
111
115
dot (x , y )
112
116
113
117
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 )
118
123
119
124
z = pytensor .shared (np .random .random ((5 , 6 )).astype (config .floatX ))
120
125
@@ -134,7 +139,8 @@ def f(x, y, z):
134
139
135
140
def test_shared (self ):
136
141
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 )
138
144
y = pytensor .shared (np .random .random ((4 , 6 )).astype (config .floatX ), "y" )
139
145
140
146
# should work
@@ -190,30 +196,31 @@ def test_constant(self):
190
196
def test_incorrect_type (self ):
191
197
x = vector ("x" )
192
198
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 ))
195
202
196
203
x = fmatrix ("x" )
197
204
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 ))
200
208
201
209
def test_overided_function (self ):
202
210
# We need to test those as they mess with Exception
203
211
# And we don't want the exception to be changed.
204
212
x = matrix ()
205
- x .tag .test_value = np .zeros ((2 , 3 ), dtype = config .floatX )
206
213
y = matrix ()
207
- y .tag .test_value = np .zeros ((2 , 2 ), dtype = config .floatX )
208
214
with pytest .raises (ValueError ):
209
215
x .__mul__ (y )
210
216
211
217
def test_scan (self ):
212
218
# Test the compute_test_value mechanism Scan.
213
219
k = iscalar ("k" )
214
220
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 )
217
224
218
225
def fx (prior_result , A ):
219
226
return prior_result * A
@@ -233,8 +240,9 @@ def test_scan_err1(self):
233
240
# This test should fail when building fx for the first time
234
241
k = iscalar ("k" )
235
242
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 )
238
246
239
247
def fx (prior_result , A ):
240
248
return dot (prior_result , A )
@@ -253,8 +261,9 @@ def test_scan_err2(self):
253
261
# but when calling the scan's perform()
254
262
k = iscalar ("k" )
255
263
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 )
258
267
259
268
def fx (prior_result , A ):
260
269
return dot (prior_result , A )
@@ -288,7 +297,8 @@ def perform(self, node, inputs, outputs):
288
297
output [0 ] = input + 1
289
298
290
299
i = ps .int32 ("i" )
291
- i .tag .test_value = 3
300
+ with pytest .warns (FutureWarning ):
301
+ i .tag .test_value = 3
292
302
293
303
o = IncOnePython ()(i )
294
304
@@ -304,7 +314,8 @@ def perform(self, node, inputs, outputs):
304
314
)
305
315
def test_no_perform (self ):
306
316
i = ps .int32 ("i" )
307
- i .tag .test_value = 3
317
+ with pytest .warns (FutureWarning ):
318
+ i .tag .test_value = 3
308
319
309
320
# Class IncOneC is defined outside of the TestComputeTestValue
310
321
# so it can be pickled and unpickled
0 commit comments