def to_list(a, diag_val=None):
    """ Convert array to list of lists
       More or less np .tolist() method but can set diag values as a convenience
    """
    ll = a.tolist()
    n = len(ll[0])
    if diag_val is not None:
        for i in range(n):
            ll[i][i] = diag_val
    return ll