change error type

pull/915/head
zhaojichen 5 years ago
parent f66f234517
commit 1af894e25f

@ -32,7 +32,7 @@ power = 0.5
class TestInputs:
def test_milestone1(self):
milestone1 = 1
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.piecewise_constant_lr(milestone1, learning_rates)
def test_milestone2(self):
@ -46,12 +46,12 @@ class TestInputs:
def test_learning_rates1(self):
lr = True
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.piecewise_constant_lr(milestone, lr)
def test_learning_rates2(self):
lr = [1, 2, 1]
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.piecewise_constant_lr(milestone, lr)
def test_learning_rate_type(self):
@ -158,7 +158,7 @@ class TestInputs:
def test_is_stair(self):
is_stair = 1
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.exponential_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, decay_epoch, is_stair)
def test_min_lr_type(self):
@ -183,12 +183,12 @@ class TestInputs:
def test_power(self):
power1 = True
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.polynomial_decay_lr(learning_rate, end_learning_rate, total_step, step_per_epoch, decay_epoch, power1)
def test_update_decay_epoch(self):
update_decay_epoch = 1
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.polynomial_decay_lr(learning_rate, end_learning_rate, total_step, step_per_epoch, decay_epoch,
power, update_decay_epoch)

@ -52,7 +52,7 @@ def test_psnr_max_val_negative():
def test_psnr_max_val_bool():
max_val = True
with pytest.raises(ValueError):
with pytest.raises(TypeError):
net = PSNRNet(max_val)
def test_psnr_max_val_zero():

@ -51,7 +51,7 @@ def test_ssim_max_val_negative():
def test_ssim_max_val_bool():
max_val = True
with pytest.raises(ValueError):
with pytest.raises(TypeError):
net = SSIMNet(max_val)
def test_ssim_max_val_zero():

@ -528,7 +528,7 @@ test_cases_for_verify_exception = [
'desc_inputs': [0],
}),
('MaxPoolWithArgmax_ValueError_2', {
'block': (lambda _: P.MaxPoolWithArgmax(ksize='1'), {'exception': ValueError}),
'block': (lambda _: P.MaxPoolWithArgmax(ksize='1'), {'exception': TypeError}),
'desc_inputs': [0],
}),
('MaxPoolWithArgmax_ValueError_3', {
@ -560,31 +560,31 @@ test_cases_for_verify_exception = [
'desc_inputs': [0],
}),
('Softmax_ValueError_1', {
'block': (lambda _: P.Softmax("1"), {'exception': ValueError}),
'block': (lambda _: P.Softmax("1"), {'exception': TypeError}),
'desc_inputs': [0],
}),
('Softmax_ValueError_2', {
'block': (lambda _: P.Softmax(1.1), {'exception': ValueError}),
'block': (lambda _: P.Softmax(1.1), {'exception': TypeError}),
'desc_inputs': [0],
}),
('Softmax_ValueError_3', {
'block': (lambda _: P.Softmax(axis="1"), {'exception': ValueError}),
'block': (lambda _: P.Softmax(axis="1"), {'exception': TypeError}),
'desc_inputs': [0],
}),
('DropoutGenMask_ValueError_1', {
'block': (lambda _: P.DropoutGenMask(Seed0="seed0"), {'exception': ValueError}),
'block': (lambda _: P.DropoutGenMask(Seed0="seed0"), {'exception': TypeError}),
'desc_inputs': [0],
}),
('DropoutGenMask_ValueError_2', {
'block': (lambda _: P.DropoutGenMask(Seed0=1.0), {'exception': ValueError}),
'block': (lambda _: P.DropoutGenMask(Seed0=1.0), {'exception': TypeError}),
'desc_inputs': [0],
}),
('DropoutGenMask_ValueError_3', {
'block': (lambda _: P.DropoutGenMask(Seed1="seed1"), {'exception': ValueError}),
'block': (lambda _: P.DropoutGenMask(Seed1="seed1"), {'exception': TypeError}),
'desc_inputs': [0],
}),
('DropoutGenMask_ValueError_4', {
'block': (lambda _: P.DropoutGenMask(Seed1=2.0), {'exception': ValueError}),
'block': (lambda _: P.DropoutGenMask(Seed1=2.0), {'exception': TypeError}),
'desc_inputs': [0],
}),
('MaxPool2d_ValueError_1', {
@ -594,14 +594,14 @@ test_cases_for_verify_exception = [
('MaxPool2d_ValueError_2', {
'block': (
lambda _: nn.MaxPool2d(kernel_size=120, stride=True, pad_mode="valid"),
{'exception': ValueError},
{'exception': TypeError},
),
'desc_inputs': [Tensor(np.random.randn(32, 3, 112, 112).astype(np.float32).transpose(0, 3, 1, 2))],
}),
('MaxPool2d_ValueError_3', {
'block': (
lambda _: nn.MaxPool2d(kernel_size=3, stride=True, pad_mode="valid"),
{'exception': ValueError},
{'exception': TypeError},
),
'desc_inputs': [Tensor(np.random.randn(32, 3, 112, 112).astype(np.float32).transpose(0, 3, 1, 2))],
}),

Loading…
Cancel
Save