
    wgK                        d Z ddlZddlZddlmZmZmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZm Z!m"Z#m$Z%m&Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 g dZ1 ejd                  ejf                        jh                  Z5d Z6d Z7d	 Z8d
 Zd Z9d*dZd*dZd*dZd*dZ d*dZ"d*dZ$d*dZ&d+dZ:d+dZ;d,dZ<d-dZ=d-dZ>d-dZ?d.dZ@d.dZAd.dZBd ZCd ZDd ZEd ZFd  ZGd! ZHd/d"ZId# ZJd+d$ZKd+d%ZLd.d&ZMd' ZNd( ZOd.d)ZPy)0zK
This module contains a set of functions for vectorized string
operations.
    N)equal	not_equalless
less_equalgreatergreater_equaladdmultiply)_vec_string)isalphaisdigitisspaceisalnumislowerisupperistitle	isdecimal	isnumericstr_lenfindrfindindexrindexcount
startswithendswith_lstrip_whitespace_lstrip_chars_rstrip_whitespace_rstrip_chars_strip_whitespace_strip_chars_replace_expandtabs_length_expandtabs)+r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   lstriprstripstripreplace
expandtabscenterljustrjustzfillupperlowerswapcase
capitalizetitlemoddecodeencode	translatec                     t        | j                  j                  t        j                        r| j
                  dz  S | j
                  S )z
    Helper function that returns the number of characters per field in
    a string or unicode array.  This is to abstract out the fact that
    for a unicode array this is itemsize / 4.
       )
issubclassdtypetypenpstr_itemsize)as    X/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/numpy/_core/strings.py_get_num_charsrB   B   s2     !'',,(zzQ::    c                    t        j                  |      }| j                  dk(  r| j                  |j                        S t        j                  | j                               }t        |j                  t         j                  j                        r$|j                  t        |j                              S |j                   t        |j                        t        |                  S )z
    Helper function to cast a result back into an array
    with the appropriate dtype if an object array must be used
    as an intermediary.
    r   )r=   asarraysizeastyper;   tolist
isinstancedtypesStringDTyper<   rB   )resultoutput_dtype_likerets      rA   _to_bytes_or_str_arrayrO   M   s     

#45{{a }}.4455
**V]]_
%C#))299+@+@Azz$066788::3d,223N34GHIIrC   c                  D    g }| D ]  }| |S |j                  |        |S )a!  
    Helper function for delegating arguments to Python string
    functions.

    Many of the Python string operations that have optional arguments
    do not use 'None' to indicate a default value.  In these cases,
    we need to remove all None arguments, and those following them.
    )append)argsnewargschks      rA   _clean_argsrU   ^   s:     G ;N 	s NrC   c                    t        j                  |       } t        j                  |      }t        j                  |j                  t         j                        st        d|j                   d      t        j                  |d      }| j                  j                  dk(  r| |z  S t        |       }t        j                  |t        j                  t        j                  |d      z  kD        rt        d      ||z  }| j                  j                   |j                          }t        j                  | |j                  |      }t!        | ||      S )	aQ  
    Return (a * i), that is string multiple concatenation,
    element-wise.

    Values in ``i`` of less than 0 are treated as 0 (which yields an
    empty string).

    Parameters
    ----------
    a : array_like, with ``StringDType``, ``bytes_`` or ``str_`` dtype

    i : array_like, with any integer dtype

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    Examples
    --------
    >>> a = np.array(["a", "b", "c"])
    >>> np.strings.multiply(a, 3)
    array(['aaa', 'bbb', 'ccc'], dtype='<U3')
    >>> i = np.array([1, 2, 3])
    >>> np.strings.multiply(a, i)
    array(['a', 'bb', 'ccc'], dtype='<U3')
    >>> np.strings.multiply(np.array(['a']), i)
    array(['a', 'aa', 'aaa'], dtype='<U3')
    >>> a = np.array(['a', 'b', 'c', 'd', 'e', 'f']).reshape((2, 3))
    >>> np.strings.multiply(a, 3)
    array([['aaa', 'bbb', 'ccc'],
           ['ddd', 'eee', 'fff']], dtype='<U3')
    >>> np.strings.multiply(a, i)
    array([['a', 'bb', 'ccc'],
           ['d', 'ee', 'fff']], dtype='<U3')

    zunsupported type z for operand 'i'r   T   zrepeated string is too longshaper;   out)r=   
