Esempio n. 1
0
def test_assert_equal_type_mismatch_dict():
    value = torch.tensor(0)
    dct1 = {"0": value}
    dct2 = OrderedDict((("0", value), ))

    with pytest.raises(AssertionError):
        ptu.assert_equal(dct1, dct2)
Esempio n. 2
0
def test_assert_equal_type_mismatch_seq():
    value = torch.tensor(0)
    seq1 = (value, )
    seq2 = [value]

    with pytest.raises(AssertionError):
        ptu.assert_equal(seq1, seq2)
def test_assert_tensor_dict_equal_ordered_dict():
    dct = OrderedDict((("0", torch.tensor(0)), ("1", torch.tensor(1))))
    ptu.assert_equal(dct, copy(dct))
Esempio n. 4
0
def test_assert_equal_unknown_container():
    value = torch.tensor(0)
    st = {value}

    with pytest.raises(RuntimeError):
        ptu.assert_equal(st, copy(st))
Esempio n. 5
0
def test_assert_equal_type_mismatch_tensor():
    tensor1 = torch.tensor(0)
    tensor2 = np.array(0)

    with pytest.raises(AssertionError):
        ptu.assert_equal(tensor1, tensor2)
Esempio n. 6
0
def test_assert_equal_tensor_dict():
    dct = {"0": torch.tensor(0), "1": torch.tensor(1)}
    ptu.assert_equal(dct, copy(dct))
Esempio n. 7
0
def test_assert_equal_tensor_seq():
    seq = (torch.tensor(0), torch.tensor(1))
    ptu.assert_equal(seq, copy(seq))
Esempio n. 8
0
def test_assert_equal_tensor():
    tensor = torch.tensor(0)
    ptu.assert_equal(tensor, tensor.clone())