コード例 #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)
コード例 #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)
コード例 #3
0
def test_assert_tensor_dict_equal_ordered_dict():
    dct = OrderedDict((("0", torch.tensor(0)), ("1", torch.tensor(1))))
    ptu.assert_equal(dct, copy(dct))
コード例 #4
0
def test_assert_equal_unknown_container():
    value = torch.tensor(0)
    st = {value}

    with pytest.raises(RuntimeError):
        ptu.assert_equal(st, copy(st))
コード例 #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)
コード例 #6
0
def test_assert_equal_tensor_dict():
    dct = {"0": torch.tensor(0), "1": torch.tensor(1)}
    ptu.assert_equal(dct, copy(dct))
コード例 #7
0
def test_assert_equal_tensor_seq():
    seq = (torch.tensor(0), torch.tensor(1))
    ptu.assert_equal(seq, copy(seq))
コード例 #8
0
def test_assert_equal_tensor():
    tensor = torch.tensor(0)
    ptu.assert_equal(tensor, tensor.clone())