a
    yn„fÇ  ã                   @  st   d dl mZ d dlmZ d dlZd dlmZ d dlm	Z	 d dl
mZ dZe ¡ Zeƒ dddd	œd
d„ƒZdd„ ZdS )é    )Úannotations)ÚSequenceN)Úhigh_level_function)ÚHighLevelContext)ÚNumpyMetadata)Úwithout_fieldT)Ú	highlevelÚbehaviorÚattrsc                c  s   | fV  t | ||||ƒS )a  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).
        where (str or non-empy sequence of str): If str, the name of the field
            to be removed. If a sequence, it is interpreted as a path where to
            remove the field in a nested record.
        highlevel (bool): If True, return an #ak.Array; otherwise, return
            a low-level #ak.contents.Content subclass.
        behavior (None or dict): Custom #ak.behavior for the output array, if
            high-level.
        attrs (None or dict): Custom attributes for the output array, if
            high-level.

    Returns an #ak.Array or #ak.Record (or low-level equivalent, if
    `highlevel=False`) with an existing field removed. This function does not
    change the array in-place.

    See #ak.Array.__delitem__ and #ak.Record.__delitem__ for a variant that
    changes the high-level object in-place. (These methods internally use
    #ak.without_field, so performance is not a factor in choosing one over the
    other.)
    )Ú_impl)ÚarrayÚwherer   r	   r
   © r   úf/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_without_field.pyr      s    r   c                   s¢   t |tƒr|g}n$t |tƒr.tdd„ |D ƒƒs6tdƒ‚t||d�� }|j| ddd�} W d   ƒ n1 sh0    Y  ‡ fdd	„‰ tjj	| ˆ d
|id�}|j
||d�S )Nc                 s  s   | ]}t |tƒV  qd S )N)Ú
isinstanceÚstr)Ú.0Úxr   r   r   Ú	<genexpr>3   ó    z_impl.<locals>.<genexpr>zFField names must be given as a single string, or a sequence of strings)r	   r
   TÚerror)Zallow_recordZprimitive_policyc           
        sØ   t | tjjƒrÐ|d ^}}|  |¡‰ t|ƒr„g }t| jƒD ]<\}}|ˆ krltjj|ˆd|id�}| 	|¡ q:| 	|¡ q:| j
|d�S ‡ fdd„t| jƒD ƒ}| jr¨d }	n‡ fdd„t| jƒD ƒ}	| j
||	d�S nd S d S )Nr   ©Údepth_context)Úcontentsc                   s   g | ]\}}|ˆ kr|‘qS r   r   )r   ÚiÚc©Zi_fieldr   r   Ú
<listcomp>R   s   z)_impl.<locals>.action.<locals>.<listcomp>c                   s   g | ]\}}|ˆ kr|‘qS r   r   )r   r   Úfr   r   r   r   Y   s   )r   Úfields)r   Úakr   ZRecordArrayZfield_to_indexÚlenÚ	enumerateÚ_doÚrecursively_applyÚappendÚcopyÚis_tupler   )
Zlayoutr   ÚkwargsÚfieldZ
next_whereZnext_contentsr   ÚcontentZnext_contentZnext_fields©Úactionr   r   r,   ;   s2    
ý
ÿ
ÿz_impl.<locals>.actionr   r   )r   )r   r   r   ÚallÚ	TypeErrorr   Úunwrapr    r#   r$   Úwrap)Úbaser   r   r	   r
   ÚctxÚoutr   r+   r   r   0   s    
ÿ.&r   )Ú
__future__r   Úcollections.abcr   Zawkwardr    Zawkward._dispatchr   Zawkward._layoutr   Zawkward._nplikes.numpy_liker   Ú__all__ÚinstanceÚnpr   r   r   r   r   r   Ú<module>   s   