OwlCyberSecurity - MANAGER
Edit File: defchararray.cpython-38.pyc
U �p�]T � 3 @ s� d Z ddlmZmZmZ ddlZddlZddlmZm Z m Z mZmZm Z ddlmZmZ ddlmZ ddlmZ dd lmZ dd lmZ ddlmZmZ ddlZdd ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>g3Zdaejd d?k�r(e Z!e"Z#ne$Z!e Z#e%Z&ej'ej(d@dA�Z(dBdC� Z)dDdE� Z*dFdG� Z+dHdI� Z,dJdK� Z-e(e-�dLd� �Z.e(e-�dMd � �Z/e(e-�dNd� �Z0e(e-�dOd� �Z1e(e-�dPd� �Z2e(e-�dQd� �Z3dRdS� Z4e(e4�dTd� �Z5e(e-�dUd� �Z6dVdW� Z7e(e7�dXd� �Z8dYdZ� Z9e(e9�d[d� �Z:e(e4�d\d� �Z;d�d]d^�Z<e(e<�d�d`d��Z=d�dadb�Z>e(e>�d�dcd��Z?d�ddde�Z@e(e@�d�dfd��ZAe(e@�d�dgd��ZBd�dhdi�ZCe(eC�d�djd��ZDd�dkdl�ZEe(eE�d�dnd��ZFe(e>�d�dod��ZGe(e>�d�dpd��ZHe(e4�dqd� �ZIe(e4�drd � �ZJe(e4�dsd!� �ZKe(e4�dtd"� �ZLe(e4�dud#� �ZMe(e4�dvd$� �ZNe(e4�dwd%� �ZOdxdy� ZPe(eP�dzd&� �ZQd�d{d|�ZRe(eR�d�d}d'��ZSe(e4�d~d(� �ZTd�dd��ZUe(eU�d�d�d)��ZVd�d�� ZWe(eW�d�d*� �ZXd�d�d��ZYe(eY�d�d�d+��ZZe(e>�d�d�d,��Z[e(e>�d�d�d-��Z\e(eR�d�d�d.��Z]e(eW�d�d/� �Z^d�d�d��Z_e(e_�d�d�d0��Z`d�d�d��ZUe(eU�d�d�d1��Zae(e_�d�d�d2��Zbd�d�d��Zce(ec�d�d�d3��Zdd�d�d��Zee(ee�d�d�d4��Zfe(eU�d�d�d5��Zge(e4�d�d6� �Zhe(e4�d�d7� �Zid�d�d��Zje(ej�d�d�d8��Zke(e4�d�d9� �Zld�d�� Zme(em�d�d:� �Zne(e4�d�d;� �Zoe(e4�d�d<� �Zped��G d�d�� d�e��Zqd�d�d=�Zd�d�d>�ZrdS )�as This module contains a set of functions for vectorized string operations and methods. .. note:: The `chararray` class exists for backwards compatibility with Numarray, it is not recommended for new development. Starting from numpy 1.4, if one needs arrays of strings, it is recommended to use arrays of `dtype` `object_`, `string_` or `unicode_`, and use the free functions in the `numpy.char` module for fast vectorized string operations. Some methods will only be available if the corresponding string method is available in your version of Python. The preferred alias for `defchararray` is `numpy.char`. � )�division�absolute_import�print_functionN� )�string_�unicode_�integer�object_�bool_� character)�ndarray�compare_chararrays��array)�_vec_string)� set_module)� overrides)�asbytes�long�equal� not_equal� greater_equal� less_equal�greater�less�str_len�add�multiply�mod� capitalize�center�count�decode�encode�endswith� expandtabs�find�index�isalnum�isalpha�isdigit�islower�isspace�istitle�isupper�join�ljust�lower�lstrip� partition�replace�rfind�rindex�rjust� rpartition�rsplit�rstrip�split� splitlines� startswith�strip�swapcase�title� translate�upper�zfill� isnumeric� isdecimalr �asarray� z numpy.char)�modulec G s4 | D ]*}t |t�s&tt�|�jjt�rt S qtS )z� Helper function for determining the output type of some string operations. For an operation on two ndarrays, if at least one is unicode, the result should be unicode. ) � isinstance�_unicode� issubclass�numpyrF �dtype�typer r )�args�x� rQ �9/usr/lib/python3/dist-packages/numpy/core/defchararray.py�_use_unicode9 s � rS c C s t �| �� �S )z� Helper function to cast a result back into a string or unicode array if an object array must be used as an intermediary. )rL rF �tolist)�resultrQ rQ rR �_to_string_or_unicode_arrayG s rV c G s( g }| D ]}|dkr q$|� |� q|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. N)�append)rO ZnewargsZchkrQ rQ rR �_clean_argsN s rX c C s t | jjt�r| jd S | jS )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. � )rK rM rN r �itemsize��arQ rQ rR �_get_num_chars^ s r] c C s | |fS �NrQ ��x1�x2rQ rQ rR �_binary_op_dispatcheri s rb c C s t | |dd�S )a4 Return (x1 == x2) element-wise. Unlike `numpy.equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- not_equal, greater_equal, less_equal, greater, less z==T�r r_ rQ rQ rR r m s c C s t | |dd�S )a4 Return (x1 != x2) element-wise. Unlike `numpy.not_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, greater_equal, less_equal, greater, less z!=Trc r_ rQ rQ rR r � s c C s t | |dd�S )a7 Return (x1 >= x2) element-wise. Unlike `numpy.greater_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, less_equal, greater, less z>=Trc r_ rQ rQ rR r � s c C s t | |dd�S )a4 Return (x1 <= x2) element-wise. Unlike `numpy.less_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, greater_equal, greater, less z<=Trc r_ rQ rQ rR r � s c C s t | |dd�S )a3 Return (x1 > x2) element-wise. Unlike `numpy.greater`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, greater_equal, less_equal, less �>Trc r_ rQ rQ rR r � s c C s t | |dd�S )a6 Return (x1 < x2) element-wise. Unlike `numpy.greater`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, greater_equal, less_equal, greater �<Trc r_ rQ rQ rR r � s c C s | fS r^ rQ r[ rQ rQ rR �_unary_op_dispatcher s rf c C s t | td�S )z� Return len(a) element-wise. Parameters ---------- a : array_like of str or unicode Returns ------- out : ndarray Output array of integers See also -------- __builtin__.len �__len__)r r r[ rQ rQ rR r s c C sB t �| �}t �|�}t|�t|� }t||�}t|||fd|f�S )a� Return element-wise string concatenation for two arrays of str or unicode. Arrays `x1` and `x2` must have the same shape. Parameters ---------- x1 : array_like of str or unicode Input array. x2 : array_like of str or unicode Input array. Returns ------- add : ndarray Output array of `string_` or `unicode_`, depending on input types of the same shape as `x1` and `x2`. �__add__)rL rF r] rS r )r` ra Zarr1Zarr2�out_sizerM rQ rQ rR r # s c C s | fS r^ rQ )r\ �irQ rQ rR �_multiply_dispatcher? s rk c C s\ t �| �}t �|�}t|jjt�s*td��t|�tt |�� �d� }t ||jj|fd|f�S )av 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 of str or unicode i : array_like of ints Returns ------- out : ndarray Output array of str or unicode, depending on input types zCan only multiply by integersr �__mul__)rL rF rK rM rN r � ValueErrorr] �maxr r )r\ rj �a_arrZi_arrri rQ rQ rR r C s �c C s | |fS r^ rQ �r\ �valuesrQ rQ rR �_mod_dispatchera s rr c C s t t| td|f��S )a� Return (a % i), that is pre-Python 2.6 string formatting (iterpolation), element-wise for a pair of array_likes of str or unicode. Parameters ---------- a : array_like of str or unicode values : array_like of values These values will be element-wise interpolated into the string. Returns ------- out : ndarray Output array of str or unicode, depending on input types See also -------- str.__mod__ �__mod__�rV r r rp rQ rQ rR r e s �c C s t �| �}t||jd�S )a� Return a copy of `a` with only the first character of each element capitalized. Calls `str.capitalize` element-wise. For 8-bit strings, this method is locale-dependent. Parameters ---------- a : array_like of str or unicode Input array of strings to capitalize. Returns ------- out : ndarray Output array of str or unicode, 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.char.capitalize(c) array(['A1b2', '1b2a', 'B2a1', '2a1b'], dtype='|S4') r �rL rF r rM �r\ ro rQ rQ rR r � s # c C s | fS r^ rQ �r\ �width�fillcharrQ rQ rR �_center_dispatcher� s rz � c C sV t �| �}t �|�}tt �|j��}t �|jt j�r<t|�}t ||jj |fd||f�S )a Return a copy of `a` with its elements centered in a string of length `width`. Calls `str.center` element-wise. Parameters ---------- a : array_like of str or unicode width : int The length of the resulting strings fillchar : str or unicode, optional The padding character to use (default is space). Returns ------- out : ndarray Output array of str or unicode, depending on input types See also -------- str.center r �rL rF r rn �flatZ issubdtyperM r r r rN �r\ rx ry ro � width_arr�sizerQ rQ rR r � s �c C s | fS r^ rQ �r\ �sub�start�endrQ rQ rR �_count_dispatcher� s r� c C s t | td||gt|� �S )a� Returns an array with the number of non-overlapping occurrences of substring `sub` in the range [`start`, `end`]. Calls `str.count` element-wise. Parameters ---------- a : array_like of str or unicode sub : str or unicode The substring to search for. start, end : int, optional Optional arguments `start` and `end` are interpreted as slice notation to specify the range in which to count. Returns ------- out : ndarray Output array of ints. See also -------- str.count Examples -------- >>> c = np.array(['aAaAaA', ' aA ', 'abBABba']) >>> c array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') >>> np.char.count(c, 'A') array([3, 1, 1]) >>> np.char.count(c, 'aA') array([3, 1, 0]) >>> np.char.count(c, 'A', start=1, end=4) array([2, 1, 1]) >>> np.char.count(c, 'A', start=1, end=3) array([1, 0, 0]) r! �r r rX r� rQ rQ rR r! � s +c C s | fS r^ rQ �r\ �encoding�errorsrQ rQ rR �_code_dispatcher s r� c C s t t| tdt||���S )a} Calls `str.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 of str or unicode encoding : str, optional The name of an encoding errors : str, optional Specifies how to handle encoding errors Returns ------- out : ndarray See also -------- str.decode Notes ----- The type of the result will depend on the encoding specified. Examples -------- >>> c = np.array(['aAaAaA', ' aA ', 'abBABba']) >>> c array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') >>> np.char.encode(c, encoding='cp037') array(['\x81\xc1\x81\xc1\x81\xc1', '@@\x81\xc1@@', '\x81\x82\xc2\xc1\xc2\x82\x81'], dtype='|S7') r"