asanyarray
issubdtyper;   integer	TypeErrormaximumcharr   anysysmaxsizeMemoryErrormax
empty_likerZ   _multiply_ufunc)r@   ia_lenbuffersizes	out_dtyper\   s         rA   r
   r
   o   s   N 	aA
aA=="**-+AGG94DEFF


1aA 	ww||s1uAJE 
vveckkBJJq!$4445788!)K77<<.!2 34I
--!2!2)
DC1aS))rC   c                 P    t        t        | t        j                  d|f      |       S )a  
    Return (a % i), that is pre-Python 2.6 string formatting
    (interpolation), element-wise for a pair of array_likes of str
    or unicode.

    Parameters
    ----------
    a : array_like, with ``StringDType``, ``bytes_`` or ``str_`` dtype

    values : array_like of values
       These values will be element-wise interpolated into the string.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    __mod__rO   r   r=   object_)r@   valuess     rA   r4   r4      s'    ( "Arzz9vi8!= =rC   c                 2    ||nt         }t        | |||      S )a  
    For each element, return the lowest index in the string where
    substring ``sub`` is found, such that ``sub`` is contained in the
    range [``start``, ``end``).

    Parameters
    ----------
    a : array_like, with ``StringDType``, ``bytes_`` or ``str_`` dtype

    sub : array_like, with `np.bytes_` or `np.str_` dtype
        The substring to search for.

    start, end : array_like, with any integer dtype
        The range to look in, interpreted as in slice notation.

    Returns
    -------
    y : ndarray
        Output array of ints

    See Also
    --------
    str.find

    Examples
    --------
    >>> a = np.array(["NumPy is a Python library"])
    >>> np.strings.find(a, "Python")
    array([11])

    )MAX_find_ufuncr@   substartends       rA   r   r      s!    @ #cCq#uc**rC   c                 2    ||nt         }t        | |||      S )aj  
    For each element, return the highest index in the string where
    substring ``sub`` is found, such that ``sub`` is contained in the
    range [``start``, ``end``).

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    sub : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        The substring to search for.

    start, end : array_like, with any integer dtype
        The range to look in, interpreted as in slice notation.

    Returns
    -------
    y : ndarray
        Output array of ints

    See Also
    --------
    str.rfind

    )rt   _rfind_ufuncrv   s       rA   r   r      s     4 #cC3s++rC   c                 2    ||nt         }t        | |||      S )aM  
    Like `find`, but raises :exc:`ValueError` when the substring is not found.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    sub : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    start, end : array_like, with any integer dtype, optional

    Returns
    -------
    out : ndarray
        Output array of ints.

    See Also
    --------
    find, str.index

    Examples
    --------
    >>> a = np.array(["Computer Science"])
    >>> np.strings.index(a, "Science", start=0, end=None)
    array([9])

    )rt   _index_ufuncrv   s       rA   r   r     s     8 #cC3s++rC   c                 2    ||nt         }t        | |||      S )aY  
    Like `rfind`, but raises :exc:`ValueError` when the substring `sub` is
    not found.

    Parameters
    ----------
    a : array_like, with ``StringDType``, ``bytes_`` or ``str_`` dtype

    sub : array_like, with ``StringDType``, ``bytes_`` or ``str_`` dtype

    start, end : array-like, with any integer dtype, optional

    Returns
    -------
    out : ndarray
        Output array of ints.

    See Also
    --------
    rfind, str.rindex

    Examples
    --------
    >>> a = np.array(["Computer Science"])
    >>> np.strings.rindex(a, "Science", start=0, end=None)
    array([9])

    )rt   _rindex_ufuncrv   s       rA   r   r   '  s     : #cCC,,rC   c                 2    ||nt         }t        | |||      S )a  
    Returns an array with the number of non-overlapping occurrences of
    substring ``sub`` in the range [``start``, ``end``).

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    sub : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
       The substring to search for.

    start, end : array_like, with any integer dtype
        The range to look in, interpreted as in slice notation.

    Returns
    -------
    y : ndarray
        Output array of ints

    See Also
    --------
    str.count

    Examples
    --------
    >>> c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
    >>> c
    array(['aAaAaA', '  aA  ', 'abBABba'], dtype='<U7')
    >>> np.strings.count(c, 'A')
    array([3, 1, 1])
    >>> np.strings.count(c, 'aA')
    array([3, 1, 0])
    >>> np.strings.count(c, 'A', start=1, end=4)
    array([2, 1, 1])
    >>> np.strings.count(c, 'A', start=1, end=3)
    array([1, 0, 0])

    )rt   _count_ufuncrv   s       rA   r   r   H  s!    N #cC3s++rC   c                 2    ||nt         }t        | |||      S )aT  
    Returns a boolean array which is `True` where the string element
    in ``a`` starts with ``prefix``, otherwise `False`.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    prefix : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    start, end : array_like, with any integer dtype
        With ``start``, test beginning at that position. With ``end``,
        stop comparing at that position.

    Returns
    -------
    out : ndarray
        Output array of bools

    See Also
    --------
    str.startswith

    )rt   _startswith_ufunc)r@   prefixrx   ry   s       rA   r   r   s  s     2 #cCQs33rC   c                 2    ||nt         }t        | |||      S )aN  
    Returns a boolean array which is `True` where the string element
    in ``a`` ends with ``suffix``, otherwise `False`.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    suffix : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    start, end : array_like, with any integer dtype
        With ``start``, test beginning at that position. With ``end``,
        stop comparing at that position.

    Returns
    -------
    out : ndarray
        Output array of bools

    See Also
    --------
    str.endswith

    Examples
    --------
    >>> s = np.array(['foo', 'bar'])
    >>> s
    array(['foo', 'bar'], dtype='<U3')
    >>> np.strings.endswith(s, 'ar')
    array([False,  True])
    >>> np.strings.endswith(s, 'a', start=1, end=2)
    array([False,  True])

    )rt   _endswith_ufunc)r@   suffixrx   ry   s       rA   r   r     s!    F #cC1feS11rC   c                     t        t        | t        j                  dt	        ||            t        j
                  d            S )a  
    Calls :meth:`bytes.decode` element-wise.

    The set of available codecs comes from the Python standard library,
    and may be extended at runtime.  For more information, see the
    :mod:`codecs` module.

    Parameters
    ----------
    a : array_like, with ``bytes_`` dtype

    encoding : str, optional
       The name of an encoding

    errors : str, optional
       Specifies how to handle encoding errors

    Returns
    -------
    out : ndarray

    See Also
    --------
    :py:meth:`bytes.decode`

    Notes
    -----
    The type of the result will depend on the encoding specified.

    Examples
    --------
    >>> c = np.array([b'\x81\xc1\x81\xc1\x81\xc1', b'@@\x81\xc1@@',
    ...               b'\x81\x82\xc2\xc1\xc2\x82\x81'])
    >>> c
    array([b'\x81\xc1\x81\xc1\x81\xc1', b'@@\x81\xc1@@',
           b'\x81\x82\xc2\xc1\xc2\x82\x81'], dtype='|S7')
    >>> np.strings.decode(c, encoding='cp037')
    array(['aAaAaA', '  aA  ', 'abBABba'], dtype='<U7')

    r5    )rO   r   r=   rq   rU   r>   r@   encodingerrorss      rA   r5   r5     s6    R "Arzz8[6-JK
 rC   c                     t        t        | t        j                  dt	        ||            t        j
                  d            S )u5  
    Calls :meth:`str.encode` element-wise.

    The set of available codecs comes from the Python standard library,
    and may be extended at runtime. For more information, see the
    :mod:`codecs` module.

    Parameters
    ----------
    a : array_like, with ``StringDType`` or ``str_`` dtype

    encoding : str, optional
       The name of an encoding

    errors : str, optional
       Specifies how to handle encoding errors

    Returns
    -------
    out : ndarray

    See Also
    --------
    str.encode

    Notes
    -----
    The type of the result will depend on the encoding specified.

    Examples
    --------
    >>> a = np.array(['aAaAaA', '  aA  ', 'abBABba'])
    >>> np.strings.encode(a, encoding='cp037')
    array([b'ÁÁÁ', b'@@Á@@',
       b'ÂÁÂ'], dtype='|S7')

    r6   rC   )rO   r   r=   rq   rU   bytes_r   s      rA   r6   r6     s6    L "Arzz8[6-JK
		# rC   c                    t        j                  |       } t        j                  |      }| j                  j                  dk(  rBt        j                  | j
                  |j
                        }t        j                  | |      }nVt        | |      }| j                  j                   |j                          }t        j                  | |j
                  |      }t        | ||      S )ai  
    Return a copy of each string element where all tab characters are
    replaced by one or more spaces.

    Calls :meth:`str.expandtabs` element-wise.

    Return a copy of each string element where all tab characters are
    replaced by one or more spaces, depending on the current column
    and the given `tabsize`. The column number is reset to zero after
    each newline occurring in the string. This doesn't understand other
    non-printing characters or escape sequences.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Input array
    tabsize : int, optional
        Replace tabs with `tabsize` number of spaces.  If not given defaults
        to 8 spaces.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input type

    See Also
    --------
    str.expandtabs

    Examples
    --------
    >>> a = np.array(['		Hello	world'])
    >>> np.strings.expandtabs(a, tabsize=4)  # doctest: +SKIP
    array(['        Hello   world'], dtype='<U21')  # doctest: +SKIP

    rW   )rZ   rY   r[   )
