• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sys.getrecursionlimit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sys.getrecursionlimit函数的典型用法代码示例。如果您正苦于以下问题:Python getrecursionlimit函数的具体用法?Python getrecursionlimit怎么用?Python getrecursionlimit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getrecursionlimit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test

def test():
    '''Test basic workings of `TempRecursionLimitSetter`.'''
    old_recursion_limit = sys.getrecursionlimit()
    assert sys.getrecursionlimit() == old_recursion_limit
    with TempRecursionLimitSetter(old_recursion_limit + 3):
        assert sys.getrecursionlimit() == old_recursion_limit + 3
    assert sys.getrecursionlimit() == old_recursion_limit
开发者ID:TobiasSimon,项目名称:GarlicSim,代码行数:7,代码来源:test_recursion_limit_setter.py


示例2: main

def main():
    lock = threading.Lock()
    with lock:
        t = threading.Thread(target=foo, args=(lock,))
        t.start()
        sys.getrecursionlimit()     # C function: sys_getrecursionlimit()
    t.join()
开发者ID:jimmysitu,项目名称:pyclewn,代码行数:7,代码来源:foo_thread.py


示例3: test_accessibility_on_very_deep_graph

def test_accessibility_on_very_deep_graph():
    gr = graph()
    gr.add_nodes(range(0,311)) # 2001
    for i in range(0,310): #2000
        gr.add_edge((i,i+1))
    recursionlimit = getrecursionlimit()
    accessibility(gr)
    assert getrecursionlimit() == recursionlimit
开发者ID:wdv4758h,项目名称:ZipPy,代码行数:8,代码来源:python-graph-bench.py


示例4: test_cut_edges_on_very_deep_graph

 def test_cut_edges_on_very_deep_graph(self):
     gr = pygraph.classes.graph.graph()
     gr.add_nodes(range(0,5001))
     for i in range(0,5000):
         gr.add_edge((i,i+1))
     recursionlimit = getrecursionlimit()
     cut_edges(gr)
     assert getrecursionlimit() == recursionlimit
开发者ID:GadgetSteve,项目名称:python-graph,代码行数:8,代码来源:unittests-accessibility.py


示例5: test_topological_sort_on_very_deep_graph

 def test_topological_sort_on_very_deep_graph(self):
     gr = pygraph.classes.graph.graph()
     gr.add_nodes(list(range(0,20001)))
     for i in range(0,20000):
         gr.add_edge((i,i+1))
     recursionlimit = getrecursionlimit()
     topological_sorting(gr)
     assert getrecursionlimit() == recursionlimit
开发者ID:soeltjen,项目名称:python-graph,代码行数:8,代码来源:unittests-sorting.py


示例6: test_dfs_very_deep_graph

 def test_dfs_very_deep_graph(self):
     gr = pygraph.classes.graph.graph()
     gr.add_nodes(range(0,20001))
     for i in range(0,20000):
         gr.add_edge((i,i+1))
     recursionlimit = getrecursionlimit()
     depth_first_search(gr, 0)
     assert getrecursionlimit() == recursionlimit
开发者ID:GadgetSteve,项目名称:python-graph,代码行数:8,代码来源:unittests-searching.py


示例7: test_recursionlimit

 def test_recursionlimit(self):
     self.assertRaises(TypeError, sys.getrecursionlimit, 42)
     oldlimit = sys.getrecursionlimit()
     self.assertRaises(TypeError, sys.setrecursionlimit)
     self.assertRaises(ValueError, sys.setrecursionlimit, -42)
     sys.setrecursionlimit(10000)
     self.assertEqual(sys.getrecursionlimit(), 10000)
     sys.setrecursionlimit(oldlimit)
开发者ID:MaximVanyushkin,项目名称:Sharp.RemoteQueryable,代码行数:8,代码来源:test_sys.py


示例8: test_accessibility_on_very_deep_graph

 def test_accessibility_on_very_deep_graph(self):
     gr = pygraph.classes.graph.graph()
     gr.add_nodes(range(0,2001))
     for i in range(0,2000):
         gr.add_edge((i,i+1))
     recursionlimit = getrecursionlimit()
     accessibility(gr)
     assert getrecursionlimit() == recursionlimit
开发者ID:GadgetSteve,项目名称:python-graph,代码行数:8,代码来源:unittests-accessibility.py


示例9: test_recursionlimit

 def test_recursionlimit(self):
     import sys
     raises(TypeError, sys.getrecursionlimit, 42)
     oldlimit = sys.getrecursionlimit()
     raises(TypeError, sys.setrecursionlimit)
     raises(ValueError, sys.setrecursionlimit, -42)
     sys.setrecursionlimit(10000)
     assert sys.getrecursionlimit() == 10000
     sys.setrecursionlimit(oldlimit)
     raises(OverflowError, sys.setrecursionlimit, 1<<31)
开发者ID:yuyichao,项目名称:pypy,代码行数:10,代码来源:test_sysmodule.py


示例10: test_as_decorator

