mples, the input is not a valid distance matrix.

Not square:

>>> is_valid_dm([[0, 2, 2], [2, 0, 2]])
False

Nonzero diagonal element:

>>> is_valid_dm([[0, 1, 1], [1, 2, 3], [1, 3, 0]])
False

Not symmetric:

>>> is_valid_dm([[0, 1, 3], [2, 0, 1], [3, 1, 0]])
False

r•