a
    yn„fg  ã                   @  sP   d dl mZ d dlZd dlmZ d dlmZ dZeƒ ddœdd	„ƒZ	d
d„ Z
dS )é    )ÚannotationsN)ÚNumpyBackend)Úhigh_level_function)Úto_numpyT©Úallow_missingc                c  s   | fV  t | |ƒS )a]  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).
        allow_missing (bool): allow missing (None) values.

    Converts `array` (many types supported, including all Awkward Arrays and
    Records) into a NumPy array, if possible.

    If the data are numerical and regular (nested lists have equal lengths
    in each dimension, as described by the #ak.Array.type), they can be losslessly
    converted to a NumPy array and this function returns without an error.

    Otherwise, the function raises an error. It does not create a NumPy
    array with dtype `"O"` for `np.object_` (see the
    [note on object_ type](https://docs.scipy.org/doc/numpy/reference/arrays.scalars.html#arrays-scalars-built-in))
    since silent conversions to dtype `"O"` arrays would not only be a
    significant performance hit, but would also break functionality, since
    nested lists in a NumPy `"O"` array are severed from the array and
    cannot be sliced as dimensions.

    If `array` is not an Awkward Array, then this function is equivalent
    to calling `np.asarray` on it.

    If `allow_missing` is True; NumPy
    [masked arrays](https://docs.scipy.org/doc/numpy/reference/maskedarray.html)
    are a possible result; otherwise, missing values (None) cause this
    function to raise an error.

    See also #ak.from_numpy and #ak.to_cupy.
    )Ú_impl)Úarrayr   © r
   úa/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_to_numpy.pyr      s    !r   c                 C  sd   dd l }|jdd��< tj| dd�}t ¡ }| |¡}|j|d�W  d   ƒ S 1 sV0    Y  d S )Nr   Úignore)ÚinvalidF)Zallow_recordr   )ÚnumpyZerrstateÚakZ	to_layoutr   ÚinstanceZ
to_backendZto_backend_array)r	   r   r   ZlayoutÚbackendZnumpy_layoutr
   r
   r   r   3   s    
r   )Ú
__future__r   Zawkwardr   Zawkward._backends.numpyr   Zawkward._dispatchr   Ú__all__r   r   r
   r
   r
   r   Ú<module>   s   &