提交 3800f5cf authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Add missing DeprecationWarnings and catch them in tests

上级 88d68ac4
...@@ -692,9 +692,10 @@ def guess_n_streams(size, warn=False): ...@@ -692,9 +692,10 @@ def guess_n_streams(size, warn=False):
if warn: if warn:
warnings.warn( warnings.warn(
( (
"MRG_RandomStream Can't determine #streams " "MRG_RandomStream can't determine the number ofstreams "
f"from size ({size}), guessing 60*256" f"from size ({size}), guessing 60*256"
), ),
DeprecationWarning,
stacklevel=3, stacklevel=3,
) )
return 60 * 256 return 60 * 256
...@@ -1106,9 +1107,10 @@ class MRG_RandomStream: ...@@ -1106,9 +1107,10 @@ class MRG_RandomStream:
**kwargs, **kwargs,
): ):
warnings.warn( warnings.warn(
"MRG_RandomStream.multinomial_wo_replacement() is " "MRG_RandomStream.multinomial_wo_replacement is "
"deprecated and will be removed in the next release of " "deprecated and will be removed in the next release of "
"Aesara. Please use MRG_RandomStream.choice() instead." "Aesara. Please use MRG_RandomStream.choice instead.",
DeprecationWarning,
) )
assert size is None assert size is None
return self.choice( return self.choice(
......
...@@ -107,7 +107,8 @@ def conv2d( ...@@ -107,7 +107,8 @@ def conv2d(
warnings.warn( warnings.warn(
"aesara.tensor.nnet.conv.conv2d is deprecated." "aesara.tensor.nnet.conv.conv2d is deprecated."
" Use aesara.tensor.nnet.conv2d instead." " Use aesara.tensor.nnet.conv2d instead.",
DeprecationWarning,
) )
# accept Constant value for image_shape and filter_shape. # accept Constant value for image_shape and filter_shape.
...@@ -406,6 +407,7 @@ class ConvOp(OpenMPOp): ...@@ -406,6 +407,7 @@ class ConvOp(OpenMPOp):
warnings.warn( warnings.warn(
"The method `getOutputShape` is deprecated use" "The method `getOutputShape` is deprecated use"
"`get_conv_output_shape` instead.", "`get_conv_output_shape` instead.",
DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
return tuple( return tuple(
......
...@@ -152,6 +152,7 @@ class TestFunction: ...@@ -152,6 +152,7 @@ class TestFunction:
p = fmatrix() p = fmatrix()
n = iscalar() n = iscalar()
with pytest.warns(DeprecationWarning):
m = th_rng.multinomial_wo_replacement(pvals=p, n=n) m = th_rng.multinomial_wo_replacement(pvals=p, n=n)
f = function([p, n], m, allow_input_downcast=True) f = function([p, n], m, allow_input_downcast=True)
...@@ -175,6 +176,7 @@ class TestFunction: ...@@ -175,6 +176,7 @@ class TestFunction:
p = fmatrix() p = fmatrix()
n = iscalar() n = iscalar()
with pytest.warns(DeprecationWarning):
m = th_rng.multinomial_wo_replacement(pvals=p, n=n) m = th_rng.multinomial_wo_replacement(pvals=p, n=n)
f = function([p, n], m, allow_input_downcast=True) f = function([p, n], m, allow_input_downcast=True)
......
...@@ -85,6 +85,7 @@ class TestConv2D(utt.InferShapeTester): ...@@ -85,6 +85,7 @@ class TestConv2D(utt.InferShapeTester):
# define aesara graph and function # define aesara graph and function
input.name = "input" input.name = "input"
filters.name = "filters" filters.name = "filters"
with pytest.warns(DeprecationWarning):
rval = conv.conv2d( rval = conv.conv2d(
input, input,
filters, filters,
...@@ -600,7 +601,8 @@ class TestConv2D(utt.InferShapeTester): ...@@ -600,7 +601,8 @@ class TestConv2D(utt.InferShapeTester):
input = aesara.shared(np.random.random(image_shape)) input = aesara.shared(np.random.random(image_shape))
filters = aesara.shared(np.random.random(filter_shape)) filters = aesara.shared(np.random.random(filter_shape))
output = self.conv2d( with pytest.warns(DeprecationWarning):
output = conv.conv2d(
input, input,
filters, filters,
image_shape, image_shape,
...@@ -635,17 +637,23 @@ class TestConv2D(utt.InferShapeTester): ...@@ -635,17 +637,23 @@ class TestConv2D(utt.InferShapeTester):
bivec_val = [7, 5, 3, 2] bivec_val = [7, 5, 3, 2]
adtens_val = rand(*aivec_val) adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val) bdtens_val = rand(*bivec_val)
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
) )
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
...@@ -655,17 +663,23 @@ class TestConv2D(utt.InferShapeTester): ...@@ -655,17 +663,23 @@ class TestConv2D(utt.InferShapeTester):
bivec_val = [4, 2, 5, 3] bivec_val = [4, 2, 5, 3]
adtens_val = rand(*aivec_val) adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val) bdtens_val = rand(*bivec_val)
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
) )
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
...@@ -675,17 +689,23 @@ class TestConv2D(utt.InferShapeTester): ...@@ -675,17 +689,23 @@ class TestConv2D(utt.InferShapeTester):
bivec_val = [5, 6, 3, 2] bivec_val = [5, 6, 3, 2]
adtens_val = rand(*aivec_val) adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val) bdtens_val = rand(*bivec_val)
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
) )
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
...@@ -695,17 +715,23 @@ class TestConv2D(utt.InferShapeTester): ...@@ -695,17 +715,23 @@ class TestConv2D(utt.InferShapeTester):
bivec_val = [5, 6, 2, 3] bivec_val = [5, 6, 2, 3]
adtens_val = rand(*aivec_val) adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val) bdtens_val = rand(*bivec_val)
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
) )
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
...@@ -715,17 +741,23 @@ class TestConv2D(utt.InferShapeTester): ...@@ -715,17 +741,23 @@ class TestConv2D(utt.InferShapeTester):
bivec_val = [6, 2, 4, 3] bivec_val = [6, 2, 4, 3]
adtens_val = rand(*aivec_val) adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val) bdtens_val = rand(*bivec_val)
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
) )
with pytest.warns(DeprecationWarning):
self._compile_and_check( self._compile_and_check(
[adtens, bdtens], [adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val], [adtens_val, bdtens_val],
conv.ConvOp, conv.ConvOp,
excluding=["conv_gemm"], excluding=["conv_gemm"],
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论