a
    yn„f  ã                   @  sx   d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	m
Z
 dZe ¡ Zedd�d	ddd
œdd„ƒZdd„ Zdd„ ZdS )é    )ÚannotationsN)ÚTypeTracerBackend)Úhigh_level_function)ÚHighLevelContextÚensure_same_backend)Újoinzak.str)ÚmoduleT)Ú	highlevelÚbehaviorÚattrsc                c  s   | |fV  t | ||||ƒS )an  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).
        separator (str, bytes, or array of them to broadcast): separator to
            insert between strings. If array-like, `separator` is broadcast
            against `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.

    Concatenate the strings in `array`. The `separator` is inserted between
    each string. If array-like, `separator` is broadcast against `array` which
    permits a unique separator for each list of strings in `array`.

    Note: this function does not raise an error if the `array` does not
    contain any string or bytestring data.

    Requires the pyarrow library and calls
    [pyarrow.compute.binary_join](https://arrow.apache.org/docs/python/generated/pyarrow.compute.binary_join.html).

    See also: #ak.str.join_element_wise.
    )Ú_impl)ÚarrayÚ	separatorr	   r
   r   © r   úd/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/str/akstr_join.pyr      s    
r   c                 C  s6   | j r|  d¡dv rdS | js$| jr.t| jƒS dS d S )NZ	__array__>   ÚstringÚ
bytestringTF)Úis_listZ	parameterZ	is_optionZ
is_indexedÚ!_is_maybe_optional_list_of_stringÚcontent)Úlayoutr   r   r   r   1   s
    
r   c              
     sÔ   ddl m} |dƒ‰ddlm‰  t||d��:}t|j| ddd�|j|dddd	d
�ƒ\}‰W d   ƒ n1 sl0    Y  tˆtt	fƒr¤‡ ‡‡fdd„}t
j ||¡}	n"‡ ‡fdd„}
t
j |ˆf|
¡\}	|j|	|d�S )Nr   )Úimport_pyarrow_computezak.str.join)Ú_apply_through_arrow)r
   r   FÚerror)Úallow_recordÚprimitive_policyzpass-through)r   Zallow_unknownr   Zstring_policyc                   s<   | j rt| jƒsd S ˆ ˆj| jtjj | j¡d�ˆddd�S )N©r   T©Zstring_to32Zbytestring_to32)	r   r   r   Úbinary_joinÚcopyÚakÚcontentsÚUnmaskedArrayÚ
simplified)r   Úkwargs©r   Zmaybe_separator_layoutÚpcr   r   Úapply_unaryO   s    ÿÿÿ÷z_impl.<locals>.apply_unaryc                   sv   | d j rt| d jƒsd S t| d ƒs@tdt | d ¡› �ƒ‚ˆ ˆj| d jtjj	 
| d j¡d�| d ddd�fS )Nr   é   z>`separator` must be a list of (possibly missing) strings, not r   Tr   )r   r   r   Ú	TypeErrorr    Útyper   r   r!   r"   r#   )Zlayoutsr$   )r   r&   r   r   Úapply_binaryd   s&    ÿþÿÿ÷ÿz_impl.<locals>.apply_binary)r	   )Zawkward._connect.pyarrowr   Zawkward.operations.strr   r   r   ÚunwrapÚ
isinstanceÚbytesÚstrr    Z_doZrecursively_applyZ_broadcastingZbroadcast_and_applyÚwrap)r   r   r	   r
   r   r   Úctxr   r'   Úoutr+   r   r%   r   r   :   s,    ûþ&ÿr   )Ú
__future__r   Zawkwardr    Zawkward._backends.typetracerr   Zawkward._dispatchr   Zawkward._layoutr   r   Ú__all__ÚinstanceZ
typetracerr   r   r   r   r   r   r   Ú<module>   s   !	