403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.19.244.133
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/__pycache__/recfunctions.cpython-37.pyc
B

��Fd^��@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
ddlmZmZddl	m
Z
ddlmZddlmZddlmZejdd	kr�dd
lmZej
jjZddd
dddddddddgZdd�Zdd�Zdd�Zdd�Zd=dd �Zd>d!d�Zd"d#�Z d$d%�Z!d?d'd(�Z"d@d)d*�Z#dAd+d,�Z$dBd.d�Z%dCd/d�Z&dDd0d1�Z'd2d�Z(d3d�Z)dEd4d�Z*dFd5d�Z+dGd6d�Z,dHd7d
�Z-dId;d�Z.dJd<d�Z/dS)Kz�
Collection of utilities to manipulate structured arrays.

Most of these functions were initially implemented by John Hunter for
matplotlib.  They have been rewritten and extended for convenience.

�)�division�absolute_import�print_functionN)�ndarray�recarray)�MaskedArray)�
MaskedRecords)�_is_string_like)�
basestring�)�zip�
append_fields�drop_fields�find_duplicates�get_fieldstructure�join_by�merge_arrays�rec_append_fields�rec_drop_fields�rec_join�recursive_fill_fields�
rename_fields�stack_arraysc	Csj|j}x^|jD]T}y||}Wntk
r4wYnX|jjrNt|||�q|||dt|��<qW|S)al
    Fills fields from output with fields from input,
    with support for nested structures.

    Parameters
    ----------
    input : ndarray
        Input array.
    output : ndarray
        Output array.

    Notes
    -----
    * `output` should be at least the same size as `input`

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> a = np.array([(1, 10.), (2, 20.)], dtype=[('A', int), ('B', float)])
    >>> b = np.zeros((3,), dtype=a.dtype)
    >>> rfn.recursive_fill_fields(a, b)
    array([(1, 10.0), (2, 20.0), (0, 0.0)],
          dtype=[('A', '<i4'), ('B', '<f8')])

    N)�dtype�names�
ValueErrorr�len)�input�output�newdtype�field�current�r"�I/opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/recfunctions.pyr"scCsTg}|j}x<|D]4}||}|jr:|�|tt|��f�q|�|�qWt|�pRdS)a�
    Returns the field names of the input datatype as a tuple.

    Parameters
    ----------
    adtype : dtype
        Input datatype

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> rfn.get_names(np.empty((1,), dtype=int)) is None
    True
    >>> rfn.get_names(np.empty((1,), dtype=[('A',int), ('B', float)]))
    ('A', 'B')
    >>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])])
    >>> rfn.get_names(adtype)
    ('a', ('b', ('ba', 'bb')))
    N)r�append�tuple�	get_names)�adtype�	listnamesr�namer!r"r"r#r&Is
r&cCsJg}|j}x2|D]*}|�|�||}|jr|�t|��qWt|�pHdS)a2
    Returns the field names of the input datatype as a tuple. Nested structure
    are flattend beforehand.

    Parameters
    ----------
    adtype : dtype
        Input datatype

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> rfn.get_names_flat(np.empty((1,), dtype=int)) is None
    True
    >>> rfn.get_names_flat(np.empty((1,), dtype=[('A',int), ('B', float)]))
    ('A', 'B')
    >>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])])
    >>> rfn.get_names_flat(adtype)
    ('a', 'b', 'ba', 'bb')
    N)rr$�extend�get_names_flatr%)r'r(rr)r!r"r"r#r+hs

r+cCsd|j}|dkr|jSg}x>|D]6}|j|\}}|jrF|�t|��q|�||f�qWt|�SdS)aD
    Flatten a structured data-type description.

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> ndtype = np.dtype([('a', '<i4'), ('b', [('ba', '<f8'), ('bb', '<i4')])])
    >>> rfn.flatten_descr(ndtype)
    (('a', dtype('int32')), ('ba', dtype('float64')), ('bb', dtype('int32')))

    N)r�descr�fieldsr*�
flatten_descrr$r%)�ndtyperr,r �typ�_r"r"r#r.�s
r.FcCs|g}|r(xf|D]}|�t|j��qWnHxF|D]>}|j}|jp@d}t|�dkr`|�d|jf�q.|�|j�q.Wt�|�jS)z�
    Combine the dtype description of a series of arrays.

    Parameters
    ----------
    seqarrays : sequence of arrays
        Sequence of arrays
    flatten : {boolean}, optional
        Whether to collapse nested descriptions.
    r"��)r*r.rrrr$r,�np)�	seqarrays�flattenr�ar!rr"r"r#�	zip_descr�s


r8cCs�|dkri}|j}x�|D]~}||}|jrV|r:|g||<ng||<|�t|||��qdd�|�|g�pjgD�}|r�|�|�n
|r�|g}|p�g||<qW|p�dS)ab
    Returns a dictionary with fields indexing lists of their parent fields.

    This function is used to simplify access to fields nested in other fields.

    Parameters
    ----------
    adtype : np.dtype
        Input datatype
    lastname : optional
        Last processed field name (used internally during recursion).
    parents : dictionary
        Dictionary of parent fields (used interbally during recursion).

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> ndtype =  np.dtype([('A', int),
    ...                     ('B', [('BA', int),
    ...                            ('BB', [('BBA', int), ('BBB', int)])])])
    >>> rfn.get_fieldstructure(ndtype)
    ... # XXX: possible regression, order of BBA and BBB is swapped
    {'A': [], 'B': [], 'BA': ['B'], 'BB': ['B'], 'BBA': ['B', 'BB'], 'BBB': ['B', 'BB']}

    NcSsg|]}|�qSr"r")�.0r1r"r"r#�
<listcomp>�sz&get_fieldstructure.<locals>.<listcomp>)r�updater�getr$)r'�lastname�parentsrr)r!Z
lastparentr"r"r#r�s"
ccsBx<|D]4}t|tj�r4x"tt|��D]
}|Vq$Wq|VqWdS)zu
    Returns an iterator of concatenated fields from a sequence of arrays,
    collapsing any nested structure.

    N)�
isinstancer4�void�_izip_fields_flatr%)�iterable�element�fr"r"r#rA�s

rAccs|xv|D]n}t|d�r8t|t�s8xTt|�D]
}|Vq(Wqt|tj�rntt|��dkrnxt|�D]
}|Vq^Wq|VqWdS)zP
    Returns an iterator of concatenated fields from a sequence of arrays.

    �__iter__r2N)�hasattrr?r
�_izip_fieldsr4r@rr%)rBrCrDr"r"r#rG�s


rGTccsT|r
t}nt}tjddkr$tj}ntj}x$||d|i�D]}t||��Vq:WdS)a*
    Returns an iterator of concatenated items from a sequence of arrays.

    Parameters
    ----------
    seqarrays : sequence of arrays
        Sequence of arrays.
    fill_value : {None, integer}
        Value used to pad shorter iterables.
    flatten : {True, False},
        Whether to
    rr�	fillvalueN)rArG�sys�version_info�	itertools�zip_longest�izip_longestr%)r5�
fill_valuer6ZzipfuncrL�tupr"r"r#�izip_records	srPcCs>t|t�sd}|r"|r:|�t�}nt�|�}|r:|�t�}|S)z�
    Private function: return a recarray, a ndarray, a MaskedArray
    or a MaskedRecords depending on the input parameters
    F)r?r�viewr�ma�filledr)r�usemask�
asrecarrayr"r"r#�_fix_output&s


rVcCs\|jj}|j|j|j}}}x8|p&i��D](\}}||kr,|||<|||||<q,W|S)zp
    Update the fill_value and masked data of `output`
    from the default given in a dictionary defaults.
    )rr�data�maskrN�items)r�defaultsrrWrXrN�k�vr"r"r#�
_fix_defaults7sr]���cCs�t|�dkrt�|d�}t|ttjf�r�|j}|rHt|fdd�|jkr�|�	�}|j
s`d|fg}|rt|rnt}q�t}n|r~t
}nt}|j||d�S|f}ndd�|D�}td	d
�|D��}t|�}t||d�}	g}
g}|�r�x�t||�D]�\}}
||
}|�	���}t�|��	�}|�rzt||j�}t|ttjf��r�t|j�dk�rV|��d}d}n"tj||jdd�}tjd|jd
�}nd}d}|
�t�||g|��|�t�||g|��q�Wtt|
|d��}tjtj||	|d�tt||d��d�}|�r�|�t�}n�x�t||�D]�\}}
||
}|�	���}|�r|t||j�}t|ttjf��r�t|j�dk�rh|��d}ntj||jdd�}nd}|
�t�||g|���q
Wtjtt|
|d��|	|d�}|�r�|�t
�}|S)a�
    Merge arrays field by field.

    Parameters
    ----------
    seqarrays : sequence of ndarrays
        Sequence of arrays
    fill_value : {float}, optional
        Filling value used to pad missing data on the shorter arrays.
    flatten : {False, True}, optional
        Whether to collapse nested fields.
    usemask : {False, True}, optional
        Whether to return a masked array or not.
    asrecarray : {False, True}, optional
        Whether to return a recarray (MaskedRecords) or not.

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> rfn.merge_arrays((np.array([1, 2]), np.array([10., 20., 30.])))
    masked_array(data = [(1, 10.0) (2, 20.0) (--, 30.0)],
                 mask = [(False, False) (False, False) (True, False)],
           fill_value = (999999, 1e+20),
                dtype = [('f0', '<i4'), ('f1', '<f8')])

    >>> rfn.merge_arrays((np.array([1, 2]), np.array([10., 20., 30.])),
    ...              usemask=False)
    array([(1, 10.0), (2, 20.0), (-1, 30.0)],
          dtype=[('f0', '<i4'), ('f1', '<f8')])
    >>> rfn.merge_arrays((np.array([1, 2]).view([('a', int)]),
    ...               np.array([10., 20., 30.])),
    ...              usemask=False, asrecarray=True)
    rec.array([(1, 10.0), (2, 20.0), (-1, 30.0)],
              dtype=[('a', '<i4'), ('f1', '<f8')])

    Notes
    -----
    * Without a mask, the missing value will be filled with something,
    * depending on what its corresponding type:
            -1      for integers
            -1.0    for floating point numbers
            '-'     for characters
            '-1'    for strings
            True    for boolean values
    * XXX: I just obtained these values empirically
    r2rT)r6r3)r�typecSsg|]}t�|��qSr")r4�
