提交 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):
if warn:
warnings.warn(
(
"MRG_RandomStream Can't determine #streams "
"MRG_RandomStream can't determine the number ofstreams "
f"from size ({size}), guessing 60*256"
),
DeprecationWarning,
stacklevel=3,
)
return 60 * 256
......@@ -1106,9 +1107,10 @@ class MRG_RandomStream:
**kwargs,
):
warnings.warn(
"MRG_RandomStream.multinomial_wo_replacement() is "
"MRG_RandomStream.multinomial_wo_replacement is "
"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
return self.choice(
......
......@@ -107,7 +107,8 @@ def conv2d(
warnings.warn(
"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.
......@@ -406,6 +407,7 @@ class ConvOp(OpenMPOp):
warnings.warn(
"The method `getOutputShape` is deprecated use"
"`get_conv_output_shape` instead.",
DeprecationWarning,
stacklevel=2,
)
return tuple(
......
......@@ -152,7 +152,8 @@ class TestFunction:
p = fmatrix()
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)
......@@ -175,7 +176,8 @@ class TestFunction:
p = fmatrix()
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)
......
......@@ -85,17 +85,18 @@ class TestConv2D(utt.InferShapeTester):
# define aesara graph and function
input.name = "input"
filters.name = "filters"
rval = conv.conv2d(
input,
filters,
image_shape,
filter_shape,
border_mode,
subsample,
unroll_batch=unroll_batch,
unroll_kern=unroll_kern,
unroll_patch=unroll_patch,
)
with pytest.warns(DeprecationWarning):
rval = conv.conv2d(
input,
filters,
image_shape,
filter_shape,
border_mode,
subsample,
unroll_batch=unroll_batch,
unroll_kern=unroll_kern,
unroll_patch=unroll_patch,
)
rval.name = "conv_output"
return rval
......@@ -600,15 +601,16 @@ class TestConv2D(utt.InferShapeTester):
input = aesara.shared(np.random.random(image_shape))
filters = aesara.shared(np.random.random(filter_shape))
output = self.conv2d(
input,
filters,
image_shape,
filter_shape,
border_mode,
unroll_patch=True,
openmp=openmp,
)
with pytest.warns(DeprecationWarning):
output = conv.conv2d(
input,
filters,
image_shape,
filter_shape,
border_mode,
unroll_patch=True,
openmp=openmp,
)
mode = Mode(
linker=aesara.link.vm.VMLinker(
allow_gc=False, use_cloop=True
......@@ -635,101 +637,131 @@ class TestConv2D(utt.InferShapeTester):
bivec_val = [7, 5, 3, 2]
adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
aivec_val = [6, 2, 8, 3]
bivec_val = [4, 2, 5, 3]
adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
aivec_val = [3, 6, 7, 5]
bivec_val = [5, 6, 3, 2]
adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
aivec_val = [3, 6, 7, 5]
bivec_val = [5, 6, 2, 3]
adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
aivec_val = [5, 2, 4, 3]
bivec_val = [6, 2, 4, 3]
adtens_val = rand(*aivec_val)
bdtens_val = rand(*bivec_val)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="valid")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[
conv.conv2d(
adtens, bdtens, aivec_val, bivec_val, border_mode="valid"
)
],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
self._compile_and_check(
[adtens, bdtens],
[self.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
with pytest.warns(DeprecationWarning):
self._compile_and_check(
[adtens, bdtens],
[conv.conv2d(adtens, bdtens, aivec_val, bivec_val, border_mode="full")],
[adtens_val, bdtens_val],
conv.ConvOp,
excluding=["conv_gemm"],
)
# Test that broadcasting of gradients works correctly when using the
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论