a
    yn„fð  ã                   @  sz   d dl mZ 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Ze ¡ Ze	ƒ ddddd	d
dœdd„ƒZdd„ ZdS )é    )Úannotations)ÚIterable)Ú_extN)Úhigh_level_function)ÚNumpyMetadata)Ú	from_iterTi   é   )Úallow_recordÚ	highlevelÚbehaviorÚattrsÚinitialÚresizec                C  s   t | ||||||ƒS )aK  
    Args:
        iterable (Python iterable): Data to convert into an Awkward Array.
        allow_record (bool): If True, the outermost element may be a record
            (returning #ak.Record or #ak.record.Record type, depending on
            `highlevel`); if False, the outermost element must be an array.
        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.
        initial (int): Initial size (in bytes) of buffers used by the `ak::ArrayBuilder`.
        resize (float): Resize multiplier for buffers used by the `ak::ArrayBuilder`;
            should be strictly greater than 1.

    Converts Python data into an Awkward Array.

    Any heterogeneous and deeply nested Python data can be converted, but the output
    will never have regular-typed array lengths. Internally, this function uses
    `ak::ArrayBuilder` (see the high-level #ak.ArrayBuilder documentation for a
    more complete description).

    The following Python types are supported.

    * bool, including `np.bool_`: converted into #ak.contents.NumpyArray.
    * int, including `np.integer`: converted into #ak.contents.NumpyArray.
    * float, including `np.floating`: converted into #ak.contents.NumpyArray.
    * bytes: converted into #ak.contents.ListOffsetArray with parameter
      `"__array__"` equal to `"bytestring"` (unencoded bytes).
    * str: converted into #ak.contents.ListOffsetArray with parameter
      `"__array__"` equal to `"string"` (UTF-8 encoded string).
    * tuple: converted into #ak.contents.RecordArray without field names
      (i.e. homogeneously typed, uniform sized tuples).
    * dict: converted into #ak.contents.RecordArray with field names
      (i.e. homogeneously typed records with the same sets of fields).
    * iterable, including np.ndarray: converted into
      #ak.contents.ListOffsetArray.

    See also #ak.to_list.
    )Ú_impl)Úiterabler	   r
   r   r   r   r   © r   úb/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_from_iter.pyr      s    4r   c                 C  s¼   t | tƒstdt| ƒ›d�ƒ‚t | tƒrN|rFt| g||d|||ƒd S tdƒ‚t | tƒr`t| ƒ} t	j
||d�}| | ¡ | ¡ \}}	}
tj |¡}tjjj||	|
ddtjj||d	|d
�
d S )Nz4cannot produce an array from a non-iterable object (ú)Fr   zCcannot produce an array from a single dict (that would be a record))r   r   z{form_key}-{attribute}ÚcpuT)Z
buffer_keyÚbackendÚ	byteorderr
   r   Úsimplifyr   )Ú
isinstancer   Ú	TypeErrorÚtypeÚdictr   Ú
ValueErrorÚtupleÚlistr   ZArrayBuilderZfromiterZ
to_buffersÚakZformsÚ	from_jsonÚ
operationsZak_from_buffersZ_utilZnative_byteorder)r   r
   r   r	   r   r   r   ÚbuilderZformstrÚlengthÚbuffersÚformr   r   r   r   I   sP    
ÿ
ùø
ÿ

öõr   )Ú
__future__r   Úcollections.abcr   Zawkward_cpp.libr   Zawkwardr   Zawkward._dispatchr   Zawkward._nplikes.numpy_liker   Ú__all__ÚinstanceÚnpr   r   r   r   r   r   Ú<module>   s    ø6