Skip to content

Commit

Permalink
Insert assert_warns
Browse files Browse the repository at this point in the history
  • Loading branch information
unnonouno committed Aug 15, 2017
1 parent 0698b2c commit 1dc2674
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/chainer_tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ def test_zerograds_multi_gpu(self):
cupy = cuda.cupy
with cuda.get_device_from_id(1):
a = chainer.Variable(cupy.empty(3, dtype=np.float32))
a.zerograd()
with testing.assert_warns(DeprecationWarning):
a.zerograd()
self.assertIsNot(a.grad, None)
self.assertEqual(int(a.grad.device), 1)
with cuda.get_device_from_id(1):
Expand All @@ -389,7 +390,8 @@ def test_zerograds_fill_multi_gpu(self):
with cuda.get_device_from_id(1):
a = chainer.Variable(cupy.empty(3, dtype=np.float32))
a.grad = cupy.empty_like(a.data)
a.zerograd()
with testing.assert_warns(DeprecationWarning):
a.zerograd()
self.assertEqual(int(a.grad.device), 1)
with cuda.get_device_from_id(1):
g_expect = cupy.zeros_like(a.data)
Expand Down Expand Up @@ -737,7 +739,8 @@ def test_zerograd(self):
@attr.gpu
def test_zerograd_to_gpu(self):
x = chainer.Parameter()
x.zerograd()
with testing.assert_warns(DeprecationWarning):
x.zerograd()
x.to_gpu()
x.initialize((3, 2))
self.check_zerograd(x, cuda.cupy)
Expand All @@ -746,7 +749,8 @@ def test_zerograd_to_gpu(self):
def test_to_gpu_zerograd(self):
x = chainer.Parameter()
x.to_gpu()
x.zerograd()
with testing.assert_warns(DeprecationWarning):
x.zerograd()
x.initialize((3, 2))
self.check_zerograd(x, cuda.cupy)

Expand Down

0 comments on commit 1dc2674

Please sign in to comment.