def test_as_decorator():
    '''Test `TempRecursionLimitSetter` when used as a decorator.'''
    old_recursion_limit = sys.getrecursionlimit()
    @TempRecursionLimitSetter(1234)
    def f():
        assert sys.getrecursionlimit() == 1234
    assert sys.getrecursionlimit() == old_recursion_limit
    f()
    assert sys.getrecursionlimit() == old_recursion_limit
    
    cute_testing.assert_polite_wrapper(f)
开发者ID:TobiasSimon,项目名称:GarlicSim,代码行数:11,代码来源:test_recursion_limit_setter.py


示例11: test_standardOptions

 def test_standardOptions(self):
     """
     L{WorkerOptions} supports a subset of standard options supported by
     trial.
     """
     self.addCleanup(sys.setrecursionlimit, sys.getrecursionlimit())
     if gc.isenabled():
         self.addCleanup(gc.enable)
     gc.enable()
     self.options.parseOptions(["--recursionlimit", "2000", "--disablegc"])
     self.assertEqual(2000, sys.getrecursionlimit())
     self.assertFalse(gc.isenabled())
开发者ID:ssilverek,项目名称:kodb,代码行数:12,代码来源:test_options.py


示例12: Save

def Save(session, filename=None):
    """
    save your session to use it later.

    Returns the filename of the written file.
    If not filename is given, a file named `androguard_session_<DATE>.ag` will
    be created in the current working directory.
    `<DATE>` is a timestamp with the following format: `%Y-%m-%d_%H%M%S`.

    This function will overwrite existing files without asking.

    If the file could not written, None is returned.

    example::

        s = session.Session()
        session.Save(s, "msession.ag")

    :param session: A Session object to save
    :param filename: output filename to save the session
    :type filename: string

    """

    if not filename:
        filename = "androguard_session_{:%Y-%m-%d_%H%M%S}.ag".format(datetime.datetime.now())

    if os.path.isfile(filename):
        log.warning("{} already exists, overwriting!")

    # Setting the recursion limit according to the documentation:
    # https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled
    #
    # Some larger APKs require a high recursion limit.
    # Tested to be above 35000 for some files, setting to 50k to be sure.
    # You might want to set this even higher if you encounter problems
    reclimit = sys.getrecursionlimit()
    sys.setrecursionlimit(50000)
    saved = False
    try:
        with open(filename, "wb") as fd:
            pickle.dump(session, fd)
        saved = True
    except RecursionError:
        log.exception("Recursion Limit hit while saving. "
                      "Current Recursion limit: {}. "
                      "Please report this error!".format(sys.getrecursionlimit()))
        # Remove partially written file
        os.unlink(filename)

    sys.setrecursionlimit(reclimit)
    return filename if saved else None
开发者ID:androguard,项目名称:androguard,代码行数:52,代码来源:session.py


示例13: calculate_acc_index

def calculate_acc_index(dir_arr, origin_upper_left=True):

    # modify maximum recursion depth if required
    import sys
    rec_depth = sys.getrecursionlimit()
    sys.setrecursionlimit(max(dir_arr.shape[0] * dir_arr.shape[1], rec_depth))



    acc_index = np.ones(dir_arr.shape)
    cache = -np.ones(dir_arr.shape)




    n1, n2 = acc_index.shape

    for i in range(n1):
        if i % 100 == 0:
            print("{}/{} ...".format(i, n1))

        for j in range(n2):
            acc_index[i, j] = calculate_acc_index_for_point(i, j, dir_arr, cache, origin_upper_left=origin_upper_left)

    # print(acc_index.min(), acc_index.max())

    return acc_index
开发者ID:guziy,项目名称:RPN,代码行数:27,代码来源:reverse_river_in_hydrosheds_nc.py


示例14: main

def main():
    max_recursion = sys.getrecursionlimit() / 4
    if len(sys.argv) < 2:
        n = 250
    else:
        n = int(sys.argv[1])

    print n / max_recursion
    for i in range(n / max_recursion):
        c = (i+1)*max_recursion
        # print i, c
        f(c)
        catalan(c)
    print_fac(n)

    n = 100
    for i in range(n / max_recursion):
        c = (i+1)*max_recursion
        catalan(c)
    for i in range(n):
        print(catalan(i))
    print catalan(n)
    print "="*20
    for i in range(30):
        print i, ci(i)
开发者ID:edilio,项目名称:Memoizer,代码行数:25,代码来源:play.py


示例15: tag_molecules

def tag_molecules(struct):
    """
    Sets the ``marked`` attribute of every Atom in struct to the molecule number
    it is a part of. If no bonds are present, every atom is its own molecule.

    Parameters
    ----------
    struct : :class:`parmed.Structure`
        Input structure to tag the molecules for
    """
    # Make sure our recursion limit is large enough, but never shrink it
    from sys import setrecursionlimit, getrecursionlimit
    setrecursionlimit(max(len(struct.atoms), getrecursionlimit()))

    if not struct.bonds:
        for i, atom in enumerate(struct.atoms):
            atom.marked = i + 1
        return
    # We do have bonds, this is the interesting part
    struct.atoms.unmark()
    mol_id = 1
    for atom in struct.atoms:
        if atom.marked: continue
        atom.marked = mol_id
        _set_owner(atom, mol_id)
        mol_id += 1
