'Return the first n nonzero terms of the series.
If n is None return an iterator.
Parameters
n : int or None
Amount of non-zero terms in approximation or None.
Returns
Expr or iterator
Approximation of function expanded into Fourier series.
Examples
>>> from sympy import fourier_series, pi
>>> from sympy.abc import x
>>> s = fourier_series(x, (x, -pi, pi))
>>> s.truncate(4)
2*sin(x) - sin(2*x) + 2*sin(3*x)/3 - sin(4*x)/2
See Also
sympy.series.fourier.FourierSeries.sigma_approximation'

def truncate(self, n=3):

    if (n is None):
        return iter(self)
    terms = []
    for t in self:
        if (len(terms) == n):
            break
        if (t is not S.Zero):
            terms.append(t)
    return Add(*terms)