r=   r]   r;   rb   broadcast_shapesrZ   rh   r$   rg   r%   )r@   tabsizerZ   r\   rl   rm   s         rA   r*   r*     s    L 	aAmmG$Gww||s##AGGW]];mmAU+(G4ww||n[__%6$78	mmA[%6%6iHq's++rC   c                    t        j                  |       }t        j                  |      }t        t        j                  |j                              }t        j
                  |j                  t         j                        rt         j                  j                  |      }t        | t        |j                        |      d||f      S )a  
    Return a copy of `a` with its elements centered in a string of
    length `width`.

    Calls :meth:`str.center` element-wise.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
    width : array_like, with any integer dtype
        The length of the resulting strings, unless ``width < str_len(a)``.
    fillchar : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Optional padding character to use (default is space).

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.center

    Notes
    -----
    This function is intended to work with arrays of strings.  The
    fill character is not applied to numeric types.

    Examples
    --------
    >>> c = np.array(['a1b2','1b2a','b2a1','2a1b']); c
    array(['a1b2', '1b2a', 'b2a1', '2a1b'], dtype='<U4')
    >>> np.strings.center(c, width=9)
    array(['   a1b2  ', '   1b2a  ', '   b2a1  ', '   2a1b  '], dtype='<U9')
    >>> np.strings.center(c, width=9, fillchar='*')
    array(['***a1b2**', '***1b2a**', '***b2a1**', '***2a1b**'], dtype='<U9')
    >>> np.strings.center(c, width=1)
    array(['a', '1', 'b', '2'], dtype='<U1')

    r+   )r=   rE   intrg   flatr^   r;   r   _utilsasbytesr   r<   )r@   widthfillchara_arr	width_arrrF   s         rA   r+   r+   C  s    T JJqME