asanyarray)r9�_mr"r"r#r:�sz merge_arrays.<locals>.<listcomp>css|]}|jVqdS)N)�size)r9r7r"r"r#�	<genexpr>�szmerge_arrays.<locals>.<genexpr>)rZndmin)r2)rN)r�count)rX)rr4r`r?rr@rr8r,�ravelrrrrrQr%�maxrZ	__array__rRZgetmaskarray�_check_fill_value�item�arrayZonesr$rK�chainrPZfromiter�list)r5rNr6rTrUZseqdtypeZseqtype�sizesZ	maxlengthrZseqdataZseqmaskr7�nZ	nbmissingrWrXZfvalZfmskrr"r"r#rEs|1


cs`t|�r|g}nt|�}�fdd���|j|�}|s8dStj|j|d�}t||�}t|||d�S)av
    Return a new array with fields in `drop_names` dropped.

    Nested fields are supported.

    Parameters
    ----------
    base : array
        Input array
    drop_names : string or sequence
        String or sequence of strings corresponding to the names of the
        fields to drop.
    usemask : {False, True}, optional
        Whether to return a masked array or not.
    asrecarray : string or sequence, optional
        Whether to return a recarray or a mrecarray (`asrecarray=True`) or
        a plain ndarray or masked array with flexible dtype. The default
        is False.

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> a = np.array([(1, (2, 3.0)), (4, (5, 6.0))],
    ...   dtype=[('a', int), ('b', [('ba', float), ('bb', int)])])
    >>> rfn.drop_fields(a, 'a')
    array([((2.0, 3),), ((5.0, 6),)],
          dtype=[('b', [('ba', '<f8'), ('bb', '<i4')])])
    >>> rfn.drop_fields(a, 'ba')
    array([(1, (3,)), (4, (6,))],
          dtype=[('a', '<i4'), ('b', [('bb', '<i4')])])
    >>> rfn.drop_fields(a, ['ba', 'bb'])
    array([(1,), (4,)],
          dtype=[('a', '<i4')])
    cs`|j}g}xP|D]H}||}||kr&q|jrJ�||�}|rX|�||f�q|�||f�qW|S)N)rr$)r/�
drop_namesrrr)r!r,)�_drop_descrr"r#ro�s

z drop_fields.<locals>._drop_descrN)r)rTrU)r	�setrr4�empty�shaperrV)�basernrTrUrrr")ror#r�s#
cs:�fdd�|D�}tj�j|d�}t�|�}t|||d�S)a�
    Return a new array keeping only the fields in `keep_names`,
    and preserving the order of those fields.

    Parameters
    ----------
    base : array
        Input array
    keep_names : string or sequence
        String or sequence of strings corresponding to the names of the
        fields to keep. Order of the names will be preserved.
    usemask : {False, True}, optional
        Whether to return a masked array or not.
    asrecarray : string or sequence, optional
        Whether to return a recarray or a mrecarray (`asrecarray=True`) or
        a plain ndarray or masked array with flexible dtype. The default
        is False.
    csg|]}|�j|f�qSr")r)r9rm)rsr"r#r:!sz _keep_fields.<locals>.<listcomp>)r)rTrU)r4rqrrrrV)rsZ
keep_namesrTrUrrr")rsr#�_keep_fieldss
rtcCst||ddd�S)zK
    Returns a new numpy.recarray with fields in `drop_names` dropped.
    FT)rTrU)r)rsrnr"r"r#r'scs"�fdd���|j|�}|�|�S)a�
    Rename the fields from a flexible-datatype ndarray or recarray.

    Nested fields are supported.

    Parameters
    ----------
    base : ndarray
        Input array whose fields must be modified.
    namemapper : dictionary
        Dictionary mapping old field names to their new version.

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> a = np.array([(1, (2, [3.0, 30.])), (4, (5, [6.0, 60.]))],
    ...   dtype=[('a', int),('b', [('ba', float), ('bb', (float, 2))])])
    >>> rfn.rename_fields(a, {'a':'A', 'bb':'BB'})
    array([(1, (2.0, [3.0, 30.0])), (4, (5.0, [6.0, 60.0]))],
          dtype=[('A', '<i4'), ('b', [('ba', '<f8'), ('BB', '<f8', 2)])])

    csVg}xL|jD]B}|�||�}||}|jr@|�|�||�f�q|�||f�qW|S)N)rr<r$)r/�
namemapperrr)Znewnamer!)�_recursive_rename_fieldsr"r#rvEsz/rename_fields.<locals>._recursive_rename_fields)rrQ)rsrurr")rvr#r.sc	CsLt|ttf�r,t|�t|�krBd}t|��nt|t�rB|g}|g}|dkrndd�|D�}dd�t||�D�}n`t|ttf�s�|g}t|�t|�kr�t|�dkr�|t|�}nd}t|��dd�t|||�D�}t|||d	�}t|�dkr�t|d
||d�}n|��}t	j
tt|�t|��|jj
|jj
d�}t||�}t||�}t|||d
�S)a

    Add new fields to an existing array.

    The names of the fields are given with the `names` arguments,
    the corresponding values with the `data` arguments.
    If a single field is appended, `names`, `data` and `dtypes` do not have
    to be lists but just values.

    Parameters
    ----------
    base : array
        Input array to extend.
    names : string, sequence
        String or sequence of strings corresponding to the names
        of the new fields.
    data : array or sequence of arrays
        Array or sequence of arrays storing the fields to add to the base.
    dtypes : sequence of datatypes, optional
        Datatype or sequence of datatypes.
        If None, the datatypes are estimated from the `data`.
    fill_value : {float}, optional
        Filling value used to pad missing data on the shorter arrays.
    usemask : {False, True}, optional
        Whether to return a masked array or not.
    asrecarray : {False, True}, optional
        Whether to return a recarray (MaskedRecords) or not.

    z7The number of arrays does not match the number of namesNcSsg|]}tj|ddd��qS)FT)�copy�subok)r4ri)r9r7r"r"r#r:}sz!append_fields.<locals>.<listcomp>cSs"g|]\}}|�||jfg��qSr")rQr)r9r)r7r"r"r#r:~sr2z5The dtypes argument must be None, a dtype, or a list.cSs0g|](\}}}tj|dd|d��||fg��qS)FT)rwrxr)r4rirQ)r9r7rm�dr"r"r#r:�s)rTrNT)r6rTrN)r)rTrU)r?r%rkrrr
