当前位置: 首页>>代码示例>>Python>>正文


Python matplotlib.get_cachedir方法代码示例

本文整理汇总了Python中matplotlib.get_cachedir方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.get_cachedir方法的具体用法?Python matplotlib.get_cachedir怎么用?Python matplotlib.get_cachedir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib的用法示例。


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

示例1: hardcopy_fonts

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import get_cachedir [as 别名]
def hardcopy_fonts():
    path = os.path.abspath(__file__)
    pkg_dir = "/" + "/".join(path.split("/")[:-1])
    os.system(
        "cp -r {}/fonts/firasans/* ".format(pkg_dir)
        + os.path.join(mpl.rcParams["datapath"] + "/fonts/ttf/")
    )
    os.system(
        "cp -r {}/fonts/firamath/* ".format(pkg_dir)
        + os.path.join(mpl.rcParams["datapath"] + "/fonts/ttf/")
    )
    os.system(
        "cp -r {}/fonts/texgyreheros/* ".format(pkg_dir)
        + os.path.join(mpl.rcParams["datapath"] + "/fonts/ttf/")
    )
    os.system("rm " + os.path.join(mpl.get_cachedir() + "/font*")) 
开发者ID:scikit-hep,项目名称:mplhep,代码行数:18,代码来源:tools.py

示例2: get_cache_dir

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import get_cachedir [as 别名]
def get_cache_dir():
    cachedir = matplotlib.get_cachedir()
    if cachedir is None:
        raise RuntimeError('Could not find a suitable configuration directory')
    cache_dir = os.path.join(cachedir, 'test_cache')
    try:
        Path(cache_dir).mkdir(parents=True, exist_ok=True)
    except IOError:
        return None
    if not os.access(cache_dir, os.W_OK):
        return None
    return cache_dir 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:14,代码来源:compare.py

示例3: get_cache_dir

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import get_cachedir [as 别名]
def get_cache_dir():
    cachedir = mpl.get_cachedir()
    if cachedir is None:
        raise RuntimeError('Could not find a suitable configuration directory')
    cache_dir = os.path.join(cachedir, 'test_cache')
    try:
        Path(cache_dir).mkdir(parents=True, exist_ok=True)
    except IOError:
        return None
    if not os.access(cache_dir, os.W_OK):
        return None
    return cache_dir 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:14,代码来源:compare.py

示例4: convert

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import get_cachedir [as 别名]
def convert(filename, cache):
    """
    Convert the named file to png; return the name of the created file.

    If *cache* is True, the result of the conversion is cached in
    `matplotlib.get_cachedir() + '/test_cache/'`.  The caching is based on a
    hash of the exact contents of the input file.  There is no limit on the
    size of the cache, so it may need to be manually cleared periodically.
    """
    base, extension = filename.rsplit('.', 1)
    if extension not in converter:
        reason = "Don't know how to convert %s files to png" % extension
        from . import is_called_from_pytest
        if is_called_from_pytest():
            import pytest
            pytest.skip(reason)
        else:
            from nose import SkipTest
            raise SkipTest(reason)
    newname = base + '_' + extension + '.png'
    if not os.path.exists(filename):
        raise IOError("'%s' does not exist" % filename)

    # Only convert the file if the destination doesn't already exist or
    # is out of date.
    if (not os.path.exists(newname) or
            os.stat(newname).st_mtime < os.stat(filename).st_mtime):
        if cache:
            cache_dir = get_cache_dir()
        else:
            cache_dir = None

        if cache_dir is not None:
            hash_value = get_file_hash(filename)
            new_ext = os.path.splitext(newname)[1]
            cached_file = os.path.join(cache_dir, hash_value + new_ext)
            if os.path.exists(cached_file):
                shutil.copyfile(cached_file, newname)
                return newname

        converter[extension](filename, newname)

        if cache_dir is not None:
            shutil.copyfile(newname, cached_file)

    return newname 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:48,代码来源:compare.py


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