5!Irvvinn%&D	}}U[[")),99$$X. tEKK &9h2GI IrC   c                    t        j                  |       }t        j                  |      }t        t        j                  |j                              }t        j
                  |j                  t         j                        rt         j                  j                  |      }t        |j                  t         j                  j                        r|j                  }n t        |j                        |      }t        ||d||f      S )ac  
    Return an array with the elements of `a` left-justified in a
    string of length `width`.

    Calls :meth:`str.ljust` element-wise.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
    width : array_like, with any integer dtype
        The length of the resulting strings, unless ``width < str_len(a)``.
    fillchar : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Optional character to use for padding (default is space).

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.ljust

    Examples
    --------
    >>> c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
    >>> np.strings.ljust(c, width=3)
    array(['aAa', '  a', 'abB'], dtype='<U3')

    r,   r=   rE   r   rg   r   r^   r;   r   r   r   rI   rJ   rK   r<   r   r@   r   r   r   r   rF   	res_dtypes          rA   r,   r,   v  s    @ JJqME

5!Irvvinn%&D	}}U[[")),99$$X.%++ryy445KK	%D%d+	y'Ix#8: :rC   c                    t        j                  |       }t        j                  |      }t        t        j                  |j                              }t        j
                  |j                  t         j                        rt         j                  j                  |      }t        |j                  t         j                  j                        r|j                  }n t        |j                        |      }t        ||d||f      S )aa  
    Return an array with the elements of `a` right-justified in a
    string of length `width`.

    Calls :meth:`str.rjust` element-wise.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
    width : array_like, with any integer dtype
        The length of the resulting strings, unless ``width < str_len(a)``.
    fillchar : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Optional padding character to use (default is space).


    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.rjust

    Examples
    --------
    >>> a = np.array(['aAaAaA', '  aA  ', 'abBABba'])
    >>> np.strings.rjust(a, width=3)
    array(['aAa', '  a', 'abB'], dtype='<U3')

    r-   r   r   s          rA   r-   r-     s    B JJqME

5!Irvvinn%&D	}}U[[")),99$$X.%++ryy445KK	%D%d+	y'Ix#8: :rC   c                 4    |t        |       S t        | |      S )a$  
    For each element in `a`, return a copy with the leading characters
    removed.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
    chars : scalar with the same dtype as ``a``, optional
       The ``chars`` argument is a string specifying the set of
       characters to be removed. If ``None``, the ``chars``
       argument defaults to removing whitespace. The ``chars`` argument
       is not a prefix or suffix; rather, all combinations of its
       values are stripped.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input type

    See Also
    --------
    str.lstrip

    Examples
    --------
    >>> c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
    >>> c
    array(['aAaAaA', '  aA  ', 'abBABba'], dtype='<U7')
    # The 'a' variable is unstripped from c[1] because of leading whitespace.
    >>> np.strings.lstrip(c, 'a')
    array(['AaAaA', '  aA  ', 'bBABba'], dtype='<U7')
    >>> np.strings.lstrip(c, 'A') # leaves c unchanged
    array(['aAaAaA', '  aA  ', 'abBABba'], dtype='<U7')
    >>> (np.strings.lstrip(c, ' ') == np.strings.lstrip(c, '')).all()
    np.False_
    >>> (np.strings.lstrip(c, ' ') == np.strings.lstrip(c)).all()
    np.True_

    )r   r   r@   charss     rA   r&   r&     s"    R }!!$$E""rC   c                 4    |t        |       S t        | |      S )a  
    For each element in `a`, return a copy with the trailing characters
    removed.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
    chars : scalar with the same dtype as ``a``, optional
       The ``chars`` argument is a string specifying the set of
       characters to be removed. If ``None``, the ``chars``
       argument defaults to removing whitespace. The ``chars`` argument
       is not a prefix or suffix; rather, all combinations of its
       values are stripped.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.rstrip

    Examples
    --------
    >>> c = np.array(['aAaAaA', 'abBABba'])
    >>> c
    array(['aAaAaA', 'abBABba'], dtype='<U7')
    >>> np.strings.rstrip(c, 'a')
    array(['aAaAaA', 'abBABb'], dtype='<U7')
    >>> np.strings.rstrip(c, 'A')
    array(['aAaAa', 'abBABba'], dtype='<U7')

    )r   r    r   s     rA   r'   r'     s"    H }!!$$E""rC   c                 4    |t        |       S t        | |      S )a  
    For each element in `a`, return a copy with the leading and
    trailing characters removed.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
    chars : scalar with the same dtype as ``a``, optional
       The ``chars`` argument is a string specifying the set of
       characters to be removed. If ``None``, the ``chars``
       argument defaults to removing whitespace. The ``chars`` argument
       is not a prefix or suffix; rather, all combinations of its
       values are stripped.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.strip

    Examples
    --------
    >>> c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
    >>> c
    array(['aAaAaA', '  aA  ', 'abBABba'], dtype='<U7')
    >>> np.strings.strip(c)
    array(['aAaAaA', 'aA', 'abBABba'], dtype='<U7')
    # 'a' unstripped from c[1] because of leading whitespace.
    >>> np.strings.strip(c, 'a')
    array(['AaAaA', '  aA  ', 'bBABb'], dtype='<U7')
    # 'A' unstripped from c[1] because of trailing whitespace.
    >>> np.strings.strip(c, 'A')
    array(['aAaAa', '  aA  ', 'abBABba'], dtype='<U7')

    )r!   r"   r   s     rA   r(   r(   (  s"    P } ##5!!rC   c                     t        j                  |       }t        j                  |      }t        t        j                  |j                              }t        | t        |j                        |      d|f      S )a=  
    Return the numeric string left-filled with zeros

    Calls :meth:`str.zfill` element-wise.

    Parameters
    ----------
    a : array_like, with ``StringDType``, ``bytes_`` or ``str_`` dtype
        Input array.
    width : int
        Width of string to left-fill elements in `a`.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.zfill

    Examples
    --------
    >>> np.strings.zfill('1', 3)
    array('001', dtype='<U3')

    r.   )r=   rE   r   rg   r   r   r<   r;   )r@   r   r   r   rF   s        rA   r.   r.   U  s_    : JJqME

