a
    yn„fs  ã                   @  sZ   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	ddd
œdd„ƒZ	dd„ Z
dS )é    )ÚannotationsN)Úhigh_level_function)ÚHighLevelContext)Úslicezak.str)Úmoduleé   T)Ú	highlevelÚbehaviorÚattrsc                c  s   | fV  t | ||||||ƒS )a™  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).
        start (int): Index to start slicing at (inclusive).
        stop (None or int): Index to stop slicing at (exclusive). If not given,
            slicing will stop at the end.
        step (int): Slice step.
        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.

    Replaces any string or bytestring-valued data with a slice between `start`
    and `stop` indexes; `start` is inclusive and `stop` is exclusive and both
    are 0-indexed.

    For strings, `start` and `stop` are measured in Unicode characters; for
    bytestrings, `start` and `stop` are measured in bytes.

    The `start`, `stop`, and `replacement` are scalars; they cannot be
    different for each string/bytestring in the sample.

    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.utf8_slice_codeunits](https://arrow.apache.org/docs/python/generated/pyarrow.compute.utf8_slice_codeunits.html)
    or performs a literal slice on strings and bytestrings, respectively.
    )Ú_impl)ÚarrayÚstartÚstopÚstepr   r	   r
   © r   úe/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/str/akstr_slice.pyr      s    $r   c                   s�   ddl m} ddlm‰  |dƒ‰‡ ‡‡‡‡fdd„}t||d��$}	|	j| ddd	d
d�}
W d   ƒ n1 sj0    Y  tj |
|¡}|	j	||d�S )Nr   )Úimport_pyarrow_compute)Ú_apply_through_arrowzak.str.slicec                   sT   | j r&|  d¡dkr&ˆ ˆj| ˆˆˆƒS | j rP|  d¡dkrP| d d …ˆˆˆ…f S d S )NZ	__array__ÚstringÚ
bytestring)Zis_listZ	parameterZutf8_slice_codeunits)ÚlayoutZabsorb©r   Zpcr   r   r   r   r   Úaction<   s    ÿz_impl.<locals>.action)r	   r
   FÚerrorzas-characters)Zallow_recordZallow_unknownZprimitive_policyZstring_policy)r   )
Zawkward._connect.pyarrowr   Zawkward.operations.strr   r   ÚunwrapÚakZ_doZrecursively_applyÚwrap)r   r   r   r   r   r	   r
   r   r   Úctxr   Úoutr   r   r   r   6   s    	û$r   )Nr   )Ú
__future__r   Zawkwardr   Zawkward._dispatchr   Zawkward._layoutr   Ú__all__r   r   r   r   r   r   Ú<module>   s    ÿÿ)