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


Python tqdm.auto方法代码示例

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


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

示例1: _download

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.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.auto import tqdm [as 别名]
# 或者: from tqdm.auto.tqdm import auto [as 别名]
def __init__(self, k: int = 10, return_value: str = 'k_skewness',
                 hub_size: float = 2., metric='euclidean',
                 store_k_neighbors: bool = False, store_k_occurrence: bool = False,
                 algorithm: str = 'auto', algorithm_params: dict = None,
                 hubness: str = None, hubness_params: dict = None,
                 verbose: int = 0, n_jobs: int = 1, random_state=None,
                 shuffle_equal: bool = True):
        self.k = k
        self.return_value = return_value
        self.hub_size = hub_size
        self.metric = metric
        self.store_k_neighbors = store_k_neighbors
        self.store_k_occurrence = store_k_occurrence
        self.algorithm = algorithm
        self.algorithm_params = algorithm_params
        self.hubness = hubness
        self.hubness_params = hubness_params
        self.verbose = verbose
        self.n_jobs = n_jobs
        self.random_state = random_state
        self.shuffle_equal = shuffle_equal 
开发者ID:VarIr,项目名称:scikit-hubness,代码行数:23,代码来源:estimation.py

示例3: __init__

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.tqdm import auto [as 别名]
def __init__(self, n_neighbors: int = 5, weights: str = 'uniform',
                 algorithm: str = 'auto', algorithm_params: dict = None,
                 hubness: str = None, hubness_params: dict = None,
                 leaf_size: int = 30, p=2, metric='minkowski', metric_params=None,
                 n_jobs=None, verbose: int = 0, **kwargs):

        super().__init__(
            n_neighbors=n_neighbors,
            algorithm=algorithm,
            algorithm_params=algorithm_params,
            hubness=hubness,
            hubness_params=hubness_params,
            leaf_size=leaf_size, metric=metric, p=p,
            metric_params=metric_params,
            n_jobs=n_jobs,
            verbose=verbose,
            **kwargs)
        self.weights = _check_weights(weights) 
开发者ID:VarIr,项目名称:scikit-hubness,代码行数:20,代码来源:classification.py

示例4: __init__

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.tqdm import auto [as 别名]
def __init__(self, n_neighbors=None, radius=None,
                 algorithm='auto', algorithm_params: dict = None,
                 hubness: str = None, hubness_params: dict = None,
                 leaf_size=30, metric='minkowski', p=2, metric_params=None,
                 n_jobs=None, verbose: int = 0, **kwargs):
        super().__init__(n_neighbors=n_neighbors,
                         radius=radius,
                         algorithm=algorithm,
                         leaf_size=leaf_size,
                         metric=metric, p=p, metric_params=metric_params,
                         n_jobs=n_jobs)
        if algorithm_params is None:
            n_candidates = 1 if hubness is None else 100
            algorithm_params = {'n_candidates': n_candidates,
                                'metric': metric}
        if n_jobs is not None and 'n_jobs' not in algorithm_params:
            algorithm_params['n_jobs'] = self.n_jobs
        if 'verbose' not in algorithm_params:
            algorithm_params['verbose'] = verbose
        hubness_params = hubness_params if hubness_params is not None else {}
        if 'verbose' not in hubness_params:
            hubness_params['verbose'] = verbose

        self.algorithm_params = algorithm_params
        self.hubness_params = hubness_params
        self.hubness = hubness
        self.verbose = verbose
        self.kwargs = kwargs 
开发者ID:VarIr,项目名称:scikit-hubness,代码行数:30,代码来源:base.py