rr�poprR�
masked_allrfrr,rrV)	rsrrW�dtypesrNrTrU�msgrr"r"r#r
Us:




cCst||||ddd�S)aM
    Add new fields to an existing array.

    The names of the fields are given with the `names` arguments,
    the corresponding values with the `data` arguments.
    If a single field is appended, `names`, `data` and `dtypes` do not have
    to be lists but just values.

    Parameters
    ----------
    base : array
        Input array to extend.
    names : string, sequence
        String or sequence of strings corresponding to the names
        of the new fields.
    data : array or sequence of arrays
        Array or sequence of arrays storing the fields to add to the base.
    dtypes : sequence of datatypes, optional
        Datatype or sequence of datatypes.
        If None, the datatypes are estimated from the `data`.

    See Also
    --------
    append_fields

    Returns
    -------
    appended_array : np.recarray
    TF)rWr|rUrT)r
)rsrrWr|r"r"r#r�s
cCs:t|t�r|St|�dkr"|dSdd�|D�}dd�|D�}dd�|D�}dd�|D�}|d}	|	j}
dd�|
D�}x�|dd	�D]�}x�|jD]�}
|
dp�d
}||kr�|
�|
�|�|�q�|�|�}|
|}|�rt�|
d�t�|d�k�rBt|�}|
d|d<t	|�|
|<q�|
d|dkr�t
dt|
�||
df��q�Wq�Wt|
�dk�rdt�
|�}n�t�t�|�f|
�}t�tjd|f�}g}x�t|||d	d�|dd	��D]r\}}}}|jj}|d	k�r�||d
t|�||�<n8x6|D].}||||||�<||k�r�|�|��q�W�q�Wtt||�||d�S)a�
    Superposes arrays fields by fields

    Parameters
    ----------
    arrays : array or sequence
        Sequence of input arrays.
    defaults : dictionary, optional
        Dictionary mapping field names to the corresponding default values.
    usemask : {True, False}, optional
        Whether to return a MaskedArray (or MaskedRecords is
        `asrecarray==True`) or a ndarray.
    asrecarray : {False, True}, optional
        Whether to return a recarray (or MaskedRecords if `usemask==True`)
        or just a flexible-type ndarray.
    autoconvert : {False, True}, optional
        Whether automatically cast the type of the field to the maximum.

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> x = np.array([1, 2,])
    >>> rfn.stack_arrays(x) is x
    True
    >>> z = np.array([('A', 1), ('B', 2)], dtype=[('A', '|S3'), ('B', float)])
    >>> zz = np.array([('a', 10., 100.), ('b', 20., 200.), ('c', 30., 300.)],
    ...   dtype=[('A', '|S3'), ('B', float), ('C', float)])
    >>> test = rfn.stack_arrays((z,zz))
    >>> test
    masked_array(data = [('A', 1.0, --) ('B', 2.0, --) ('a', 10.0, 100.0) ('b', 20.0, 200.0)
     ('c', 30.0, 300.0)],
                 mask = [(False, False, True) (False, False, True) (False, False, False)
     (False, False, False) (False, False, False)],
           fill_value = ('N/A', 1e+20, 1e+20),
                dtype = [('A', '|S3'), ('B', '<f8'), ('C', '<f8')])

    r2rcSsg|]}t�|����qSr")r4r`re)r9r7r"r"r#r:�sz stack_arrays.<locals>.<listcomp>cSsg|]}t|��qSr")r)r9r7r"r"r#r:�scSsg|]
}|j�qSr")r)r9r7r"r"r#r:�scSsg|]
}|j�qSr")r)r9ryr"r"r#r:�scSsg|]}|d�qS)rr")r9r1r"r"r#r:�sNr3r^zIncompatible type '%s' <> '%s'zf%i)rTrU)r?rrr,r$�indexr4rrkr%�	TypeError�dictrR�concatenater{�sumZcumsumZr_rrrVr])ZarraysrZrTrUZautoconvertr5Znrecordsr/ZfldnamesZdtype_lZnewdescrrZdtype_nr,r)�nameidxZ
current_descrr�offset�seenr7rm�i�jr"r"r#r�sT'


 ,



c
Cs�t�|���}t|j�}|}|rBx||D]}||}q*W||}|��}||}|��}	|	dd�|	dd�k}
|r�|j}d|
|dd�<t�dg|
f�}
|
dd�|
dd�|
dd�<|||
}|r�|||
fS|SdS)aa
    Find the duplicates in a structured array along a given key

    Parameters
    ----------
    a : array-like
        Input array
    key : {string, None}, optional
        Name of the fields along which to check the duplicates.
        If None, the search is performed by records
    ignoremask : {True, False}, optional
        Whether masked data should be discarded or considered as duplicates.
    return_index : {False, True}, optional
        Whether to return the indices of the duplicated values.

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> ndtype = [('a', int)]
    >>> a = np.ma.array([1, 1, 1, 2, 2, 3, 3],
    ...         mask=[0, 0, 1, 0, 0, 0, 1]).view(ndtype)
    >>> rfn.find_duplicates(a, ignoremask=True, return_index=True)
    ... # XXX: judging by the output, the ignoremask flag has no effect
    Nr^r2F)	r4r`rerr�argsortrSZ
recordmaskr�)
r7�keyZ
ignoremaskZreturn_indexr-rsrDZsortidxZ
sortedbaseZ
sorteddata�flagZ
sortedmask�
duplicatesr"r"r#rs(
 �inner�1�2c	)s�|dkrtd|��t�t�r$�f�tt���t��kr^t�fdd�t��D��}	td|	��x<�D]4}
|
|jjkr�td|
��|
|jjkrdtd|
��qdW|�	�}|�	�}t|�}|jj|jj}}
t�
t|�t|
�����r�|s�|s�d}|d	7}t|���fd
d�|D�}t||�}t||�}t
�||f�}|j�d�}||}t
�d
g|dd�|dd�kf�}|dd�|dd�|dd�<||}|||k}|||k|}t|�t|�}}|dk�r�d\}}n�|dk�r2||}t�||||kf�}t�||||k|f�}t|�|t|�|}}n<|dk�rn||}t�||||kf�}t|�|d}}||||}}dd�|jjD�}|��fdd�|jjD��tdd�|D��} x�|jjD]�}!t|!�}!|!d}
|
| k�rN|�|!�}"||"}#|
�k�rt|!d|#d�|#d<n0|#d|7<|!d|7<|�|"d|!�n| �|!d�|�|!��q�Wdd�|D�}t||�}$t
j|$||f|d�}%|%jj} x�|D]x}&||&}'|&| k�s�|&|
k�r�|�s�|&�k�r�|&|7}&|%|&}#|'d|�|#d|�<|dk�r�|'|d�|#|$|$|�<�q�Wx�|
D]|}&||&}'|&| k�s\|&|k�rd|�sd|&�k�rd|&|7}&|%|&}#|'d|�|#d|�<|dk�r,|�r,|'|d�|#|d�<�q,W|%j�d�t||d�}(tt|%|�f|(�S)a<
    Join arrays `r1` and `r2` on key `key`.

    The key should be either a string or a sequence of string corresponding
    to the fields used to join the array.  An exception is raised if the
    `key` field cannot be found in the two input arrays.  Neither `r1` nor
    `r2` should have any duplicates along `key`: the presence of duplicates
    will make the output quite unreliable. Note that duplicates are not
    looked for by the algorithm.

    Parameters
    ----------
    key : {string, sequence}
        A string or a sequence of strings corresponding to the fields used
        for comparison.
    r1, r2 : arrays
        Structured arrays.
    jointype : {'inner', 'outer', 'leftouter'}, optional
        If 'inner', returns the elements common to both r1 and r2.
        If 'outer', returns the common elements as well as the elements of
        r1 not in r2 and the elements of not in r2.
        If 'leftouter', returns the common elements and the elements of r1
        not in r2.
    r1postfix : string, optional
        String appended to the names of the fields of r1 that are present
        in r2 but absent of the key.
    r2postfix : string, optional
        String appended to the names of the fields of r2 that are present
        in r1 but absent of the key.
    defaults : {dictionary}, optional
        Dictionary mapping field names to the corresponding default values.
    usemask : {True, False}, optional
        Whether to return a MaskedArray (or MaskedRecords is
        `asrecarray==True`) or a ndarray.
    asrecarray : {False, True}, optional
        Whether to return a recarray (or MaskedRecords if `usemask==True`)
        or just a flexible-type ndarray.

    Notes
    -----
    * The output is sorted along the key.
    * A temporary array is formed by dropping the fields not in the key for
      the two arrays and concatenating the result. This array is then
      sorted, and the common entries selected. The output is constructed by
      filling the fields with the selected entries. Matching is not
      preserved if there are some duplicates...

    )r��outer�	leftouterzWThe 'jointype' argument should be in 'inner', 'outer' or 'leftouter' (got '%s' instead)c3s*|]"\}}|�|dd�kr|VqdS)r2Nr")r9rm�x)r�r"r#rc�szjoin_by.<locals>.<genexpr>zduplicate join key %rzr1 does not have key field %rzr2 does not have key field %rz8r1 and r2 contain common names, r1postfix and r2postfix zcan't be emptycsg|]}|�kr|�qSr"r")r9rm)r�r"r#r:�szjoin_by.<locals>.<listcomp>)�orderFr2Nr^r�)rrr�r�rcSsg|]}t|��qSr")rk)r9r1r"r"r#r:�sc3s"|]}|d�krt|�VqdS)rN)rk)r9r1)r�r"r#rc�scss|]}|dVqdS)rNr")r9r1r"r"r#rc�scSsg|]}t|��qSr")r%)r9r1r"r"r#r:�s)r)r�r�)rTrU)rr?r
rrp�next�	enumeraterrre�intersection�
differencertrRr�r�r4r,r*rkr~rf�insertr$r{�sortr�rVr]))r��r1�r2�jointype�	r1postfix�	r2postfixrZrTrU�dupr)Znb1Zr1namesZr2namesr}�key1Zr1kZr2kZauxZidx_sortZflag_inZidx_inZidx_1Zidx_2Zr1cmnZr2cmnZr1spcZr2spcZidx_out�s1�s2r/r�descr�r!ZcmnrrD�selected�kwargsr")r�r#rLs�3



$ 










$

$cCs$t||||ddd�}t|||f|�S)z�
    Join arrays `r1` and `r2` on keys.
    Alternative to join_by, that always returns a np.recarray.

    See Also
    --------
    join_by : equivalent function
    FT)r�r�r�rZrTrU)r�r)r�r�r�r�r�r�rZr�r"r"r#r�s
)F)NN)NT)TF)N)r^FFF)TF)TF)Nr^TF)N)NTFF)NTF)r�r�r�NTF)r�r�r�N)0�__doc__�
__future__rrrrIrK�numpyr4Znumpy.marRrrrZnumpy.ma.mrecordsrZnumpy.lib._iotoolsr	�numpy.compatr
rJZfuture_builtinsr�corerg�__all__rr&r+r.r8rrArGrPrVr]rrrtrrr
rrrrrr"r"r"r#�<module>s\

'

/



	
@
'
D
"
Y
6
-

Youez - 2016 - github.com/yon3zu
LinuXploit