开发者ID:jchodera,项目名称:ParmEd,代码行数:26,代码来源:__init__.py


示例16: test_pickle

 def test_pickle(self, net_fitted, X_test, y_pred):
     recursionlimit = sys.getrecursionlimit()
     sys.setrecursionlimit(10000)
     pickled = pickle.dumps(net_fitted, -1)
     net_loaded = pickle.loads(pickled)
     assert np.array_equal(net_loaded.predict(X_test), y_pred)
     sys.setrecursionlimit(recursionlimit)
开发者ID:dnouri,项目名称:nolearn,代码行数:7,代码来源:test_base.py


示例17: test_main

def test_main(type="short"):
    oldRecursionDepth = sys.getrecursionlimit()
    try:
        sys.setrecursionlimit(1001)
        t0 = clock()
        import b0
        import b1
        import b2
        import b3
        import b4
        import b5
        import b6
        print 'import time = %.2f' % (clock()-t0)
    
        tests = [b0,b1,b2,b3,b4,b5,b6]
        N = { "short" : 1, "full" : 1, "medium" : 2, "long" : 4 }[type]
    
        results = {}
    
        t0 = clock()
        for i in range(N):
            for test in tests:
                ts0 = clock()
                test.main()
                tm = (clock()-ts0)
                results.setdefault(test, []).append(tm)
                print '%.2f sec running %s' % ( tm, test.__name__)
    
        for test in tests:
            print '%s = %f -- %r' % (test.__name__, sum(results[test])/N, results[test])
    
        print 'all done in %.2f sec' % (clock()-t0)
    finally:
        sys.setrecursionlimit(oldRecursionDepth)
开发者ID:mdavid,项目名称:dlr,代码行数:34,代码来源:test_parrot.py


示例18: test_create

    def test_create(self):
        '''construct a group from an object instance'''

        # get a useful backtrace
        # must restore recursion limit or later tests will be VERY odd
        with temp_set(sys.setrecursionlimit, 35, sys.getrecursionlimit()):
            ga = GroupAlias({})
开发者ID:damonwang,项目名称:xraylarch,代码行数:7,代码来源:unittest_all.py


示例19: calculate_n_mer_significances

def calculate_n_mer_significances(seqs, n, background=None):
    '''
    Counts all n-mers in the sequences and assesses the significance of each
    count w.r.t. the background_model

    If the background model is not specified, a uniform distribution over
    the bases is assumed
    '''
    from sys import getrecursionlimit
    all = _AllNMers()
    hmm.count_mers(seqs, n, all)
    collapsed = collapse_rev_comps(all.n_mers)
    log_fact = _LogFactorial()
    total_counts = sum(count for mer, count in collapsed)
    for i in xrange(1,total_counts,getrecursionlimit()/2):
        log_fact[i]
    log_fact_total = log_fact[total_counts]
    if None == background:
        background_LL = n * math.log(.25)
        foreground_LL = math.log(1.0 - math.exp(background_LL))
    result = []
    for mer, count in collapsed:
        if None != background:
            background_LL = background.LL(mer)
            foreground_LL = math.log(1.0 - math.exp(background_LL))
        log_bernoulli = (
                log_fact_total
                - log_fact[count]
                - log_fact[total_counts-count]
                + count * background_LL
                + (total_counts-count) * foreground_LL
        )
        result.append((mer, count, log_bernoulli))
    result.sort(cmp=lambda x,y: cmp(x[2], y[2]))
    return result
开发者ID:JohnReid,项目名称:HMM,代码行数:35,代码来源:count_mers.py


示例20: test_tco_decorator

    def test_tco_decorator(self):

        def recur_accumulate(origin, f=operator.add, acc=0):
            n = next(origin, None)
            if n is None: return acc
            return recur_accumulate(origin, f, f(acc, n))

        # this works normally
        self.assertEqual(10, recur_accumulate(iter(range(5))))

        limit = sys.getrecursionlimit() * 10
        # such count of recursive calls should fail on CPython,
        # for PyPy we skip this test cause on PyPy the limit is
        # approximative and checked at a lower level
        if not hasattr(sys, 'pypy_version_info'):
            self.assertRaises(RuntimeError, recur_accumulate, iter(range(limit)))

        # with recur decorator it should run without problems
        @recur.tco
        def tco_accumulate(origin, f=operator.add, acc=0):
            n = next(origin, None)
            if n is None: return False, acc
            return True, (origin, f, f(acc, n))

        self.assertEqual(sum(range(limit)), tco_accumulate(iter(range(limit))))
开发者ID:Gizmo707,项目名称:fn.py,代码行数:25,代码来源:tests.py



注:本文中的sys.getrecursionlimit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sys.getrefcount函数代码示例发布时间:2022-05-27
下一篇:
Python sys.getprofile函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap