def METHOD_NAME(x, p, q):
    """Polyphase filter resample, based on MATLAB's resample.m"""
    bta = 5
    N = 10
    pqmax = max(p, q)
    fc = (1 / 2) / pqmax
    L = 2 * N * pqmax + 1
    h = p * scipy.signal.firwin(L - 1, 2 * fc, window=("kaiser", bta))
    Lhalf = (L - 1) / 2
    Lx = len(x)
    nz = int(math.floor(q - (Lhalf % q)))
    z = numpy.zeros(nz)  # noqa
    Lhalf += nz
    delay = math.floor(math.ceil(Lhalf) / q)
    nz1 = 0
    while math.ceil(((Lx - 1) * p + len(h) + nz1) / q) - delay < math.ceil(Lx * p / q):
        nz1 = nz1 + 1
    h = numpy.hstack([h, numpy.zeros(nz1)])
    y = upfirdn(x, h, p, q)
    Ly = math.ceil(Lx * p / q)
    y = y[int(delay) :]
    y = y[: int(Ly)]
    return y