U
    ÷Õ/ex  ã                   @  s@   d dl mZ d dlZd dlmZ dddœdd„Zefd	d
„ZdS )é    )ÚannotationsN)Ú	CPU_COUNTÚintzset[int])ÚnÚreturnc                   s4   ‡ fdd„t dttˆ dƒd ƒƒD ƒ}dd„ |D ƒS )zTReturn the factors of an integer
    https://stackoverflow.com/a/6800214/616616
    c                 3  s&   | ]}ˆ | d kr|ˆ | gV  qdS )r   N© )Ú.0Úi©r   r   ú</tmp/pip-unpacked-wheel-g426oqom/distributed/deploy/utils.pyÚ	<genexpr>   s      z_factors.<locals>.<genexpr>é   g      à?c                 S  s   h | ]}|D ]}|’qqS r   r   )r   ÚitemÚjr   r   r   Ú	<setcomp>   s       z_factors.<locals>.<setcomp>)Úranger   Úpow)r   Úseqr   r
   r   Ú_factors   s    &r   c                   s8   ˆ dkrˆ }nt ‡ fdd„tˆ ƒD ƒƒ}ˆ | }||fS )aC  
    The default breakdown of processes and threads for a given number of cores

    Parameters
    ----------
    n : int
        Number of available cores

    Examples
    --------
    >>> nprocesses_nthreads(4)
    (4, 1)
    >>> nprocesses_nthreads(32)
    (8, 4)

    Returns
    -------
    nprocesses, nthreads
    é   c                 3  s    | ]}|t  ˆ ¡kr|V  qd S )N)ÚmathÚsqrt)r   Úfr
   r   r   r   '   s      z&nprocesses_nthreads.<locals>.<genexpr>)Úminr   )r   Z	processesÚthreadsr   r
   r   Únprocesses_nthreads   s
    r   )Ú
__future__r   r   Zdask.systemr   r   r   r   r   r   r   Ú<module>   s   