a
    tDf.'                     @  s  d dl mZ d dlmZ d dlmZ d dlZd dlm	Z	 d dl
mZmZmZmZmZ d dlmZmZ d dlmZ d d	lmZmZ efd
dZG dd dZeedd ZG dd dZeejZeejZeejZeejZeej Z eej!Z!eej"Z"eej#Z#eej$Z$eej%Z%eej&Z&eej'Z'eej(Z(eej)Z)eej* Z+Z*eej,Z,eej-Z-eej.Z.eej/Z/eej0Z0eej1Z1eej2Z2eej3Z3eej4Z4eej5Z5eej6Z6eej7Z7eej8Z8eej9Z9eej:Z:eej;Z;eej<Z<eej=Z=eej>Z>eej?Z?eej@Z@eejAZAeejBZBeejCZCeejDZDeejEZEeejFZFeejGZGeejHZHeejIZIeejJZJeejKZKeejLZLeeLejM ZNeeLejMZOeejPZPeejQZQeejRZReejSZSeejTZTeejUZUeejVZVeejWZWeejXZXeejYZYeejZZZeej[Z[e[Z\eej]Z]eej^Z^eej_Z_eej`Z`eejaZaeejbZbeejcZceejdZdeejeZeeejfZfeejgZgeejhZheejiZieejjZjeejkZkeejlZleejmZmeejnZneejoZoeejpZpepZqeejrZreejsZseejtZteejuZueejvZveejwZweejxZxeejyZyeejzZzeedddZ{eedd Z|eedd Z}eedd Z~dS )    )annotations)partialgetitemN)core)Arrayapply_infer_dtypeasarray	blockwiseelemwise)is_dask_collectionnormalize_token)HighLevelGraph)derived_fromfuncnamec                   s     fdd} j |_ t||S )z&Wrap up numpy function into dask.arrayc                    sH   dd | D }t |dkr6|d j g| R i |S  | i |S d S )Nc                 S  s   g | ]}t |d r|qS 	_elemwisehasattr.0arg r   ]/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/dask/array/ufunc.py
<listcomp>       z2wrap_elemwise.<locals>.wrapped.<locals>.<listcomp>r   )lenr   )argskwargsdsknumpy_ufuncr   r   wrapped   s    zwrap_elemwise.<locals>.wrapped)__name__r   )r!   sourcer"   r   r    r   wrap_elemwise   s    r%   c                   @  sH   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dS )da_frompyfuncz"A serializable `frompyfunc` objectc                 C  s<   t |||| _|| _|| _|| _t|| _d| j | _d S )Nzfrompyfunc-%s)	np
frompyfunc_ufunc_funcninnoutr   _namer#   )selffuncr+   r,   r   r   r   __init__!   s    
zda_frompyfunc.__init__c                 C  s   d| j | j| jf S )Nzda.frompyfunc<%s, %d, %d>)r-   r+   r,   r.   r   r   r   __repr__)   s    zda_frompyfunc.__repr__c                 C  s   t | j| j| jfS N)r   r*   r+   r,   r1   r   r   r   __dask_tokenize__,   s    zda_frompyfunc.__dask_tokenize__c                 C  s   t | j| j| jffS r3   )r&   r*   r+   r,   r1   r   r   r   
__reduce__/   s    zda_frompyfunc.__reduce__c                 O  s   | j |i |S r3   )r)   )r.   r   r   r   r   r   __call__2   s    zda_frompyfunc.__call__c                 C  s2   | dst| j|S tt| jd|d S )N_ object has no attribute )
startswithgetattrr)   AttributeErrortyper#   )r.   ar   r   r   __getattr__5   s    
zda_frompyfunc.__getattr__c                 C  s4   t tt| }|| j |t| j t|S r3   )setdirr<   update__dict__r)   list)r.   or   r   r   __dir__:   s    zda_frompyfunc.__dir__N)r#   
__module____qualname____doc__r0   r2   r4   r5   r6   r>   rE   r   r   r   r   r&      s   r&   c                 C  s    |dkrt dtt| ||S )N   z$frompyfunc with more than one output)NotImplementedErrorufuncr&   )r/   r+   r,   r   r   r   r(   A   s    r(   c                   @  sV   e Zd Zh dZdd Zdd Zdd Zdd	 Zd
d Zdd Z	e
ejdd ZdS )rK   >   	signaturer,   Zntypesr+   typesnargsidentityc                 C  sL   t |tjtfs"tdt|j || _|j| _t |tjrHtt|  d S )Nz:must be an instance of `ufunc` or `da_frompyfunc`, got `%s)	
isinstancer'   rK   r&   	TypeErrorr<   r#   r)   r   )r.   rK   r   r   r   r0   S   s    zufunc.__init__c                 C  s   | j t| jfS r3   )r#   r   r)   r1   r   r   r   r4   ^   s    zufunc.__dask_tokenize__c                 C  s2   || j v rt| j|S tt| jd|d S )Nr8   )_forward_attrsr:   r)   r;   r<   r#   )r.   keyr   r   r   r>   a   s    
zufunc.__getattr__c                 C  s   t | jtt| | jS r3   )rC   rR   unionr@   r<   rB   r1   r   r   r   rE   f   s    zufunc.__dir__c                 C  s
   t | jS r3   )reprr)   r1   r   r   r   r2   i   s    zufunc.__repr__c                 O  sz   dd |D }t |dkrf|D ]6}|j| jg|R i |}t|ttkr|  S qtd| j n| j|i |S d S )Nc                 S  s   g | ]}t |d r|qS r   r   r   r   r   r   r   m   r   z"ufunc.__call__.<locals>.<listcomp>r   z.Parameters of such types are not supported by )r   r   r)   r<   NotImplementedrQ   r#   )r.   r   r   Zdsksr   resultr   r   r   r6   l   s    
