a
    2`/b  ã                   @   sŽ   d dl mZ d dlZd dlmZ d dlmZ d dlmZ	 d dl
mZ zd dlZW n eyf   dZY n0 e	ejƒZdZdd	„ Zed
d„ ƒZdS )é    )ÚNumberN)Úwithout_property_validation)Úcurdoc)Úparse)ÚfirstFc                    s   ‡ fdd„ˆ d D ƒS )Nc                    s    i | ]‰ ˆ ‡ fd d„ˆD ƒ“qS )c                    s   g | ]}|ˆ  ‘qS © r   )Ú.0Úd©Úkr   ú:lib/python3.9/site-packages/distributed/dashboard/utils.pyÚ
<listcomp>   ó    z(transpose.<locals>.<dictcomp>.<listcomp>r   )r   ©Zlodr
   r   Ú
<dictcomp>   r   ztranspose.<locals>.<dictcomp>r   r   r   r   r   r   Ú	transpose   s    r   c                    s¾   t rtdd„ ˆj ¡ D ƒƒs*ˆj|kr*dS t rŽt|t|ƒ ƒdkrŽi ‰ | ¡ D ]<\}}t|ƒt jur‚t	|d t
ƒr‚t  |¡ˆ |< qN|ˆ |< qNn|‰ tr®tƒ  ‡ ‡fdd„¡ nˆj ˆ ¡ dS )a  Update source with data

    This checks a few things first

    1.  If the data is the same, then don't update
    2.  If numpy is available and the data is numeric, then convert to numpy
        arrays
    3.  If profiling then perform the update in another callback
    c                 s   s   | ]}t |tjƒV  qd S ©N)Ú
isinstanceÚnpÚndarray)r   Úvr   r   r   Ú	<genexpr>"   r   zupdate.<locals>.<genexpr>Né
   r   c                      s   ˆj  ˆ ¡S r   )ÚdataÚupdater   ©r	   Úsourcer   r   Ú<lambda>0   r   zupdate.<locals>.<lambda>)r   Úanyr   ÚvaluesÚlenr   ÚitemsÚtyper   r   r   ZarrayÚ	PROFILINGr   Zadd_next_tick_callbackr   )r   r   r   r   r   r   r   r      s    
r   )Znumbersr   ZbokehZbokeh.core.propertiesr   Zbokeh.ior   Zpackaging.versionr   Zparse_versionZtlz.curriedr   Znumpyr   ÚImportErrorÚ__version__ZBOKEH_VERSIONr#   r   r   r   r   r   r   Ú<module>   s   