示例5: _check_algorithm_metric

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.tqdm import auto [as 别名]
def _check_algorithm_metric(self):
        if self.algorithm not in ['auto', *EXACT_ALG, *ANN_ALG]:
            raise ValueError("unrecognized algorithm: '%s'" % self.algorithm)

        if self.algorithm == 'auto':
            if self.metric == 'precomputed':
                alg_check = 'brute'
            elif (callable(self.metric) or
                  self.metric in VALID_METRICS['ball_tree']):
                alg_check = 'ball_tree'
            else:
                alg_check = 'brute'
        else:
            alg_check = self.algorithm

        if callable(self.metric):
            if self.algorithm in ['kd_tree', *ANN_ALG]:
                # callable metric is only valid for brute force and ball_tree
                raise ValueError(f"{self.algorithm} algorithm does not support callable metric '{self.metric}'")
        elif self.metric not in VALID_METRICS[alg_check]:
            raise ValueError(f"Metric '{self.metric}' not valid. Use "
                             f"sorted(skhubness.neighbors.VALID_METRICS['{alg_check}']) "
                             f"to get valid options. "
                             f"Metric can also be a callable function.")

        if self.metric_params is not None and 'p' in self.metric_params:
            warnings.warn("Parameter p is found in metric_params. "
                          "The corresponding parameter from __init__ "
                          "is ignored.", SyntaxWarning, stacklevel=3)
            effective_p = self.metric_params['p']
        else:
            effective_p = self.p

        if self.metric in ['wminkowski', 'minkowski'] and effective_p <= 0:
            raise ValueError("p must be greater than zero for minkowski metric") 
开发者ID:VarIr,项目名称:scikit-hubness,代码行数:37,代码来源:base.py

示例6: __init__

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.tqdm import auto [as 别名]
def __init__(self, n_candidates: int = 5,
                 metric: str = 'euclidean',
                 index_dir: str = 'auto',
                 optimize: bool = False,
                 edge_size_for_creation: int = 80,
                 edge_size_for_search: int = 40,
                 num_incoming: int = -1,
                 num_outgoing: int = -1,
                 epsilon: float = 0.1,
                 n_jobs: int = 1,
                 verbose: int = 0):

        if ngtpy is None:  # pragma: no cover
            raise ImportError(f'Please install the `ngt` package, before using this class.\n'
                              f'$ pip3 install ngt') from None

        super().__init__(n_candidates=n_candidates,
                         metric=metric,
                         n_jobs=n_jobs,
                         verbose=verbose,
                         )
        self.index_dir = index_dir
        self.optimize = optimize
        self.edge_size_for_creation = edge_size_for_creation
        self.edge_size_for_search = edge_size_for_search
        self.num_incoming = num_incoming
        self.num_outgoing = num_outgoing
        self.epsilon = epsilon 
开发者ID:VarIr,项目名称:scikit-hubness,代码行数:30,代码来源:nng.py

示例7: __init__

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.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

示例8: __init__

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.tqdm import auto [as 别名]
def __init__(
        self,
        metrics_separator: str = " - ",
        overall_bar_format: str = "{l_bar}{bar} {n_fmt}/{total_fmt} ETA: "
        "{remaining}s,  {rate_fmt}{postfix}",
        epoch_bar_format: str = "{n_fmt}/{total_fmt}{bar} ETA: "
        "{remaining}s - {desc}",
        metrics_format: str = "{name}: {value:0.4f}",
        update_per_second: int = 10,
        leave_epoch_progress: bool = True,
        leave_overall_progress: bool = True,
        show_epoch_progress: bool = True,
        show_overall_progress: bool = True,
    ):

        try:
            # import tqdm here because tqdm is not a required package
            # for addons
            import tqdm

            version_message = "Please update your TQDM version to >= 4.36.1, "
            "you have version {}. To update, run !pip install -U tqdm"
            assert tqdm.__version__ >= "4.36.1", version_message.format(
                tqdm.__version__
            )
            from tqdm.auto import tqdm

            self.tqdm = tqdm
        except ImportError:
            raise ImportError("Please install tqdm via pip install tqdm")

        self.metrics_separator = metrics_separator
        self.overall_bar_format = overall_bar_format
        self.epoch_bar_format = epoch_bar_format
        self.leave_epoch_progress = leave_epoch_progress
        self.leave_overall_progress = leave_overall_progress
        self.show_epoch_progress = show_epoch_progress
        self.show_overall_progress = show_overall_progress
        self.metrics_format = metrics_format

        # compute update interval (inverse of update per second)
        self.update_interval = 1 / update_per_second

        self.last_update_time = time.time()
        self.overall_progress_tqdm = None
        self.epoch_progress_tqdm = None
        self.is_training = False
        self.num_epochs = None
        self.logs = None
        super().__init__() 
