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)
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))
def test_assert_equal_unknown_container(): value = torch.tensor(0) st = {value} with pytest.raises(RuntimeError): ptu.assert_equal(st, copy(st))
def test_assert_equal_type_mismatch_tensor(): tensor1 = torch.tensor(0) tensor2 = np.array(0) with pytest.raises(AssertionError): ptu.assert_equal(tensor1, tensor2)
def test_assert_equal_tensor_dict(): dct = {"0": torch.tensor(0), "1": torch.tensor(1)} ptu.assert_equal(dct, copy(dct))
def test_assert_equal_tensor_seq(): seq = (torch.tensor(0), torch.tensor(1)) ptu.assert_equal(seq, copy(seq))
def test_assert_equal_tensor(): tensor = torch.tensor(0) ptu.assert_equal(tensor, tensor.clone())