CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
progressbar.cpython-310.pyc90 linesDownload Raw Back to __pycache__
1o

2'�Yi�@s�dZddlZddlZddlmZddlZddlZddlm	Z	ddl3mZddlZ
ddlmZddlmZddlmZGd	d4�d5�ZGdd�de�ZGd
d�d�ZdS)zSome utility functions.�N)�Iterable)�Thread�)�logger)�
_check_option)�6get_configc@sbeZdZdZ					ddd�dd�Zdd	�Zd7d�Zdd
�Zdd�Zdd�Z	dd�Z8dd�ZdS)�ProgressBara�Generate a command-line progressbar.9 10    Parameters11    ----------12    iterable : iterable | int | None13        The iterable to use. Can also be an int for backward compatibility14        (acts like ``max_value``).15    initial_value : int16        Initial value of process, useful when resuming process from a specific17        value, defaults to 0.18    mesg : str19        Message to include at end of progress bar.20    max_total_width : int | str21        Maximum total message width. Can use "auto" (default) to try to set22        a sane value based on the current terminal width.23    max_value : int | None24        The max value. If None, the length of ``iterable`` will be used.25    which_tqdm : str | None26        Which tqdm module to use. Can be "tqdm", "tqdm.notebook", or "off".27        Defaults to ``None``, which uses the value of the MNE_TQDM environment28        variable, or ``"tqdm.auto"`` if that is not set.29    **kwargs : dict30        Additional keyword arguments for tqdm.31    Nr�auto)�32which_tqdmc33Ks�ddl}|dur
tdd�}td|dd�ddd�t�d|���|d	vrPzt|�WntyD}	z
td34t|��d|	���d�d}	~	wwt	||�35dd
�d
�}|j}tddd
ddd�}36|37��D]\}}||vro|�
||i�q`t|t�r�||_|dur�t|�|_n||_nt|�|_d|_|dkr�d}tjddd��}
|
j|_Wd�n1s�wY~
d|_tjtjkp�|dk}|d|j||j|||d�|��|_dS)NrZMNE_TQDMz	tqdm.auto�)�tqdmztqdm.�offZ	beginning)�extrazUsing ProgressBar with )rr
zUnknown tqdm backend z, got: �.rTg����Mb�?g�������?zg{percentage:3.0f}%|{bar}| {desc} : {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}])ZleaveZminintervalZminitersZ	smoothingZ38bar_formatr	�wbZtmp_mne_prog)�prefixr
)�iterable�desc�total�initialZncols�disable�)rrrr�debug�39__import__�	Exception�40ValueError�repr�getattr�split�dict�items�update�41isinstancerr�len�	max_value�int�tempfile�NamedTemporaryFile�name�_mmap_fname�_mmap�level�logging�INFO�_tqdm)�selfr�
initial_valueZmesgZmax_total_widthr$r42�kwargsr�exc�defaults�key�val�tfrrr�E:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\mne/utils/progressbar.py�__init__0sp
43�������444546���zProgressBar.__init__cCs|�||jj�dS)aEUpdate progressbar with current value of process.47 48        Parameters49        ----------50        cur_value : number51            Current value of process.  Should be <= max_value (but this is not52            enforced).  The percent of the progressbar will be computed as53            ``(cur_value / max_value) * 100``.54        N)�update_with_increment_valuer.�n)r/Z	cur_valuerrr7r!rs55zProgressBar.updatecCs(z	|j�|�WdStyYdSw)a(Update progressbar with an increment.56 57        Parameters58        ----------59        increment_value : int60            Value of the increment of process.  The percent of the progressbar61            will be computed as62            ``(self.cur_value + increment_value / max_value) * 100``.63        N)r.r!�	TypeError)r/Zincrement_valuerrr7r9~s6465�z'ProgressBar.update_with_increment_valueccs�|jEdHdS)z*Iterate to auto-increment the pbar with 1.N)r.�r/rrr7�__iter__�s�zProgressBar.__iter__cCs66t||�S)aMake a joblib-friendly index subset updater.67 68        Parameters69        ----------70        idx : ndarray71            List of indices for this subset.72 73        Returns74        -------75        updater : instance of PBSubsetUpdater76            Class with a ``.update(ii)`` method.77        )�_PBSubsetUpdater)r/�idxrrr7�subset�s78
zProgressBar.subsetcCsXt�|j�rt�|j�tj|jtdt|j	d�d�|_79|�d�t|�|_
|j
��|S)Nzw+r)�shaper)�op�isfiler)�os�remove�npZmemmap�bool�maxr$r*r!�
_UpdateThread�_thread�startr<rrr7�	__enter__�s�808182zProgressBar.__enter__cCsj|�|j���|j��d|j_|j��d|_t�	|j83�r3z	t�|j84�WdSt
y2YdSwdS)NF)r!r*�sumr.�closerJ�_mne_run�joinrBrCr)rDrE�PermissionError)r/�type_�value�	tracebackrrr7�__exit__�s8586��zProgressBar.__exit__cCs"t|dd�dur|j��dSdS)zEnsure output completes.r.N)rr.rNr<rrr7�__del__�s�zProgressBar.__del__)NrNr	N)�__name__�87__module__�__qualname__�__doc__r8r!r9r=r@rLrUrVrrrr7rs"��Brcs$eZdZ�fdd�Zdd�Z�ZS)rIcst�jdd�d|_||_dS)NT)�daemon)�superr8rO�_mne_pb)r/�pb��	__class__rr7r8�s88z_UpdateThread.__init__cCs2|jr|j�|jj���t�d�|jsdSdS)Ng�?)rOr]r!r*rM�time�sleepr<rrr7�run�s89�z_UpdateThread.run)rWrXrYr8rc�
__classcell__rrr_r7rI�srIc@seZdZdd�Zdd�ZdS)r>cCs|j|_||_dS)N)r*�mmapr?)r/r^r?rrr7r8�s90z_PBSubsetUpdater.__init__cCsd|j|j|d<dS)NTr)rer?)r/�iirrr7r!�sz_PBSubsetUpdater.updateN)rWrXrYr8r!rrrr7r>�sr>)rZr,rDZos.path�pathrBr&ra�collections.abcr�	threadingr�numpyrFZ_loggingr�checkr�configrrrIr>rrrr7�<module>s .
Aluode/PerceptionLabPortable · CoolFace