a
    yn„f�  ã                   @  sJ   d dl mZ d dlZd dlmZ d dlmZ dZeƒ dd„ ƒZ	dd	„ Z
dS )
é    )ÚannotationsN)ÚCupyBackend)Úhigh_level_function)Úto_cupyc                 c  s   | fV  t | ƒS )a&  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).

    Converts `array` (many types supported) into a CuPy 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 CuPy array and this function returns without an error.

    Otherwise, the function raises an error.

    If `array` is a scalar, it is converted into a CuPy scalar.

    See also #ak.from_cupy and #ak.to_numpy.
    )Ú_impl)Úarray© r   ú`/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_to_cupy.pyr      s    r   c                 C  s,   t j| dd�}t ¡ }| |¡}|jdd�S )NF)Zallow_record)Zallow_missing)ÚakZ	to_layoutr   ÚinstanceZ
to_backendZto_backend_array)r   ZlayoutÚbackendZcupy_layoutr   r   r	   r   %   s    
r   )Ú
__future__r   Zawkwardr
   Zawkward._backends.cupyr   Zawkward._dispatchr   Ú__all__r   r   r   r   r   r	   Ú<module>   s   
