a
    yn„f
  ã                   @  sh   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 )é    )ÚannotationsN)Úhigh_level_function)ÚHighLevelContext)ÚNumpyMetadata)ÚunzipT)Ú	highlevelÚbehaviorÚattrsc                c  s   | fV  t | |||ƒS )aý  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).
        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.

    If the `array` contains tuples or records, this operation splits them
    into a Python tuple of arrays, one for each field.

    If the `array` does not contain tuples or records, the single `array`
    is placed in a length 1 Python tuple.

    For example,

        >>> array = ak.Array([{"x": 1.1, "y": [1]},
        ...                   {"x": 2.2, "y": [2, 2]},
        ...                   {"x": 3.3, "y": [3, 3, 3]}])
        >>> x, y = ak.unzip(array)
        >>> x
        <Array [1.1, 2.2, 3.3] type='3 * float64'>
        >>> y
        <Array [[1], [2, 2], [3, 3, 3]] type='3 * var * int64'>
    )Ú_impl)Úarrayr   r   r	   © r   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_unzip.pyr      s    r   c                   s¢   t ||d�� ‰ ˆ j| ddd�‰W d   ƒ n1 s20    Y  tj ˆ¡‰‡fdd„}tjjˆ|dd� tˆƒd	kr„ˆ jˆˆdd
�fS t	‡ ‡‡fdd„ˆD ƒƒS d S )N)r   r	   TÚerror)Zallow_recordZprimitive_policyc                   sN   t | tjjtjfƒr| S | jrJ| jD ]$}ttj |¡ƒtˆ ƒkr$t	dƒ‚q$d S )Nz2union of different sets of fields, cannot ak.unzip)
Ú
isinstanceÚakÚcontentsZRecordArrayZRecordZis_unionÚsetÚ
operationsÚfieldsÚ
ValueError)ÚlayoutÚkwargsÚcontent)r   r   r   Úcheck_for_union8   s    
ÿz_impl.<locals>.check_for_unionF)Zreturn_arrayr   ©r   Zallow_otherc                 3  s"   | ]}ˆ j ˆ| ˆd d�V  qdS )Tr   N)Úwrap)Ú.0Ún)Úctxr   r   r   r   Ú	<genexpr>H   s   z_impl.<locals>.<genexpr>)
r   Úunwrapr   r   r   Z_doZrecursively_applyÚlenr   Útuple)r   r   r   r	   r   r   )r   r   r   r   r   r
   3   s    .ÿr
   )Ú
__future__r   Zawkwardr   Zawkward._dispatchr   Zawkward._layoutr   Zawkward._nplikes.numpy_liker   Ú__all__ÚinstanceÚnpr   r
   r   r   r   r   Ú<module>   s   #