def METHOD_NAME(radius, p, circular=False):
    """Create square matrix of inverse distance weights
    The weights are normalized (sum to 1) and are flattened as a list
    Parameters
    ----------
    radius : int
        Radius of the square matrix in cells.
    p : float
        Distance weighting power. p=0 gives equal weights.
    circular : bool (opt). Default is False
        Optionally use a circular mask.
    Returns
    -------
    W : list
        Returns a square matrix of weights that excludes the centre cell, or
        other cells if a circular mask is used. The matrix is flattened and
        returned as a list.
    """
    size = radius * 2 + 1
    centre = int(size / 2)
    # create distance matrix
    dist = distance_from_centre(radius)
    # create inverse distance weights
    W = dist.copy()
    W[centre, centre] = np.inf
    W = 1 / (W**p)
    # normalize weights to sum to 1 (excluding centre)
    W[centre, centre] = np.inf
    W = W / W[np.isfinite(W)].sum()
    # circular mask
    if circular:
        mask = dist <= radius
    else:
        mask = np.isfinite(W)
    mask[centre, centre] = False
    return list(W[mask])