zufunc.__call__c                 K  s   | j dkrtdd|v r"tdt|}t|}|sP|sP| jj||fi |S |r^t|trl|rtt|tsttdt|}t|}|j	|j	 }t
t|}|d |j	 }||j	d  }	t| jj||g|ddd}
d	|v rt| jj|d	d
}n| jj}t||||||	f|
| jd d|S )N   z1outer product only supported for binary functionsoutz`out` kwarg not supportedzGDask objects besides `dask.array.Array` are not supported at this time.ufunc.outerF)Zsuggest_dtypedtyper[   z.outer)r[   token)r+   
ValueErrorr   r)   outerrP   r   rJ   r	   ndimtupleranger   r   popr
   r#   )r.   ABr   Z	A_is_daskZ	B_is_daskr`   Zout_indsZA_indsZB_indsr[   r/   r   r   r   r_   y   sX    
	rZ   N)r#   rF   rG   rR   r0   r4   r>   rE   r2   r6   r   r'   rK   r_   r   r   r   r   rK   H   s   
rK   c                 C  s0   t |}t| dr"| tj| |S tj| |dS )Nr   )deg)boolr   r   r'   angle)xrf   r   r   r   rh     s    
rh   c           
        s   t tj| td}d|j  d|j  fddt| D }fddt| D }tjt	| d| d| j
 | jd	}t|\}}tj ||gd
}t| |j|d}tj||gd
}t||j|d}	||	fS )Nr\   z	mantissa-z	exponent-c                   s&   i | ]} f|d d  t |dfqS rI   Nr   r   r   rS   leftr   r   
<dictcomp>-  s   zfrexp.<locals>.<dictcomp>c                   s&   i | ]} f|d d  t |d fqS rI   Nr   rk   rightr   r   rn   1  s   _metarI   shaper[   Zdependencieschunksmeta)r   r'   frexpobjectnamer   flatten__dask_keys__Z
empty_liker:   r`   r[   r   from_collectionsr   rx   
ri   tmpZldskZrdskr=   lrgraphLRr   rm   rq   r   rz   '  s     



 rz   c           
        s   t tj| td}d|j  d|j  fddt| D }fddt| D }tjt	| d| d| j
 | jd	}t|\}}tj ||gd
}t| |j|d}tj||gd
}t||j|d}	||	fS )Nr\   zmodf1-zmodf2-c                   s&   i | ]} f|d d  t |dfqS rj   r   rk   rl   r   r   rn   F  s   zmodf.<locals>.<dictcomp>c                   s&   i | ]} f|d d  t |d fqS ro   r   rk   rp   r   r   rn   J  s   rr   rs   rt   rv   rw   )r   r'   modfr{   r|   r   r}   r~   Z	ones_liker:   r`   r[   r   r   r   rx   r   r   r   r   r   @  s     



 r   c                 C  s   | | }| | }||fS r3   r   )ri   yZres1Zres2r   r   r   divmodY  s    r   )r   )
__future__r   	functoolsr   operatorr   numpyr'   Zdaskr   Zdask.array.corer   r   r	   r
   r   Z	dask.baser   r   Zdask.highlevelgraphr   Z
dask.utilsr   r   r%   r&   r(   rK   addsubtractmultiplydivideZ	logaddexpZ
logaddexp2Ztrue_divideZfloor_dividenegativeZpositivepowerZfloat_power	remaindermod	conjugateZconjexpZexp2loglog2log10log1pexpm1sqrtZsquareZcbrtZ
reciprocalsincostanZarcsinZarccosZarctanZarctan2hypotsinhcoshtanhZarcsinhZarccoshZarctanhZdeg2radZrad2degZgreaterZgreater_equalZlessZ
less_equal	not_equalequalinfZisneginfZisposinflogical_and
logical_orlogical_xorZlogical_notmaximumZminimumZfmaxZfminZbitwise_andZ
bitwise_orZbitwise_xorZbitwise_notinvertZ
left_shiftZright_shiftisfiniteisinfisnanZsignbitcopysign	nextafterspacingldexpfmodfloorceiltruncdegreesradiansZrintfabssignabsoluteabsZclipZisrealZ	iscomplexrealimagZfixZi0ZsincZ
nan_to_numrh   rz   r   r   r   r   r   r   <module>   s   #
h

























































































