a
    yn„fO  ã                   @  s®   U d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 d dl
mZmZ edƒZi Zded< g Zd	ed
< eddd�Zdddœdd„Zeded�Zedœddddœdd„ZdS )é    )Úannotations)Ú	ArrayLike)Ú	NumpyLike)ÚAnyÚTypeVarÚcast)ÚUNSETÚSentinelÚDzdict[type, NumpyLike]Ú_type_to_nplikezlist[type[NumpyLike]]Ú_nplike_classesÚNztype[NumpyLike])Úbound)ÚclsÚreturnc                 C  s   t  | ¡ | S )N)r   Úappend)r   © r   ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/_nplikes/dispatch.pyÚregister_nplike   s    
r   Ú
ArrayLikeT)Údefaultr   zD | SentinelzNumpyLike[ArrayLikeT] | D)Úobjr   r   c                C  s~   t | ƒ}z
t| W S  tyx   tD ]}| |¡r$| ¡ } qhq$|tu rZtd|j› �ƒ‚nt	t
|ƒ Y S |t|< | Y S 0 dS )aL  
    Args:
        *arrays: iterable of possible array objects
        default: default NumpyLike instance if no array objects found

    Return the nplike that is best-suited to operating upon the given
    iterable of arrays. If no known array types are found, return `default`
    if it is set, otherwise `Numpy.instance()`.
    zcannot find nplike for N)Útyper   ÚKeyErrorr   Zis_own_array_typeÚinstancer   Ú	TypeErrorÚ__name__r   r
   )r   r   r   Z
nplike_clsZnpliker   r   r   Únplike_of_obj   s    

r   N)Ú
__future__r   Zawkward._nplikes.array_liker   Zawkward._nplikes.numpy_liker   Zawkward._typingr   r   r   Zawkward._utilr   r	   r
   r   Ú__annotations__r   r   r   r   r   r   r   r   r   Ú<module>   s   ÿ