a
    yn„f[  ã                   @  sN   d dl mZ d dlZd dlZd dlZdZddd„Zdd„ Zddd	œd
d„Z	dS )é    )ÚannotationsN)Úmixin_classÚmixin_class_methodc                   s   ‡ ‡fdd„}|S )a  
    Args:
        registry (dict): The destination behavior mapping registry. Typically,
            this would be the global registry #ak.behavior, but one may wish
            to register methods in an alternative way.
        name (str): The name to assign to the behaviour class.

    This decorator can be used to register a behavior mixin class.

    Any inherited behaviors will automatically be made available to the decorated
    class.

    See the "Mixin decorators" section of #ak.behavior for further details.
    c                   sH  | j }ˆ d u r|}nˆ }t|d | tjjfd| jiƒ}ttj| j |d |ƒ |ˆ|< t|d | tjj	fd| jiƒ}ttj| j |d |ƒ |ˆd|f< |  
¡ D ]¢}|j ¡ D ]’}t|dƒr®|j\}}}	|d u râˆ ||f|¡ q®g t|ƒ¢|‘D ]8}
ˆ |||
f|¡ |	d urò|
|kròˆ ||
|f|	¡ qò|j |v r®| |¡ q®q | S )NÚRecordÚ
__module__ÚArrayÚ*Ú_awkward_mixin)Ú__name__ÚtypeÚakZ	highlevelr   r   ÚsetattrÚsysÚmodulesr   ÚmroÚ__dict__ÚvaluesÚhasattrr	   Ú
setdefaultÚlistÚadd)ÚclsÚcls_nameZbehavior_nameÚrecordÚarrayZbaseclsÚmethodÚufuncÚrhsÚ	transposeZrhs_name©ÚnameÚregistry© ú[/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/behaviors/mixins.pyÚregister   sD    
ý
ý

ÿ
zmixin_class.<locals>.registerr"   )r!   r    r$   r"   r   r#   r      s    &r   c                 C  s
   | ||ƒS )Nr"   )ÚfuncÚleftÚrightr"   r"   r#   Ú_call_transposedF   s    r(   T)r   c                  s   ‡ ‡‡fdd„}|S )a(  
    Args:
        ufunc (numpy.ufunc): A universal function (or NEP18 callable) that is
            hooked in Awkward Array, i.e. it can be the first argument of a behavior.
        rhs (Set[type] or None): Set of right-hand side argument types, optional
            if wrapping a unary function. The left-hand side is expected to
            always be `self` of the parent class. The current class is implicitly
            included in this set.
        transpose (bool): If true, automatically create a transpose signature
            (only makes sense for binary ufuncs).

    This decorator can be used to register a mixin class method.

    Using this decorator ensures that derived classes that are declared with the
    #ak.mixin_class decorator will also have the behaviors that this class has.
    c                   sP   t ˆ ttd ƒfƒstdƒ‚ˆr@ˆ d ur@ˆtˆ ƒt t| ¡f| _nˆˆ d f| _| S )Nz0expected a set of right-hand-side argument types)Ú
isinstanceÚsetr   Ú
ValueErrorÚ	functoolsÚpartialr(   r	   )r   ©r   r   r   r"   r#   r$   \   s    
ýz$mixin_class_method.<locals>.registerr"   )r   r   r   r$   r"   r.   r#   r   J   s    r   )N)N)
Ú
__future__r   r,   r   Zawkwardr   Ú__all__r   r(   r   r"   r"   r"   r#   Ú<module>   s   
9