提交 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,7 +152,8 @@ class TestFunction: ...@@ -152,7 +152,8 @@ class TestFunction:
p = fmatrix() p = fmatrix()
n = iscalar() n = iscalar()
m = th_rng.multinomial_wo_replacement(pvals=p, n=n) with pytest.warns(DeprecationWarning):
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,7 +176,8 @@ class TestFunction: ...@@ -175,7 +176,8 @@ class TestFunction:
p = fmatrix() p = fmatrix()
n = iscalar() n = iscalar()
m = th_rng.multinomial_wo_replacement(pvals=p, n=n) with pytest.warns(DeprecationWarning):
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,17 +85,18 @@ class TestConv2D(utt.InferShapeTester): ...@@ -85,17 +85,18 @@ 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"
rval = conv.conv2d( with pytest.warns(DeprecationWarning):
input, rval = conv.conv2d(
filters, input,
image_shape, filters,
filter_shape, image_shape,
border_mode, filter_shape,
subsample, border_mode,
unroll_batch=unroll_batch, subsample,
unroll_kern=unroll_kern, unroll_batch=unroll_batch,
unroll_patch=unroll_patch, unroll_kern=unroll_kern,
) unroll_patch=unroll_patch,
)
rval.name = "conv_output" rval.name = "conv_output"
return rval return rval
...@@ -600,15 +601,16 @@ class TestConv2D(utt.InferShapeTester): ...@@ -600,15 +601,16 @@ 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):
input, output = conv.conv2d(
filters, input,
image_shape, filters,
filter_shape, image_shape,
border_mode, filter_shape,
unroll_patch=True, border_mode,
openmp=openmp, unroll_patch=True,
) openmp=openmp,
)
mode = Mode( mode = Mode(
linker=aesara.link.vm.VMLinker( linker=aesara.link.vm.VMLinker(
allow_gc=False, use_cloop=True allow_gc=False, use_cloop=True
...@@ -635,101 +637,131 @@ class TestConv2D(utt.InferShapeTester): ...@@ -635,101 +637,131 @@ 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)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [adtens, bdtens],
[adtens_val, bdtens_val], [
conv.ConvOp, conv.conv2d(
excluding=["conv_gemm"], adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
) )
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [adtens, bdtens],
[adtens_val, bdtens_val], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
conv.ConvOp, [adtens_val, bdtens_val],
excluding=["conv_gemm"], conv.ConvOp,
) excluding=["conv_gemm"],
)
aivec_val = [6, 2, 8, 3] aivec_val = [6, 2, 8, 3]
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)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [adtens, bdtens],
[adtens_val, bdtens_val], [
conv.ConvOp, conv.conv2d(
excluding=["conv_gemm"], adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
) )
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [adtens, bdtens],
[adtens_val, bdtens_val], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
conv.ConvOp, [adtens_val, bdtens_val],
excluding=["conv_gemm"], conv.ConvOp,
) excluding=["conv_gemm"],
)
aivec_val = [3, 6, 7, 5] aivec_val = [3, 6, 7, 5]
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)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [adtens, bdtens],
[adtens_val, bdtens_val], [
conv.ConvOp, conv.conv2d(
excluding=["conv_gemm"], adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
) )
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [adtens, bdtens],
[adtens_val, bdtens_val], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
conv.ConvOp, [adtens_val, bdtens_val],
excluding=["conv_gemm"], conv.ConvOp,
) excluding=["conv_gemm"],
)
aivec_val = [3, 6, 7, 5] aivec_val = [3, 6, 7, 5]
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)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [adtens, bdtens],
[adtens_val, bdtens_val], [
conv.ConvOp, conv.conv2d(
excluding=["conv_gemm"], adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
) )
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [adtens, bdtens],
[adtens_val, bdtens_val], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
conv.ConvOp, [adtens_val, bdtens_val],
excluding=["conv_gemm"], conv.ConvOp,
) excluding=["conv_gemm"],
)
aivec_val = [5, 2, 4, 3] aivec_val = [5, 2, 4, 3]
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)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")], [adtens, bdtens],
[adtens_val, bdtens_val], [
conv.ConvOp, conv.conv2d(
excluding=["conv_gemm"], adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
) )
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check( with pytest.warns(DeprecationWarning):
[adtens, bdtens], self._compile_and_check(
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")], [adtens, bdtens],
[adtens_val, bdtens_val], [conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
conv.ConvOp, [adtens_val, bdtens_val],
excluding=["conv_gemm"], conv.ConvOp,
) excluding=["conv_gemm"],
)
# Test that broadcasting of gradients works correctly when using the # Test that broadcasting of gradients works correctly when using the
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论