5!Irvvinn%&D tEKK &)? ?rC   c                 Z    t        j                  |       }t        ||j                  d      S )a  
    Return an array with the elements converted to uppercase.

    Calls :meth:`str.upper` element-wise.

    For 8-bit strings, this method is locale-dependent.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Input array.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.upper

    Examples
    --------
    >>> c = np.array(['a1b c', '1bca', 'bca1']); c
    array(['a1b c', '1bca', 'bca1'], dtype='<U5')
    >>> np.strings.upper(c)
    array(['A1B C', '1BCA', 'BCA1'], dtype='<U5')

    r/   r=   rE   r   r;   r@   r   s     rA   r/   r/   y  $    > JJqMEuekk733rC   c                 Z    t        j                  |       }t        ||j                  d      S )a  
    Return an array with the elements converted to lowercase.

    Call :meth:`str.lower` element-wise.

    For 8-bit strings, this method is locale-dependent.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Input array.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.lower

    Examples
    --------
    >>> c = np.array(['A1B C', '1BCA', 'BCA1']); c
    array(['A1B C', '1BCA', 'BCA1'], dtype='<U5')
    >>> np.strings.lower(c)
    array(['a1b c', '1bca', 'bca1'], dtype='<U5')

    r0   r   r   s     rA   r0   r0     r   rC   c                 Z    t        j                  |       }t        ||j                  d      S )a  
    Return element-wise a copy of the string with
    uppercase characters converted to lowercase and vice versa.

    Calls :meth:`str.swapcase` element-wise.

    For 8-bit strings, this method is locale-dependent.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Input array.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.swapcase

    Examples
    --------
    >>> c=np.array(['a1B c','1b Ca','b Ca1','cA1b'],'S5'); c
    array(['a1B c', '1b Ca', 'b Ca1', 'cA1b'],
        dtype='|S5')
    >>> np.strings.swapcase(c)
    array(['A1b C', '1B cA', 'B cA1', 'Ca1B'],
        dtype='|S5')

    r1   r   r   s     rA   r1   r1     s%    D JJqMEuekk:66rC   c                 Z    t        j                  |       }t        ||j                  d      S )a  
    Return a copy of ``a`` with only the first character of each element
    capitalized.

    Calls :meth:`str.capitalize` element-wise.

    For byte strings, this method is locale-dependent.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Input array of strings to capitalize.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.capitalize

    Examples
    --------
    >>> c = np.array(['a1b2','1b2a','b2a1','2a1b'],'S4'); c
    array(['a1b2', '1b2a', 'b2a1', '2a1b'],
        dtype='|S4')
    >>> np.strings.capitalize(c)
    array(['A1b2', '1b2a', 'B2a1', '2a1b'],
        dtype='|S4')

    r2   r   r   s     rA   r2   r2     s%    D JJqMEuekk<88rC   c                 Z    t        j                  |       }t        ||j                  d      S )aI  
    Return element-wise title cased version of string or unicode.

    Title case words start with uppercase characters, all remaining cased
    characters are lowercase.

    Calls :meth:`str.title` element-wise.

    For 8-bit strings, this method is locale-dependent.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Input array.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.title

    Examples
    --------
    >>> c=np.array(['a1b c','1b ca','b ca1','ca1b'],'S5'); c
    array(['a1b c', '1b ca', 'b ca1', 'ca1b'],
        dtype='|S5')
    >>> np.strings.title(c)
    array(['A1B C', '1B Ca', 'B Ca1', 'Ca1B'],
        dtype='|S5')

    r3   r   r   s     rA   r3   r3     s%    H JJqMEuekk733rC   c                    t        j                  |       }|j                  }t        j                  |t        |d|            }t        j                  |t        |d|            }t        j                  |      }|j                  j                  dk(  rt        ||||      S t        j                  t         j                        j                  }t        ||d|      }t        j                  |dk  |t        j                  ||            }t        |      |t        |      t        |      z
  z  z   }|j                  j                   |j                          }	t        j                  ||j                  |	      }
