(ctx, f, N)
return f_maxcalls_wrapped
Return a wrapped copy of *f* that raises ``NoConvergence`` when *f*
        has been called more than *N* times::

            >>> from sympy.mpmath import *
            >>> mp.dps = 15
            >>> f = maxcalls(sin, 10)
            >>> print(sum(f(n) for n in range(10)))
            1.95520948210738
            >>> f(10)
            Traceback (most recent call last):
              ...
            NoConvergence: maxcalls: function evaluated 10 times
Return a wrapped copy of *f* that raises ``NoConvergence`` when *f*
        has been called more than *N* times::
Return a wrapped copy of * f * that raises NoConvergence when * f * has been called more than * N * times ::
def maxcalls(ctx, f, N):
        """
        Return a wrapped copy of *f* that raises ``NoConvergence`` when *f*
        has been called more than *N* times::

            >>> from sympy.mpmath import *
            >>> mp.dps = 15
            >>> f = maxcalls(sin, 10)
            >>> print(sum(f(n) for n in range(10)))
            1.95520948210738
            >>> f(10)
            Traceback (most recent call last):
              ...
            NoConvergence: maxcalls: function evaluated 10 times

        """
        counter = [0]
        def f_maxcalls_wrapped(*args, **kwargs):
            counter[0] += 1
            if counter[0] > N:
                raise ctx.NoConvergence("maxcalls: function evaluated %i times" % N)
            return f(*args, **kwargs)
        return f_maxcalls_wrapped
def maxcalls ( ctx , f , N ) : counter = [ 0 ] def f_maxcalls_wrapped ( * args , * * kwargs ) : counter [ 0 ] += 1 if counter [ 0 ] > N : raise ctx . NoConvergence ( "maxcalls: function evaluated %i times" % N ) return f ( * args , * * kwargs ) return f_maxcalls_wrapped