开发者ID:tensorflow,项目名称:addons,代码行数:52,代码来源:tqdm_progress_bar.py

示例9: run_simulation_alg

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.tqdm import auto [as 别名]
def run_simulation_alg(self, alg, start, end, delay_factor=True):
        from tqdm.auto import tqdm

        alg.blotter.clear()
        # get factor data from algorithm
        run_engine = alg.run_engine
        data, _ = run_engine(start, end, delay_factor)
        ticks = self.get_data_ticks(data, start)
        if len(ticks) == 0:
            raise ValueError("No data returned, please set `start`, `end` time correctly")
        data = self.wrap_data(data, DataLoaderFastGetter)
        # mock CustomAlgorithm
        alg.run_engine = lambda *args: (self._mocked_data, self._mocked_last)
        if 'empty_cache_after_run' in alg.__dict__:
            for eng in alg._engines.values():
                eng.empty_cache()
            gc.collect()
            torch.cuda.empty_cache()

        # infer freq
        delta = min(ticks[1:] - ticks[:-1])
        data_freq = delta.resolution_string

        # loop factor data
        last_day = None
        for dt in tqdm(ticks):
            if self._stop:
                break
            # prepare data
            self.mock_data(data, dt)

            # if date changed
            if dt.day != last_day:
                if last_day is not None:
                    self.fire_market_close(alg)
            alg.set_datetime(dt)

            # fire daily data event
            if data_freq == 'D':
                self.fire_event(self, EveryBarData)

            # fire open event
            if dt.day != last_day:
                self.fire_market_open(alg)
                last_day = dt.day

            # fire intraday data event
            if data_freq != 'D':
                alg.blotter.set_price('close')
                self.fire_event(self, EveryBarData)

        self.fire_market_close(alg)
        alg.run_engine = run_engine 
开发者ID:Heerozh,项目名称:spectre,代码行数:55,代码来源:algorithm.py

示例10: fit

# 需要导入模块: from tqdm.auto import tqdm [as 别名]
# 或者: from tqdm.auto.tqdm import auto [as 别名]
def fit(self, X, y=None) -> RandomProjectionTree:
        """ Build the annoy.Index and insert data from X.

        Parameters
        ----------
        X: np.array
            Data to be indexed
        y: any
            Ignored

        Returns
        -------
        self: RandomProjectionTree
            An instance of RandomProjectionTree with a built index
        """
        if y is None:
            X = check_array(X)
        else:
            X, y = check_X_y(X, y)
            self.y_train_ = y

        self.n_samples_fit_ = X.shape[0]
        self.n_features_ = X.shape[1]
        self.X_dtype_ = X.dtype
        if self.metric == 'minkowski':  # for compatibility
            self.metric = 'euclidean'
        metric = self.metric if self.metric != 'sqeuclidean' else 'euclidean'
        self.effective_metric_ = metric
        annoy_index = annoy.AnnoyIndex(X.shape[1], metric=metric)
        if self.mmap_dir == 'auto':
            self.annoy_ = create_tempfile_preferably_in_dir(prefix='skhubness_',
                                                            suffix='.annoy',
                                                            directory='/dev/shm')
            logging.warning(f'The index will be stored in {self.annoy_}. '
                            f'It will NOT be deleted automatically, when this instance is destructed.')
        elif isinstance(self.mmap_dir, str):
            self.annoy_ = create_tempfile_preferably_in_dir(prefix='skhubness_',
                                                            suffix='.annoy',
                                                            directory=self.mmap_dir)
        else:  # e.g. None
            self.mmap_dir = None

        for i, x in tqdm(enumerate(X),
                         desc='Build RPtree',
                         disable=False if self.verbose else True,
                         ):
            annoy_index.add_item(i, x.tolist())
        annoy_index.build(self.n_trees)

        if self.mmap_dir is None:
            self.annoy_ = annoy_index
        else:
            annoy_index.save(self.annoy_, )

        return self 
开发者ID:VarIr,项目名称:scikit-hubness,代码行数:57,代码来源:random_projection_trees.py


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