t        |||||
      S )a  
    For each element in ``a``, return a copy of the string with
    occurrences of substring ``old`` replaced by ``new``.

    Parameters
    ----------
    a : array_like, with ``bytes_`` or ``str_`` dtype

    old, new : array_like, with ``bytes_`` or ``str_`` dtype

    count : array_like, with ``int_`` dtype
        If the optional argument ``count`` is given, only the first
        ``count`` occurrences are replaced.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.replace

    Examples
    --------
    >>> a = np.array(["That is a mango", "Monkeys eat mangos"])
    >>> np.strings.replace(a, 'mango', 'banana')
    array(['That is a banana', 'Monkeys eat bananas'], dtype='<U19')

    >>> a = np.array(["The dish is fresh", "This is it"])
    >>> np.strings.replace(a, 'is', 'was')
    array(['The dwash was fresh', 'Thwas was it'], dtype='<U19')

    r;   )r;   rW   r   rY   r[   )r=   r]   r;   getattrrb   r#   iinfoint64rg   r   whereminimumr   rh   rZ   )r@   oldnewr   arra_dt	max_int64countsrl   rm   r\   s              rA   r)   r)   3  s0   H --
C99D
--73#>
?C
--73#>
?CMM% E
yy~~S#u--"&&I#sAy1FXXeaiFE)BCF#,73<'#,+F!GGK99>>";??#4"56I
--;#4#4I
FCCc6s33rC   c                 P    t        t        | t        j                  d|f      |      S )a  
    Return a string which is the concatenation of the strings in the
    sequence `seq`.

    Calls :meth:`str.join` element-wise.

    Parameters
    ----------
    sep : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
    seq : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types

    See Also
    --------
    str.join

    Examples
    --------
    >>> np.strings.join('-', 'osd')  # doctest: +SKIP
    array('o-s-d', dtype='<U5')  # doctest: +SKIP

    >>> np.strings.join(['-', '.'], ['ghc', 'osd'])  # doctest: +SKIP
    array(['g-h-c', 'o.s.d'], dtype='<U5')  # doctest: +SKIP

    joinrp   )sepseqs     rA   _joinr   j  s'    > "CVcV4c; ;rC   c           	      T    t        | t        j                  d|gt        |      z         S )a  
    For each element in `a`, return a list of the words in the
    string, using `sep` as the delimiter string.

    Calls :meth:`str.split` element-wise.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    sep : str or unicode, optional
       If `sep` is not specified or None, any whitespace string is a
       separator.

    maxsplit : int, optional
        If `maxsplit` is given, at most `maxsplit` splits are done.

    Returns
    -------
    out : ndarray
        Array of list objects

    Examples
    --------
    >>> x = np.array("Numpy is nice!")
    >>> np.strings.split(x, " ")  # doctest: +SKIP
    array(list(['Numpy', 'is', 'nice!']), dtype=object)  # doctest: +SKIP

    >>> np.strings.split(x, " ", 1)  # doctest: +SKIP
    array(list(['Numpy', 'is nice!']), dtype=object)  # doctest: +SKIP

    See Also
    --------
    str.split, rsplit

    splitr   r=   rq   rU   r@   r   maxsplits      rA   _splitr     s+    N 	2::wH(= =? ?rC   c           	      T    t        | t        j                  d|gt        |      z         S )a  
    For each element in `a`, return a list of the words in the
    string, using `sep` as the delimiter string.

    Calls :meth:`str.rsplit` element-wise.

    Except for splitting from the right, `rsplit`
    behaves like `split`.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    sep : str or unicode, optional
        If `sep` is not specified or None, any whitespace string
        is a separator.
    maxsplit : int, optional
        If `maxsplit` is given, at most `maxsplit` splits are done,
        the rightmost ones.

    Returns
    -------
    out : ndarray
        Array of list objects

    See Also
    --------
    str.rsplit, split

    Examples
    --------
    >>> a = np.array(['aAaAaA', 'abBABba'])
    >>> np.strings.rsplit(a, 'A')  # doctest: +SKIP
    array([list(['a', 'a', 'a', '']),  # doctest: +SKIP
           list(['abB', 'Bba'])], dtype=object)  # doctest: +SKIP

    rsplitr   r   s      rA   _rsplitr     s-    P 	2::x#X)>!>@ @rC   c                 L    t        | t        j                  dt        |            S )a  
    For each element in `a`, return a list of the lines in the
    element, breaking at line boundaries.

    Calls :meth:`str.splitlines` element-wise.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

    keepends : bool, optional
        Line breaks are not included in the resulting list unless
        keepends is given and true.

    Returns
    -------
    out : ndarray
        Array of list objects

    See Also
    --------
    str.splitlines

    
