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


Python tqdm.update方法代码示例

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


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

示例1: filehash

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import update [as 别名]
def filehash(filename, block_size=65536, algorithm='sha256'):
    """
    Computes the hash value for a file by using a specified hash algorithm.

    :param filename: filename
    :type filename: str
    :param block_size: blocksize used to compute file hash
    :type block_size: int
    :param algorithm: hash algorithms like 'sha256' or 'md5' etc.
    :type algorithm: str
    :return: None
    :History: 2019-Mar-12 - Written - Henry Leung (University of Toronto)
    """
    algorithm = algorithm.lower()
    if algorithm not in hashlib.algorithms_guaranteed:
        raise ValueError(f"{algorithm} is an unsupported hashing algorithm")

    func_algorithm = getattr(hashlib, algorithm)()
    with open(filename, 'rb') as f:
        for block in iter(lambda: f.read(block_size), b''):
            func_algorithm.update(block)
    return func_algorithm.hexdigest() 
开发者ID:henrysky,项目名称:astroNN,代码行数:24,代码来源:downloader_tools.py

示例2: md5sum

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import update [as 别名]
def md5sum(downfile):
    '''
    文件的 md5 哈希值

    :param downfile:
    :return:
    '''
    import hashlib
    md5_l = hashlib.md5()

    with open(downfile, mode="rb") as fp:
        by = fp.read()

    md5_l.update(by)
    ret = md5_l.hexdigest()

    return ret 
开发者ID:bopo,项目名称:mootdx,代码行数:19,代码来源:utils.py

示例3: update_to

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import update [as 别名]
def update_to(self, b=1, bsize=1, tsize=None):
        """
        b  : int, optional
            Number of blocks transferred so far [default: 1].
        bsize  : int, optional
            Size of each block (in tqdm units) [default: 1].
        tsize  : int, optional
            Total size (in tqdm units). If [default: None] remains unchanged.
        """
        if tsize is not None:
            self.total = tsize
        self.update(b * bsize - self.n)  # will also set self.n = b * bsize 
开发者ID:henrysky,项目名称:astroNN,代码行数:14,代码来源:downloader_tools.py

示例4: update_to

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import update [as 别名]
def update_to(self, downloaded=0, total_size=None):
        """
        b  : int, optional
            Number of blocks transferred so far [default: 1].
        bsize  : int, optional
            Size of each block (in tqdm units) [default: 1].
        tsize  : int, optional
            Total size (in tqdm units). If [default: None] remains unchanged.
        """
        if total_size is not None:
            self.total = total_size

        # self.ascii = True
        self.update(downloaded - self.n)  # will also set self.n = b * bsize 
开发者ID:bopo,项目名称:mootdx,代码行数:16,代码来源:utils.py

示例5: _hash_file

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import update [as 别名]
def _hash_file(fpath, algorithm="sha256", chunk_size=65535):
    """Calculates a file sha256 or md5 hash.

    # Example

    ```python
       >>> from keras.data_utils import _hash_file
       >>> _hash_file("/path/to/file.zip")
       "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
    ```

    # Arguments
        fpath: path to the file being validated
        algorithm: hash algorithm, one of "auto", "sha256", or "md5".
            The default "auto" detects the hash algorithm in use.
        chunk_size: Bytes to read at a time, important for large files.

    # Returns
        The file hash
    """
    hasher = hashlib.md5()

    with open(fpath, "rb") as fpath_file:
        for chunk in iter(lambda: fpath_file.read(chunk_size), b""):
            hasher.update(chunk)

    return hasher.hexdigest() 
开发者ID:alexander-rakhlin,项目名称:ICIAR2018,代码行数:29,代码来源:download_models.py

示例6: my_hook

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import update [as 别名]
def my_hook(t):
    """Wraps tqdm instance.
    Don't forget to close() or __exit__()
    the tqdm instance once you're done with it (easiest using `with` syntax).
    Example
    -------
    >>> with tqdm(...) as t:
    ...     reporthook = my_hook(t)
    ...     urllib.urlretrieve(..., reporthook=reporthook)
    """
    last_b = [0]

    def update_to(b=1, bsize=1, tsize=None):
        """
        b  : int, optional
            Number of blocks transferred so far [default: 1].
        bsize  : int, optional
            Size of each block (in tqdm units) [default: 1].
        tsize  : int, optional
            Total size (in tqdm units). If [default: None] remains unchanged.
        """
        if tsize is not None:
            t.total = tsize
        t.update((b - last_b[0]) * bsize)
        last_b[0] = b

    return update_to 
开发者ID:deep500,项目名称:deep500,代码行数:29,代码来源:download.py

示例7: update_to

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import update [as 别名]
def update_to(self, b=1, bsize=1, tsize=None):
        """Reports update statistics on the download progress.

        Args:
            b (int): Number of blocks transferred so far [default: 1].
            bsize (int): Size of each block (in tqdm units) [default: 1].
            tsize (int): Total size (in tqdm units). If [default: None] remains unchanged.
        """
        if tsize is not None:
            self.total = tsize
        self.update(b * bsize - self.n)  # will also set self.n = b * bsize 
开发者ID:cisco,项目名称:mindmeld,代码行数:13,代码来源:embeddings.py


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