當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。