splitlinesr   )r@   keependss     rA   _splitlinesr     s#    2 	2::|[%:< <rC   c                 P    t        t        | t        j                  d|f      |       S )aS  
    Partition each element in `a` around `sep`.

    Calls :meth:`str.partition` element-wise.

    For each element in `a`, split the element as the first
    occurrence of `sep`, and return 3 strings containing the part
    before the separator, the separator itself, and the part after
    the separator. If the separator is not found, return 3 strings
    containing the string itself, followed by two empty strings.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Input array
    sep : {str, unicode}
        Separator to split each string element in `a`.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types. The output array will have an extra
        dimension with 3 elements per input element.

    Examples
    --------
    >>> x = np.array(["Numpy is nice!"])
    >>> np.strings.partition(x, " ")  # doctest: +SKIP
    array([['Numpy', ' ', 'is nice!']], dtype='<U8')  # doctest: +SKIP
 
    See Also
    --------
    str.partition

    	partitionrp   r@   r   s     rA   
_partitionr     s(    J "Arzz;7< <rC   c                 P    t        t        | t        j                  d|f      |       S )a  
    Partition (split) each element around the right-most separator.

    Calls :meth:`str.rpartition` element-wise.

    For each element in `a`, split the element as the last
    occurrence of `sep`, and return 3 strings containing the part
    before the separator, the separator itself, and the part after
    the separator. If the separator is not found, return 3 strings
    containing the string itself, followed by two empty strings.

    Parameters
    ----------
    a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
        Input array
    sep : str or unicode
        Right-most separator to split each element in array.

    Returns
    -------
    out : ndarray
        Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
        depending on input types. The output array will have an extra
        dimension with 3 elements per input element.

    See Also
    --------
    str.rpartition

    Examples
    --------
    >>> a = np.array(['aAaAaA', '  aA  ', 'abBABba'])
    >>> np.strings.rpartition(a, 'A')  # doctest: +SKIP
    array([['aAaAa', 'A', ''],  # doctest: +SKIP
       ['  a', 'A', '  '],  # doctest: +SKIP
       ['abB', 'A', 'Bba']], dtype='<U5')  # doctest: +SKIP

    
rpartitionrp   r   s     rA   _rpartitionr   *  s(    N "Arzz<#8!= =rC   c           	         t        j                  |       }t        |j                  j                  t         j
                        rt        ||j                  d|f      S t        ||j                  d|gt        |      z         S )a:  
    For each element in `a`, return a copy of the string where all
    characters occurring in the optional argument `deletechars` are
    removed, and the remaining characters have been mapped through the
    given translation table.

    Calls :meth:`str.translate` element-wise.

    Parameters
    ----------
    a : array-like, with `np.bytes_` or `np.str_` dtype

    table : str of length 256

    deletechars : str

    Returns
    -------
    out : ndarray
        Output array of str or unicode, depending on input type

    See Also
    --------
    str.translate

    Examples
    --------
    >>> a = np.array(['a1b c', '1bca', 'bca1'])
    >>> table = a[0].maketrans('abc', '123')
    >>> deletechars = ' '
    >>> np.char.translate(a, table, deletechars)
    array(['112 3', '1231', '2311'], dtype='<U5')

    r7   )r=   rE   r:   r;   r<   r>   r   rU   )r@   tabledeletecharsr   s       rA   r7   r7   U  sq    F JJqME%++""BGG,5;;eX7 	7 KKGk+..	
 	
rC   )r   N)NN)   ) )N))Q__doc__rd   numpyr=   r   r   r   r   r   r   r	   r
   ri   numpy._core.multiarrayr   numpy._core.umathr   r   r   r   r   r   r   r   r   r   r   ru   r   r{   r   r}   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   __all__r   r   rg   rt   rB   rO   rU   r4   r5   r6   r*   r+   r,   r-   r&   r'   r(   r.   r/   r0   r1   r2   r3   r)   r   r   r   r   r   r   r7    rC   rA   <module>r      s9  
     /      <( bhhrxxJ"";*|=0!+H,<,@-B(,V4:$2N+\(V0,f0If*:Z+:\+#\&#R*"Z!?H 4F 4F#7L#9L%4P44n ;F(?V)@X<:&<R(=V-
rC   