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


Python tqdm.auto方法代码示例

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


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

示例1: _download

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import auto [as 别名]
def _download(url: str, path: Path):
    try:
        import ipywidgets
        from tqdm.auto import tqdm
    except ModuleNotFoundError:
        from tqdm import tqdm
    from urllib.request import urlretrieve

    path.parent.mkdir(parents=True, exist_ok=True)
    with tqdm(unit='B', unit_scale=True, miniters=1, desc=path.name) as t:

        def update_to(b=1, bsize=1, tsize=None):
            if tsize is not None:
                t.total = tsize
            t.update(b * bsize - t.n)

        try:
            urlretrieve(url, str(path), reporthook=update_to)
        except Exception:
            # Make sure file doesn’t exist half-downloaded
            if path.is_file():
                path.unlink()
            raise 
开发者ID:theislab,项目名称:scanpy,代码行数:25,代码来源:readwrite.py

示例2: __init__

# 需要导入模块: from tqdm import tqdm [as 别名]
# 或者: from tqdm.tqdm import auto [as 别名]
def __init__(self, frontend="auto", **kwargs):
        """
        Parameters
        ----------
        frontend : {"auto", "console", "gui", "notebook"}, optional
            Selects a frontend for displaying the progress bar. By default ("auto"),
            the frontend is chosen by guessing in which environment the simulation
            is run. The "console" frontend displays an ascii progress bar, while the
            "gui" frontend is based on matplotlib and the "notebook" frontend is based
            on ipywidgets.
        **kwargs : dict, optional
            Arbitrary keyword arguments for progress bar customization.
            See https://tqdm.github.io/docs/tqdm/.

        """
        if frontend == "auto":
            from tqdm.auto import tqdm
        elif frontend == "console":
            from tqdm import tqdm
        elif frontend == "gui":
            from tqdm.gui import tqdm
        elif frontend == "notebook":
            from tqdm.notebook import tqdm
        else:
            raise ValueError(
                f"Frontend argument {frontend!r} not supported. "
                "Please select one of the following: "
                ", ".join(["auto", "console", "gui", "notebook"])
            )

        self.custom_description = False
        if "desc" in kwargs.keys():
            self.custom_description = True

        self.tqdm = tqdm
        self.tqdm_kwargs = {"bar_format": "{bar} {percentage:3.0f}% | {desc} "}
        self.tqdm_kwargs.update(kwargs) 
开发者ID:benbovy,项目名称:xarray-simlab,代码行数:39,代码来源:monitoring.py


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