def cancelPZ(arg1, tol=1e-6):
    """Cancel zeros/poles in a SISO transfer function.

    **Parameters:**

    arg1 : LTI system description
        Multiple descriptions are supported for the LTI system.

        If one argument is used, it is a scipy ``lti`` object.

        If more arguments are used, they should be arranged in a tuple, the
        following gives the number of elements in the tuple and their
        interpretation:

        * 2: (numerator, denominator)
        * 3: (zeros, poles, gain)
        * 4: (A, B, C, D)

        Each argument can be an array or sequence.

    tol : float, optional
        the absolute tolerance for pole, zero cancellation. Defaults to 1e-6.

    **Returns:**

    (z, p, k) : tuple
        A tuple containing zeros, poles and gain (unchanged) after poles, zeros 
        cancellation.

    """
    if not isinstance(arg1, lti):
        arg1 = lti(*arg1)
    z = copy.copy(arg1.zeros)
    p = copy.copy(arg1.poles)
    k = arg1.gain
    for i in range(max(z.shape) - 1, -1, -1):
        d = z[i] - p
        cancel = np.nonzero(tol < np.abs(d))[0]
        if cancel.size:
            p = np.delete(p, cancel[0])
            z = np.delete(z, i)
    return z, p, k
dataset/ETHPy150Open ggventurini/python-deltasigma/deltasigma/_cancelPZ.py/cancelPZ/swapped operands of `<`