a
    yn„fŸ  ã                   @  s®   d dl mZ d dlmZ d dlmZ d dlmZmZ dZ	ddœddd	d	d
œdd„Z
dddd	dœdd„Zddœdddddœdd„Zddœdddddœdd„Zdd	dœdd„ZdS )é    )Úannotations)Ú
Collection)Úchain)ÚJSONMappingÚJSONSerializable)Z	__array__Z__list__Z
__record__Z__categorical__F)Úallow_missingzJSONMapping | NoneÚbool)ÚoneÚtwor   Úreturnc                C  s˜   | d u r|d u rdS | d u r@t D ]}| |¡d ur |  S q dS |d u rlt D ]}|  |¡d urL|  S qLdS t D ]}|  |¡| |¡krp dS qpdS d S ©NTF)ÚTYPE_PARAMETERSÚget)r	   r
   r   Úkey© r   úV/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/_parameters.pyÚtype_parameters_equal   s     

r   )r	   r
   r   c                 C  s   | d u r|d u rdS | d u rd|rBt D ]}| |¡d ur$ dS q$dS | ¡ D ]}|d urJ dS qJdS n˜|d u r´|r’t D ]}|  |¡d urt dS qtdS |  ¡ D ]}|d urš dS qšdS nH|r¾t }nt|  ¡ ƒ | ¡ ¡}|D ]}|  |¡| |¡krØ dS qØdS d S r   )r   r   ÚvaluesÚsetÚkeysÚunion)r	   r
   Zonly_array_recordr   Úvaluer   r   r   r   Úparameters_are_equal(   s:    r   N)Úexcludez/Collection[tuple[str, JSONSerializable]] | None)ÚleftÚrightr   r   c                  s    | du s|du rdS t |  ¡ | ¡ @ ƒ}|duo:t|ƒdk}d}|D ]V‰ | ˆ  ‰ˆdurDˆ|ˆ  krD|r€t‡ ‡fdd„|D ƒƒsD|du r’ˆ ˆi}qDˆ|ˆ < qD|S )zâ
    Args:
        left: first parameters mapping
        right: second parameters mapping
        exclude: collection of keys to exclude

    Returns the intersected key-value pairs of `left` and `right` as a dictionary.
    Nr   c                 3  s   | ]}|ˆ ˆfkV  qd S ©Nr   ©Ú.0Úpair©r   Z
left_valuer   r   Ú	<genexpr>o   ó    z'parameters_intersect.<locals>.<genexpr>)Úiterr   ÚlenÚany)r   r   r   Zcommon_keysÚhas_exclusionsÚresultr   r    r   Úparameters_intersectR   s&    ÿ
þüü

r(   c                  s¤   |duot |ƒdk}g }| dur.| |  ¡ ¡ |durD| | ¡ ¡ d}t |¡D ]L‰ ˆ \}}|du rhqR|r„t‡ fdd„|D ƒƒr„qR|du r–||i}qR|||< qR|S )zã
    Args:
        left: first parameters mapping
        right: second parameters mapping
        exclude: collection of key items to exclude

    Returns the merged key-value pairs of `left` and `right` as a dictionary.

    Nr   c                 3  s   | ]}|ˆ kV  qd S r   r   r   ©Úitemr   r   r!   •   r"   z#parameters_union.<locals>.<genexpr>)r$   ÚappendÚitemsr   Úfrom_iterabler%   )r   r   r   r&   r,   Ú
parametersr   r   r   r)   r   Úparameters_unionz   s"    

r/   )r.   r   c                 C  s,   | du rdS |   ¡ D ]}|dur dS qdS )a  
    Args:
        parameters (dict or None): parameters dictionary, or None

    Return True if the parameters dictionary is considered empty, either because it is
    None, or because it does not have any meaningful (non-None) values; otherwise,
    return False.
    NTF)r   )r.   r*   r   r   r   Úparameters_are_emptyŸ   s    	r0   )F)Ú
__future__r   Úcollections.abcr   Ú	itertoolsr   Zawkward._typingr   r   r   r   r   r(   r/   r0   r   r   r   r   Ú<module>   s   ÿ ÿ.ü,ü%