Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to test against new chainerx.GradientError #5787

Merged
merged 1 commit into from Dec 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions tests/chainerx_tests/unit_tests/test_array.py
Expand Up @@ -525,14 +525,13 @@ def test_array_require_grad_multiple_graphs_forward():


@pytest.mark.parametrize(
'expected_error,invalid_shape,invalid_dtype,invalid_device',
'invalid_shape,invalid_dtype,invalid_device',
[
(chainerx.DtypeError, None, chainerx.float32, None),
(chainerx.DimensionError, (2, 1), None, None),
(chainerx.DeviceError, None, None, 'native:1'),
(None, chainerx.float32, None),
((2, 1), None, None),
(None, None, 'native:1'),
])
def test_array_grad_invalid_grad(
expected_error, invalid_shape, invalid_dtype, invalid_device):
def test_array_grad_invalid_grad(invalid_shape, invalid_dtype, invalid_device):
shape = (3, 1)
dtype = chainerx.float64
device = 'native:0'
Expand All @@ -546,9 +545,9 @@ def test_array_grad_invalid_grad(
invalid_grad = chainerx.ones(
grad_shape, grad_dtype, device=grad_device)

with pytest.raises(expected_error):
with pytest.raises(chainerx.GradientError):
array.set_grad(invalid_grad)
with pytest.raises(expected_error):
with pytest.raises(chainerx.GradientError):
array.grad = invalid_grad


Expand Down