o
    Nrf.'                     @  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                    sD   dd | D }t |dkr|d j g| R i |S  | i |S )Nc                 S     g | ]	}t |d r|qS 	_elemwisehasattr.0arg r   Y/var/www/html/software/conda/envs/catlas/lib/python3.10/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__)      zda_frompyfunc.__repr__c                 C  s   t | j| j| jfS N)r   r+   r,   r-   r2   r   r   r   __dask_tokenize__,   r4   zda_frompyfunc.__dask_tokenize__c                 C  s   t | j| j| jffS r5   )r'   r+   r,   r-   r2   r   r   r   
__reduce__/   r4   zda_frompyfunc.__reduce__c                 O  s   | j |i |S r5   )r*   )r/   r   r   r   r   r   __call__2      zda_frompyfunc.__call__c                 C  s.   | dst| j|S tt| jd|)N_ object has no attribute )
startswithgetattrr*   AttributeErrortyper$   )r/   ar   r   r   __getattr__5      
zda_frompyfunc.__getattr__c                 C  s4   t tt| }|| j |t| j t|S r5   )setdirr?   update__dict__r*   list)r/   or   r   r   __dir__:   s   zda_frompyfunc.__dir__N)r$   
__module____qualname____doc__r1   r3   r6   r7   r8   rA   rI   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'   )r0   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 )rO   >   r-   identitytypesr,   nargsZntypes	signaturec                 C  sP   t |tjtfstdt|j || _|j| _t |tjr&tt|  d S d S )Nz:must be an instance of `ufunc` or `da_frompyfunc`, got `%s)	
isinstancer(   rO   r'   	TypeErrorr?   r$   r*   r   )r/   rO   r   r   r   r1   S   s   zufunc.__init__c                 C  s   | j t| jfS r5   )r$   r   r*   r2   r   r   r   r6   ^   r9   zufunc.__dask_tokenize__c                 C  s.   || j v rt| j|S tt| jd|)Nr;   )_forward_attrsr=   r*   r>   r?   r$   )r/   keyr   r   r   rA   a   rB   zufunc.__getattr__c                 C  s   t | jtt| | jS r5   )rG   rV   unionrD   r?   rF   r2   r   r   r   rI   f   s   zufunc.__dir__c                 C  s
   t | jS r5   )reprr*   r2   r   r   r   r3   i   s   
zufunc.__repr__c                 O  st   dd |D }t |dkr2|D ]}|j| jg|R i |}t|ttkr*|  S qtd| j | j|i |S )Nc                 S  r   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?   NotImplementedrU   r$   )r/   r   r   Zdsksr    resultr   r   r   r8   l   s   zufunc.__call__c                 K  s   | j dkr	tdd|v rtdt|}t|}|s(|s(| jj||fi |S |r/t|tr6|r:t|ts:tdt|}t|}|j	|j	 }t
t|}|d |j	 }||j	d  }	t| jj||g|ddd}
d	|v ryt| 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*   outerrT   r   rN   r	   ndimtupleranger   r   popr
   r$   )r/   ABr   Z	A_is_daskZ	B_is_daskrd   Zout_indsZA_indsZB_indsr_   r0   r   r   r   rc   y   sX   
	r^   N)r$   rJ   rK   rV   r1   r6   rA   rI   r3   r8   r   r(   rO   rc   r   r   r   r   rO   H   s    
rO   c                 C  s0   t |}t| dr| tj| |S tj| |dS )Nr   )deg)boolr   r   r(   angle)xrj   r   r   r   rl     s   
rl   c           
           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                   &   i | ]} f|d d  t |dfqS rM   Nr   r   r   rW   leftr   r   
<dictcomp>-      zfrexp.<locals>.<dictcomp>c                   &   i | ]} f|d d  t |d fqS rM   Nr   rq   rightr   r   rt   1  ru   _metarM   shaper_   dependencieschunksmeta)r   r(   frexpobjectnamer   flatten__dask_keys__Z
empty_liker=   rd   r_   r   from_collectionsr   r   
rm   tmpZldskZrdskr@   lrgraphLRr   rs   ry   r   r   '      



 r   c           
        rn   )Nr`   zmodf1-zmodf2-c                   ro   rp   r   rq   rr   r   r   rt   F  ru   zmodf.<locals>.<dictcomp>c                   rv   rw   r   rq   rx   r   r   rt   J  ru   rz   r{   r|   r~   r   )r   r(   modfr   r   r   r   r   Z	ones_liker=   rd   r_   r   r   r   r   r   r   r   r   r   @  r   r   c                 C  s   | | }| | }||fS r5   r   )rm   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)   rO   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_equallessZ
less_equal	not_equalequalinfZisneginfZisposinflogical_and
logical_orlogical_xorZlogical_notmaximum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_numrl   r   r   r   r   r   r   r   <module>   s    #

h
























































































