def _assert_triangular(distances):
    """Ensure that matrix is left-triangular at least.
    """
    for i, row in enumerate(distances):
        if len(row) < i:
            raise ValueError(
                'Distance matrix must be left-triangular at least. Row {row} must have at least {i} items'
                .format(**locals()))
