a
    yn„f¦	  ã                   @  sŽ   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 dl
mZ dZe ¡ Zeƒ dddd	œd
d„ƒZdd„ Zejj d¡efdd„ƒZdS )é    )ÚannotationsN)ÚUNSUPPORTED)Úhigh_level_function)ÚHighLevelContext)ÚNumpyMetadata©ÚravelT)Ú	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.

    Returns an array with all level of nesting removed by erasing the
    boundaries between consecutive lists.

    This is the equivalent of NumPy's `np.ravel` for Awkward Arrays.

    Consider the following:

        >>> array = ak.Array([[[1.1, 2.2, 3.3],
        ...                    [],
        ...                    [4.4, 5.5],
        ...                    [6.6]],
        ...                   [],
        ...                   [[7.7],
        ...                    [8.8, 9.9]
        ...                   ]])

    Ravelling the array produces a flat array

        >>> ak.ravel(array).show()
        [1.1,
         2.2,
         3.3,
         4.4,
         5.5,
         6.6,
         7.7,
         8.8,
         9.9]

    Missing values are not eliminated by flattening. See #ak.flatten with
    `axis=None` for an equivalent function that eliminates the option type.
    )Ú_impl)Úarrayr	   r
   r   © r   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_ravel.pyr      s    -r   c                 C  sˆ   t ||d�� }|j| ddd�}W d   ƒ n1 s20    Y  tjj|ddd�}t|tƒrjtdd„ |D ƒƒsnJ ‚tj |¡}|j	||d	�S )
N)r
   r   FÚerror)Zallow_recordZprimitive_policyzak.ravel)Zfunction_nameZ
drop_nonesc                 s  s   | ]}t |tjjƒV  qd S ©N)Ú
isinstanceÚakÚcontentsZContent)Ú.0Úxr   r   r   Ú	<genexpr>H   s   z_impl.<locals>.<genexpr>)r	   )
r   Úunwrapr   Z_doZremove_structurer   ÚtupleÚallZ	mergemanyÚwrap)r   r	   r
   r   ÚctxZlayoutÚoutÚresultr   r   r   r   C   s    .ÿr   c                 C  s   t | ƒS r   r   )ÚaÚorderr   r   r   Ú_nep_18_implQ   s    r!   )Ú
__future__r   Zawkwardr   Zawkward._connect.numpyr   Zawkward._dispatchr   Zawkward._layoutr   Zawkward._nplikes.numpy_liker   Ú__all__ÚinstanceÚnpr   r   Ú_connectÚnumpyZ
implementsr!   r   r   r   r   Ú<module>   s   2