lt_helper.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:latenttrees 作者: kaltwang 项目源码 文件源码
def check_matplotlib_backends():
    # from http://stackoverflow.com/questions/5091993/list-of-all-available-matplotlib-backends
    # get the directory where the backends live
    backends_dir = os.path.dirname(matplotlib.backends.__file__)

    # filter all files in that directory to identify all files which provide a backend
    backend_fnames = filter(is_backend_module, os.listdir(backends_dir))

    backends = [backend_fname_formatter(fname) for fname in backend_fnames]

    print("supported backends: \t" + str(backends))

    # validate backends
    backends_valid = []
    for b in backends:
        try:
            plt.switch_backend(b)
            backends_valid += [b]
        except:
            continue

    print("valid backends: \t" + str(backends_valid))


    # try backends performance
    for b in backends_valid:

        pylab.ion()
        try:
            plt.switch_backend(b)


            pylab.clf()
            tstart = time.time()               # for profiling
            x = range(0,2*pylab.pi,0.01)            # x-array
            line, = pylab.plot(x,pylab.sin(x))
            for i in range(1,200):
                line.set_ydata(pylab.sin(x+i/10.0))  # update the data
                pylab.draw()                         # redraw the canvas

            print(b + ' FPS: \t' , 200/(time.time()-tstart))
            pylab.ioff()

        except:
            print(b + " error :(")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号