Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/lib/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/lib/__pycache__/recfunctions.cpython-311.pyc

�

�܋f���n�dZddlZddlZddlmZddlmZmZddlmZddl	m
Z
ddlmZddl
mZejjjZgd�Zd	�Zee��d
���Zd�Zd�Zd
�Zd�ZdAd�ZdAd�ZdBd�Zd�Zd�ZdCd�ZdDd�ZdEd�Z		dFd�Z ee ��		dGd���Z!dBd�Z"ee"��dDd���Z#dDd�Z$d�Z%ee%��d ���Z&d!�Z'ee'��d"���Z(		dFd#�Z)ee)��		dHd$���Z*dEd%�Z+ee+��dEd&���Z,dBd'�Z-ee-��dId(���Z.dJd)�Z/d*�Z0		dKd+�Z1ee1��dLd-���Z2		dMd.�Z3ee3��		dNd/���Z4d0�Z5ee5��d1���Z6dEd2�Z7ee7��dOd3���Z8d4�Z9ee9��d5���Z:		dFd6�Z;ee;��		dPd7���Z<	dKd8�Z=ee=��dQd9���Z>		dRd:�Z?ee?��		dSd>���Z@		dFd?�ZAeeA��		dTd@���ZBdS)Uz�
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.

�N)�ndarray�recarray)�MaskedArray)�
MaskedRecords)�array_function_dispatch)�_is_string_like)�
append_fields�apply_along_fields�assign_fields_by_name�drop_fields�find_duplicates�
flatten_descr�get_fieldstructure�	get_names�get_names_flat�join_by�merge_arrays�rec_append_fields�rec_drop_fields�rec_join�recursive_fill_fields�
rename_fields�
repack_fields�require_fields�stack_arrays�structured_to_unstructured�unstructured_to_structuredc�
�||fS�N�)�input�outputs  �i/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/numpy/lib/recfunctions.py�!_recursive_fill_fields_dispatcherr$s���6�?��c���|j}|jD]Y}	||}n#t$rY�wxYw|jj�t|||���?|||dt	|���<�Z|S)aj
    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', np.int64), ('B', np.float64)])
    >>> b = np.zeros((3,), dtype=a.dtype)
    >>> rfn.recursive_fill_fields(a, b)
    array([(1, 10.), (2, 20.), (0,  0.)], dtype=[('A', '<i8'), ('B', '<f8')])

    N)�dtype�names�
ValueErrorr�len)r!r"�newdtype�field�currents     r#rr#s���4�|�H���3�3��	��E�l�G�G���	�	�	��H�	�����=��*�!�'�6�%�=�9�9�9�9�+2�F�5�M�-�3�w�<�<�-�(�(��Ms��
(�(c�Z���j�d�fgS�fd��jD��}d�|D��S)aR
    Produce a list of name/dtype pairs corresponding to the dtype fields

    Similar to dtype.descr, but the second item of each tuple is a dtype, not a
    string. As a result, this handles subarray dtypes

    Can be passed to the dtype constructor to reconstruct the dtype, noting that
    this (deliberately) discards field offsets.

    Examples
    --------
    >>> dt = np.dtype([(('a', 'A'), np.int64), ('b', np.double, 3)])
    >>> dt.descr
    [(('a', 'A'), '<i8'), ('b', '<f8', (3,))]
    >>> _get_fieldspec(dt)
    [(('a', 'A'), dtype('int64')), ('b', dtype(('<f8', (3,))))]

    N�c3�6�K�|]}|�j|fV��dSr)�fields��.0�namer's  �r#�	<genexpr>z!_get_fieldspec.<locals>.<genexpr>as/�����E�E��4���d�+�,�E�E�E�E�E�Er%c�b�g|],\}}t|��dkr|n	|d|f|df��-S)�r�r*)r3r4�fs   r#�
<listcomp>z"_get_fieldspec.<locals>.<listcomp>csO��
�
�
���a���V�V�q�[�[�T�T�q��t�T�l�A�a�D�9�
�
�
r%�r()r'r1s` r#�_get_fieldspecr<JsU���&
�{���U��}��E�E�E�E���E�E�E��
�
�!�
�
�
�	
r%c	���g}|j}|D]X}||}|j�2|�|tt|����f���C|�|���Yt|��S)aG
    Returns the field names of the input datatype as a tuple. Input datatype
    must have fields otherwise error is raised.

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

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> rfn.get_names(np.empty((1,), dtype=[('A', int)]).dtype)
    ('A',)
    >>> rfn.get_names(np.empty((1,), dtype=[('A',int), ('B', float)]).dtype)
    ('A', 'B')
    >>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])])
    >>> rfn.get_names(adtype)
    ('a', ('b', ('ba', 'bb')))
    )r(�append�tupler��adtype�	listnamesr(r4r-s     r#rris���*�I��L�E��#�#����,���=�$����d�E�)�G�*<�*<�$=�$=�>�?�?�?�?����T�"�"�"�"�����r%c���g}|j}|D]H}|�|��||}|j�"|�t|�����It	|��S)a�
    Returns the field names of the input datatype as a tuple. Input datatype
    must have fields otherwise error is raised.
    Nested structure are flattened beforehand.

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

    Examples
    --------
    >>> from numpy.lib import recfunctions as rfn
    >>> rfn.get_names_flat(np.empty((1,), dtype=[('A', int)]).dtype) is None
    False
    >>> rfn.get_names_flat(np.empty((1,), dtype=[('A',int), ('B', str)]).dtype)
    ('A', 'B')
    >>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])])
    >>> rfn.get_names_flat(adtype)
    ('a', 'b', 'ba', 'bb')
    )r(r>�extendrr?r@s     r#rr�so��,�I��L�E��6�6�����������,���=�$����^�G�4�4�5�5�5������r%c���|j}|�d|ffSg}|D]S}|j|\}}|j�#|�t|�����<|�||f���Tt|��S)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')))

    Nr/)r(r1rDrr>r?)�ndtyper(�descrr,�typ�_s      r#rr�s���
�L�E��}��V�������	+�	+�E��}�U�+�H�S�!��y�$����]�3�/�/�0�0�0�0����e�S�\�*�*�*�*��U�|�|�r%Fc�V�g}|r-|D])}|�t|j�����*ne|D]b}|j}|j�;t	|j��dkr#|�t|�����K|�d|f���ctj|��S)N�r/)rDrr'r(r*r<r>�np)�	seqarrays�flattenr+�ar-s     r#�
_zip_dtyperP�s����H��
/��	4�	4�A��O�O�M�!�'�2�2�3�3�3�3�	4��	/�	/�A��g�G��}�(�S���-?�-?�1�-D�-D�����w� 7� 7�8�8�8�8�����W�
�.�.�.�.�
�8�H���r%c�.�t||���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.
    �rN)rPrG)rMrNs  r#�
_zip_descrrS�s���i��1�1�1�7�7r%c�6�|�i}|j}|D]�}||}|j�3|r|g||<ng||<|�t|||�����Dd�|�|g��pgD��}|r|�|��n|r|g}|pg||<��|S)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']}

    Nc��g|]}|��Sr r )r3rIs  r#r:z&get_fieldstructure.<locals>.<listcomp>s��G�G�G��!�G�G�Gr%)r(�updater�getr>)rA�lastname�parentsr(r4r-�
lastparents       r#rr�s���4�����L�E��-�-����,���=�$��
#�!)����
�
� "���
��N�N�-�g�t�W�E�E�F�F�F�F�G�G�g�k�k�(�B�&?�&?�&E�2�G�G�G�J��
*��!�!�(�+�+�+�+��
*�&�\�
�&�,�"�G�D�M�M��Nr%c#�K�|D]C}t|tj��r#tt	|����Ed{V���?|V��DdS)zu
    Returns an iterator of concatenated fields from a sequence of arrays,
    collapsing any nested structure.

    N)�
isinstancerL�void�_izip_fields_flatr?��iterable�elements  r#r^r^si���������g�r�w�'�'�	�(��w���8�8�8�8�8�8�8�8�8�8��M�M�M�M�	�r%c#�2K�|D]�}t|d��r+t|t��st|��Ed{V���=t|tj��r6t
t|����dkrt|��Ed{V����|V���dS)zP
    Returns an iterator of concatenated fields from a sequence of arrays.

    �__iter__NrK)�hasattrr\�str�_izip_fieldsrLr]r*r?r_s  r#rfrfs�����
�����G�Z�(�(�	��w��,�,�	�#�G�,�,�,�,�,�,�,�,�,�,�
����
)�
)�	�c�%��.�.�.A�.A�Q�.F�.F�#�G�,�,�,�,�,�,�,�,�,�,��M�M�M�M��r%Tc#�K�|rt}nt}tj|d|i�D]}t	||����V��dS)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
    �	fillvalueN)r^rf�	itertools�zip_longestr?)rM�
fill_valuerN�zipfunc�tups     r#�
_izip_recordsrn-sd������#������$�i�F�:�F�F�"�"���G�G�C�L�L�!�!�!�!�!�!�"�"r%c���t|t��sd}|r|r|�t��}n0t	j|��}|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�
asrecarrays   r#�_fix_outputruEsj��
�f�k�*�*�����+��	0��[�[��/�/�F����6�"�"���	+��[�[��*�*�F��Mr%c��|jj}|j|j|j}}}|pi���D]\}}||vr|||<|||||<� |S)zp
    Update the fill_value and masked data of `output`
    from the default given in a dictionary defaults.
    )r'r(�data�maskrk�items)r"�defaultsr(rwrxrk�k�vs        r#�
_fix_defaultsr}Vso��

�L��E� &��V�[�&�:K��4�T��>�r�(�(�*�*�!�!���A���:�:��J�q�M� �D��G�D��G����Mr%c��|Srr )rMrkrNrsrts     r#�_merge_arrays_dispatcherrds���r%���c	���t|��dkrtj|d��}t|ttjf��r�|j}|j�tjd|fg��}|rt|fd���|krP|�	��}|r|rt}nt}n|rt}nt}|�
||���S|f}nd�|D��}td	�|D����}t|��}t||���}	g}
g}|�r�t!||��D�]X\}}
||
z
}|�	�����}t%j|���	��}|r�t)||j��}t|ttjf��rlt|j��dkr|���d}d}n<tj||jd�
��}tjd|j���}nd}d}|
�t3j||g|z����|�t3j||g|z������Ztt7|
|�����}t%jtj||	|�
��t;t7||��������}|r|�
t��}�nFt!||��D]�\}}
||
z
}|�	�����}|r�t)||j��}t|ttjf��rOt|j��dkr|���d}ntj||jd�
��}nd}|
�t3j||g|z������tjtt7|
|�����|	|�
��}|r|�
t��}|S)aR
    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.])))
    array([( 1, 10.), ( 2, 20.), (-1, 30.)],
          dtype=[('f0', '<i8'), ('f1', '<f8')])

    >>> rfn.merge_arrays((np.array([1, 2], dtype=np.int64),
    ...         np.array([10., 20., 30.])), usemask=False)
     array([(1, 10.0), (2, 20.0), (-1, 30.0)],
             dtype=[('f0', '<i8'), ('f1', '<f8')])
    >>> rfn.merge_arrays((np.array([1, 2]).view([('a', np.int64)]),
    ...               np.array([10., 20., 30.])),
    ...              usemask=False, asrecarray=True)
    rec.array([( 1, 10.), ( 2, 20.), (-1, 30.)],
              dtype=[('a', '<i8'), ('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
    rKrNr/TrR)r'�typec�6�g|]}tj|����Sr )rL�
asanyarray)r3�_ms  r#r:z merge_arrays.<locals>.<listcomp>�s"��;�;�;�2�R�]�2�&�&�;�;�;r%c3�$K�|]}|jV��dSr)�size�r3rOs  r#r5zmerge_arrays.<locals>.<genexpr>�s$����,�,�Q�!�&�,�,�,�,�,�,r%)r'�ndmin)rK�r')r'�count)rx)r*rLr�r\rr]r'r(rP�ravelrrrrpr?�max�zip�	__array__rq�getmaskarray�_check_fill_value�item�array�onesr>ri�chainrn�fromiter�list)rMrkrNrsrt�seqdtype�seqtype�sizes�	maxlengthr+�seqdata�seqmaskrO�n�	nbmissingrwrx�fval�fmskr"s                    r#rris1��b	�I���!����M�)�A�,�/�/�	��)�g�r�w�/�0�0�<��?���>�!��x�"�h�� 0�1�1�H��	%�*�i�\�4�@�@�@�H�L�L�!���)�)�I��
"��*�+�G�G�)�G�G��
"�"���!���>�>��w�>�?�?�?�"��I�I�<�;��;�;�;�	��,�,�)�,�,�,�,�,�E��E�
�
�I��)�W�5�5�5�H��G��G��.+��)�U�+�+�	F�	F�F�Q��"�Q��I��7�7�9�9�&�&�(�(�D��?�1�%�%�+�+�-�-�D��
�(��Q�W�=�=���d�W�b�g�$6�7�7�?��4�:���!�+�+�#�y�y�{�{�1�~��#���!�x��A�G�1�E�E�E��!�w�t�4�:�>�>�>��������N�N�9�?�4�$��)�1C�D�D�E�E�E��N�N�9�?�4�$��)�1C�D�D�E�E�E�E��]�7�G�<�<�<�=�=����"�+�d�(�)�L�L�L�#�M�'�7�$K�$K�$K�L�L�N�N�N���	0��[�[��/�/�F���)�U�+�+�	F�	F�F�Q��"�Q��I��7�7�9�9�&�&�(�(�D��
�(��Q�W�=�=���d�W�b�g�$6�7�7�F��4�:���!�+�+�#�y�y�{�{�1�~���!�x��A�G�1�E�E�E������N�N�9�?�4�$��)�1C�D�D�E�E�E�E���U�=��'�#J�#J�#J�K�K�#+�9�>�>�>���	+��[�[��*�*�F��Mr%c��|fSrr )�base�
drop_namesrsrts    r#�_drop_fields_dispatcherr���	���7�Nr%c����t|��r|g}nt|��}�fd���|j|��}tj|j|���}t
||��}t|||���S)a
    Return a new array with fields in `drop_names` dropped.

    Nested fields are supported.

    .. versionchanged:: 1.18.0
        `drop_fields` returns an array with 0 fields if all fields are dropped,
        rather than returning ``None`` as it did previously.

    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', np.int64), ('b', [('ba', np.double), ('bb', np.int64)])])
    >>> rfn.drop_fields(a, 'a')
    array([((2., 3),), ((5., 6),)],
          dtype=[('b', [('ba', '<f8'), ('bb', '<i8')])])
    >>> rfn.drop_fields(a, 'ba')
    array([(1, (3,)), (4, (6,))], dtype=[('a', '<i8'), ('b', [('bb', '<i8')])])
    >>> rfn.drop_fields(a, ['ba', 'bb'])
    array([(1,), (4,)], dtype=[('a', '<i8')])
    c����|j}g}|D]S}||}||vr�|j�&�||��}|r|�||f���<|�||f���T|Sr)r(r>)rFr�r(r+r4r-rG�_drop_descrs       �r#r�z drop_fields.<locals>._drop_descr s����������		1�		1�D��T�l�G��z�!�!���}�(�#��G�Z�8�8���3��O�O�T�5�M�2�2�2������w��0�0�0�0��r%r��rsrt)r�setr'rL�empty�shaperru)r�r�rsrtr+r"r�s      @r#rr�s����L�z�"�"�%� �\�
�
���_�_�
�
�
�
�
�
��{�4�:�z�2�2�H�
�X�d�j��
1�
1�
1�F�
"�4��
0�
0�F��v�w�:�F�F�F�Fr%c����fd�|D��}tj�j|���}t�|��}t	|||���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.
    c�.��g|]}|�j|f��Sr r�)r3r�r�s  �r#r:z _keep_fields.<locals>.<listcomp>Is$���7�7�7�q��D�J�q�M�"�7�7�7r%r�r�)rLr�r�rru)r��
keep_namesrsrtr+r"s`     r#�_keep_fieldsr�6sX���&8�7�7�7�J�7�7�7�H�
�X�d�j��
1�
1�
1�F�
"�4��
0�
0�F��v�w�:�F�F�F�Fr%c��|fSrr �r�r�s  r#�_rec_drop_fields_dispatcherr�Or�r%c�(�t||dd���S)zK
    Returns a new numpy.recarray with fields in `drop_names` dropped.
    FTr�)rr�s  r#rrSs��
�t�Z��4�H�H�H�Hr%c��|fSrr )r��
namemappers  r#�_rename_fields_dispatcherr�[r�r%c�Z���fd���|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., [ 3., 30.])), (4, (5., [ 6., 60.]))],
          dtype=[('A', '<i8'), ('b', [('ba', '<f8'), ('BB', '<f8', (2,))])])

    c����g}|jD]`}|�||��}||}|j�"|�|�||��f���I|�||f���a|Sr)r(rWr>)rFr�r+r4�newnamer-�_recursive_rename_fieldss      �r#r�z/rename_fields.<locals>._recursive_rename_fieldsws�������L�	4�	4�D� �n�n�T�4�0�0�G��T�l�G��}�(�����6�6�w�
�K�K�L���������'� 2�3�3�3�3��r%)r'rp)r�r�r+r�s   @r#rr_sD���0�����(�'��
�J�?�?�H��9�9�X���r%c#�"K�|V�|Ed{V��dSrr )r�r(rw�dtypesrkrsrts       r#�_append_fields_dispatcherr��s$����
�J�J�J��O�O�O�O�O�O�O�O�Or%c��t|ttf��r2t|��t|��krd}t	|���nt|t
��r|g}|g}|�'d�|D��}d�t
||��D��}n�t|ttf��s|g}t|��t|��kr7t|��dkr|t|��z}nd}t	|���d�t
|||��D��}t|||���}t|��dkrt|d	||�
��}n|���}tj
tt|��t|����t|j
��t|j
��z���}t||��}t||��}t|||���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 namesNc�<�g|]}tj|dd�����S)FT)�copy�subok)rLr�r�s  r#r:z!append_fields.<locals>.<listcomp>�s)��B�B�B������d�3�3�3�B�B�Br%c�N�g|]"\}}|�||jfg����#Sr )rpr')r3r4rOs   r#r:z!append_fields.<locals>.<listcomp>�s1��L�L�L�i�t�Q�����q�w��(�)�)�L�L�Lr%rKz5The dtypes argument must be None, a dtype, or a list.c�r�g|]4\}}}tj|dd|����||fg����5S)FT)r�r�r')rLr�rp)r3rOr��ds    r#r:z!append_fields.<locals>.<listcomp>�sU��;�;�;��Q��1�����d�!�<�<�<�A�A�A�q�6�(�K�K�;�;�;r%)rsrkT)rNrsrkr�r�)r\r?r�r*r)rer�r�poprq�
masked_allr�r<r'rru)	r�r(rwr�rkrsrt�msgr"s	         r#r	r	�s	��@�%�%���'�'���u�:�:��T���"�"�K�C��S�/�/�!�#�
�E�3�	�	���	���x��
�~�B�B�T�B�B�B��L�L�3�u�d�;K�;K�L�L�L����&�5�$�-�0�0�	 ��Z�F��t�9�9��F���#�#��6�{�{�a����#�d�)�)�+���M�� ��o�o�%�;�;�!$�T�5�&�!9�!9�;�;�;����g�*�E�E�E�D�
�4�y�y�1�}�}��D�$��'1�3�3�3����x�x�z�z��
�]��C��I�I�s�4�y�y�!�!��T�Z�(�(�>�$�*�+E�+E�E�G�G�G�F�#�4��
0�
0�F�
"�4��
0�
0�F��v�w�:�F�F�F�Fr%c#�"K�|V�|Ed{V��dSrr �r�r(rwr�s    r#�_rec_append_fields_dispatcherr��s$����
�J�J�J��O�O�O�O�O�O�O�O�Or%c�,�t||||dd���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�rtrs)r	r�s    r#rr�s(��>��u�4��$(�%�9�9�9�9r%c��|fSrr )rO�align�recurses   r#�_repack_fields_dispatcherr��s	��
�4�Kr%c���t|tj��s.t|j||���}|�|d���S|j�|Sg}|jD]f}|j|}|rt|d|d���}n|d}t|��dkr
|d|f}|�||f���gtj||�	��}tj|j	|f��S)
a
    Re-pack the fields of a structured array or dtype in memory.

    The memory layout of structured datatypes allows fields at arbitrary
    byte offsets. This means the fields can be separated by padding bytes,
    their offsets can be non-monotonically increasing, and they can overlap.

    This method removes any overlaps and reorders the fields in memory so they
    have increasing byte offsets, and adds or removes padding bytes depending
    on the `align` option, which behaves like the `align` option to
    `numpy.dtype`.

    If `align=False`, this method produces a "packed" memory layout in which
    each field starts at the byte the previous field ended, and any padding
    bytes are removed.

    If `align=True`, this methods produces an "aligned" memory layout in which
    each field's offset is a multiple of its alignment, and the total itemsize
    is a multiple of the largest alignment, by adding padding bytes as needed.

    Parameters
    ----------
    a : ndarray or dtype
       array or dtype for which to repack the fields.
    align : boolean
       If true, use an "aligned" memory layout, otherwise use a "packed" layout.
    recurse : boolean
       If True, also repack nested structures.

    Returns
    -------
    repacked : ndarray or dtype
       Copy of `a` with fields repacked, or `a` itself if no repacking was
       needed.

    Examples
    --------

    >>> from numpy.lib import recfunctions as rfn
    >>> def print_offsets(d):
    ...     print("offsets:", [d.fields[name][1] for name in d.names])
    ...     print("itemsize:", d.itemsize)
    ...
    >>> dt = np.dtype('u1, <i8, <f8', align=True)
    >>> dt
    dtype({'names': ['f0', 'f1', 'f2'], 'formats': ['u1', '<i8', '<f8'], 'offsets': [0, 8, 16], 'itemsize': 24}, align=True)
    >>> print_offsets(dt)
    offsets: [0, 8, 16]
    itemsize: 24
    >>> packed_dt = rfn.repack_fields(dt)
    >>> packed_dt
    dtype([('f0', 'u1'), ('f1', '<i8'), ('f2', '<f8')])
    >>> print_offsets(packed_dt)
    offsets: [0, 1, 9]
    itemsize: 17

    )r�r�F)r�NrT�r7�r�)
r\rLr'r�astyper(r1r*r>r�)rOr�r��dt�	fieldinfor4rm�fmts        r#rrs���x�a���"�"�(�
�1�7�%��
A�
A�
A���x�x���x�'�'�'��w�����I���
&�
&���h�t�n���	���A��e�T�B�B�B�C�C��a�&�C��s�8�8�q�=�=���F�D�>�D����$���%�%�%�%�	��)�5�	)�	)�	)�B�
�8�Q�V�R�L�!�!�!r%c���
��d�}g}|jD]�}|j|}|d|d}}||��\}}|j�1|�tj||ff��|||zf���et|||z��}	|j�t|��D]@�
�
dkr|�|	���|��
�fd�|	D�����A��|S)z�
    Returns a flat list of (dtype, count, offset) tuples of all the
    scalar fields in the dtype "dt", including nested fields, in left
    to right order.
    c�f�d}|jdkr!|jD]}||z}�|j}|jdk�!||fS)NrKr )r�r�)r�r�r�s   r#�
count_elemz+_get_fields_and_offsets.<locals>.count_elem\sN�����h�"�n�n���
�
����
�����B��h�"�n�n��5�y�r%rrKNc�.��g|]\}}}|||��zzf��Sr r )r3r��c�o�ir�s    ��r#r:z+_get_fields_and_offsets.<locals>.<listcomp>us.���"O�"O�"O�'�!�Q��A�q�!�a��f�*�#5�"O�"O�"Or%)	r(r1r>rLr'�_get_fields_and_offsets�itemsize�rangerD)r��offsetr�r1r4r,�f_dt�f_offsetr��	subfieldsr�r�s          @@r#r�r�Ss��������F���Q�Q���	�$����q��5��8�h���*�T�"�"���a��:���M�M�2�8�T�A�4�L�1�1�1�h��6G�H�I�I�I�I�/��h��6G�H�H�I��=�D��1�X�X�
Q�
Q����6�6��M�M�)�,�,�,�,��M�M�"O�"O�"O�"O�"O�Y�"O�"O�"O�P�P�P�P�
Q��Mr%c�h�t|��dkr|S|d|dk}|r+tt|��t|����}nt||��}d}d}|D]A\}}|dkr|rdS|�|}||krdS||dz
|zz}	n|}	|�||z
}
|�|
}||
krdS|	}�B|r|S|S)z�
    Returns the stride between the fields, or None if the stride is not
    constant. The values in "counts" designate the lengths of
    subarrays. Subarrays are treated as many contiguous fields, with
    always positive stride.
    rKrN)r*r��reversed)�offsets�countsr��negative�it�prev_offset�strider�r��
end_offset�
new_strides           r#�_common_strider�xs���7�|�|�q������q�z�G�A�J�&�H��"�
��'�"�"�H�V�$4�$4�
5�
5���
��&�
!�
!���K�
�F��!�!�
����A�:�:��
��t�t��~�!����!�!��t�t��5�1�9��"8�8�J�J��J��"��+�-�J��~�#����#�#��t�t� ������w���Mr%c��|fSrr )�arrr'r��castings    r#�&_structured_to_unstructured_dispatcherr���	���6�Mr%�unsafec���|jj�td���t|j��}t	|��}|dkr|�td���|dkrtd���t
|�\}}}d�t|��D��}	|�tj	d�|D����ntj|���tj|	|||jj
d���}
|�|
��}t|��tj
tjtjfv}|�sF|�rCt!�fd	�|D�����r't#||�j
��}|��|j}
|jt)|���j
fz}|jt-|��d
fz}|dtjf�tj��}|dt3|��d�f}tjj�|||d�
��}|����d}|dkr
|dddd�f}t|��t|
j��ur|
|��}|Stj|	�fd�|D��d���}|�|||���}|��t)|��ff��S)aW
    Converts an n-D structured array into an (n+1)-D unstructured array.

    The new array will have a new last dimension equal in size to the
    number of field-elements of the input array. If not supplied, the output
    datatype is determined from the numpy type promotion rules applied to all
    the field datatypes.

    Nested fields, as well as each element of any subarray fields, all count
    as a single field-elements.

    Parameters
    ----------
    arr : ndarray
       Structured array or dtype to convert. Cannot contain object datatype.
    dtype : dtype, optional
       The dtype of the output unstructured array.
    copy : bool, optional
        If true, always return a copy. If false, a view is returned if
        possible, such as when the `dtype` and strides of the fields are
        suitable and the array subtype is one of `np.ndarray`, `np.recarray`
        or `np.memmap`.

        .. versionchanged:: 1.25.0
            A view can now be returned if the fields are separated by a
            uniform stride.

    casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
        See casting argument of `numpy.ndarray.astype`. Controls what kind of
        data casting may occur.

    Returns
    -------
    unstructured : ndarray
       Unstructured array with one more dimension.

    Examples
    --------

    >>> from numpy.lib import recfunctions as rfn
    >>> a = np.zeros(4, dtype=[('a', 'i4'), ('b', 'f4,u2'), ('c', 'f4', 2)])
    >>> a
    array([(0, (0., 0), [0., 0.]), (0, (0., 0), [0., 0.]),
           (0, (0., 0), [0., 0.]), (0, (0., 0), [0., 0.])],
          dtype=[('a', '<i4'), ('b', [('f0', '<f4'), ('f1', '<u2')]), ('c', '<f4', (2,))])
    >>> rfn.structured_to_unstructured(a)
    array([[0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0.]])

    >>> b = np.array([(1, 2, 5), (4, 5, 7), (7, 8 ,11), (10, 11, 12)],
    ...              dtype=[('x', 'i4'), ('y', 'f4'), ('z', 'f8')])
    >>> np.mean(rfn.structured_to_unstructured(b[['x', 'z']]), axis=-1)
    array([ 3. ,  5.5,  9. , 11. ])

    N�arr must be a structured arrayrz(arr has no fields. Unable to guess dtypez#arr with no fields is not supportedc�8�g|]}d�|����S�zf{}��format�r3r�s  r#r:z.structured_to_unstructured.<locals>.<listcomp>�s"��6�6�6��U�\�\�!�_�_�6�6�6r%c��g|]	}|j��
Sr �r�)r3r�s  r#r:z.structured_to_unstructured.<locals>.<listcomp>�s��$;�$;�$;��R�W�$;�$;�$;r%�r(�formatsr�r�c3�.�K�|]}|j�kV��dSrr�r3r��	out_dtypes  �r#r5z-structured_to_unstructured.<locals>.<genexpr>s*�����&J�&J��r�w�)�';�&J�&J�&J�&J�&J�&Jr%rK.T)r��.rr�c�"��g|]}�|jf��Sr )r�rs  �r#r:z.structured_to_unstructured.<locals>.<listcomp>$s ���)N�)N�)N�B�9�b�h�*?�)N�)N�)Nr%�r(r�r�r�)r'r(r)r�r*�NotImplementedErrorr�r�rL�result_typer�rpr�rr�memmap�allr��__array_wrap__r��sum�strides�abs�newaxis�uint8�min�lib�
stride_tricks�
as_strided�__self__r�)r�r'r�r�r1�n_fields�dtsr�r�r(�flattened_fields�can_view�
common_stride�wrap�	new_shape�new_strides�
packed_fieldsrs                 @r#rr�s����v�y����9�:�:�:�
$�S�Y�
/�
/�F��6�{�{�H��1�}�}����C�D�D�D�	�Q���!�"G�H�H�H���<��C���6�6�e�H�o�o�6�6�6�E��}��N�$;�$;�s�$;�$;�$;�<�	�	��H�U�O�O�	��x�%�,/�,3�-0�Y�-?�!A�!A�B�B���(�(�#�
$�
$�C�
�C�y�y�R�Z���b�i�@�@�H���h��3�&J�&J�&J�&J�c�&J�&J�&J�#J�#J��'�w��	�8J�K�K�
��$��%�D��	�S��[�[�)�2D�$E�E�I��+��]�);�);�Q�(?�?�K��c�2�:�o�&�+�+�B�H�5�5�C��c�3�w�<�<�=�=�(�)�C��&�&�1�1�#�2;�2=�8<�2�>�>�C��(�(�9�%�%�f�-�C��q� � ��#�t�t��t�)�n���C�y�y��T�]� 3� 3�3�3��d�3�i�i���J��H�u�)N�)N�)N�)N�#�)N�)N�)N�P�P�Q�Q�M�

�*�*�]��w�*�
?�
?�C��8�8�Y��V����/�0�0�0r%c��|fSrr )r�r'r(r�r�r�s      r#�&_unstructured_to_structured_dispatcherr#+r�r%c�����jdkrtd����jd}|dkrtd���|�Z|�d�t|��D��}t	j�fd�|D��|�	��}t
|��}t|�\}	}
}n�|�td
���t	j|��}t
|��}t|��dkrggg}}
}	n
t|�\}	}
}|t|
��krtd���|}|r|j
std���d
�tt|����D��}t	j|�fd�|	D��d���}t	j����|���t	j||	||j
d���}
��|
||������|��dS)a
    Converts an n-D unstructured array into an (n-1)-D structured array.

    The last dimension of the input array is converted into a structure, with
    number of field-elements equal to the size of the last dimension of the
    input array. By default all output fields have the input array's dtype, but
    an output structured dtype with an equal number of fields-elements can be
    supplied instead.

    Nested fields, as well as each element of any subarray fields, all count
    towards the number of field-elements.

    Parameters
    ----------
    arr : ndarray
       Unstructured array or dtype to convert.
    dtype : dtype, optional
       The structured dtype of the output array
    names : list of strings, optional
       If dtype is not supplied, this specifies the field names for the output
       dtype, in order. The field dtypes will be the same as the input array.
    align : boolean, optional
       Whether to create an aligned memory layout.
    copy : bool, optional
        See copy argument to `numpy.ndarray.astype`. If true, always return a
        copy. If false, and `dtype` requirements are satisfied, a view is
        returned.
    casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
        See casting argument of `numpy.ndarray.astype`. Controls what kind of
        data casting may occur.

    Returns
    -------
    structured : ndarray
       Structured array with fewer dimensions.

    Examples
    --------

    >>> from numpy.lib import recfunctions as rfn
    >>> dt = np.dtype([('a', 'i4'), ('b', 'f4,u2'), ('c', 'f4', 2)])
    >>> a = np.arange(20).reshape((4,5))
    >>> a
    array([[ 0,  1,  2,  3,  4],
           [ 5,  6,  7,  8,  9],
           [10, 11, 12, 13, 14],
           [15, 16, 17, 18, 19]])
    >>> rfn.unstructured_to_structured(a, dt)
    array([( 0, ( 1.,  2), [ 3.,  4.]), ( 5, ( 6.,  7), [ 8.,  9.]),
           (10, (11., 12), [13., 14.]), (15, (16., 17), [18., 19.])],
          dtype=[('a', '<i4'), ('b', [('f0', '<f4'), ('f1', '<u2')]), ('c', '<f4', (2,))])

    r z$arr must have at least one dimensionr�rz&last axis with size 0 is not supportedNc�8�g|]}d�|����Sr�r�r�s  r#r:z.unstructured_to_structured.<locals>.<listcomp>ps"��<�<�<��U�\�\�!�_�_�<�<�<r%c�"��g|]}|�jf��Sr r�)r3r�r�s  �r#r:z.unstructured_to_structured.<locals>.<listcomp>qs���<�<�<��q�#�)�n�<�<�<r%r�z!don't supply both dtype and nameszVThe length of the last dimension of arr must be equal to the number of fields in dtypez'align was True but dtype is not alignedc�8�g|]}d�|����Sr�r�r�s  r#r:z.unstructured_to_structured.<locals>.<listcomp>�s"��9�9�9��U�\�\�!�_�_�9�9�9r%c�,��g|]}�j|jf��Sr )r'r�)r3r�r�s  �r#r:z.unstructured_to_structured.<locals>.<listcomp>�s"���)N�)N�)N�B�3�9�b�h�*?�)N�)N�)Nr%rrr	r)r�r)r
r�rLr'r�r�r*r�isalignedstruct�ascontiguousarrayrpr�r�)r�r'r(r�r�r��n_elemrr1rr�r�r!rs`             r#rr/s=���p�y�B����?�@�@�@�
�Y�r�]�F�
��{�{�!�"J�K�K�K��}��=�<�<�e�F�m�m�<�<�<�E��H�<�<�<�<�e�<�<�<�E�J�J�J�	�(��3�3��"�F�|���V�W�W����@�A�A�A�������(��/�/���v�;�;�!���#%�r�2���C�C�#&��<� �C����S��[�[� � ��I�J�J�
J��	��	H��2�	H��F�G�G�G�9�9�e�C��K�K�&8�&8�9�9�9�E�
�H�u�)N�)N�)N�)N�#�)N�)N�)N�P�P�Q�Q�M�
�
�s�
#�
#�
(�
(��
7�
7�C��x�%�,/�,3�-6�-?�!A�!A�B�B���*�*�%�D�'�*�
B�
B�C��8�8�I���v�&�&r%c��|fSrr )�funcr�s  r#�_apply_along_fields_dispatcherr.�s	���6�Mr%c�p�|jj�td���t|��}||d���S)a@
    Apply function 'func' as a reduction across fields of a structured array.

    This is similar to `apply_along_axis`, but treats the fields of a
    structured array as an extra axis. The fields are all first cast to a
    common type following the type-promotion rules from `numpy.result_type`
    applied to the field's dtypes.

    Parameters
    ----------
    func : function
       Function to apply on the "field" dimension. This function must
       support an `axis` argument, like np.mean, np.sum, etc.
    arr : ndarray
       Structured array for which to apply func.

    Returns
    -------
    out : ndarray
       Result of the recution operation

    Examples
    --------

    >>> from numpy.lib import recfunctions as rfn
    >>> b = np.array([(1, 2, 5), (4, 5, 7), (7, 8 ,11), (10, 11, 12)],
    ...              dtype=[('x', 'i4'), ('y', 'f4'), ('z', 'f8')])
    >>> rfn.apply_along_fields(np.mean, b)
    array([ 2.66666667,  5.33333333,  8.66666667, 11.        ])
    >>> rfn.apply_along_fields(np.mean, b[['x', 'z']])
    array([ 3. ,  5.5,  9. , 11. ])

    Nr�r�)�axis)r'r(r)r)r-r��uarrs   r#r
r
�s@��F�y����9�:�:�:�%�c�*�*�D��4��2����r%c�
�||fSrr )�dst�src�zero_unassigneds   r#�!_assign_fields_by_name_dispatcherr6�s����8�Or%c��|jj�||d<dS|jjD]5}||jjvr|rd||<�t|||||���6dS)a�
    Assigns values from one structured array to another by field name.

    Normally in numpy >= 1.14, assignment of one structured array to another
    copies fields "by position", meaning that the first field from the src is
    copied to the first field of the dst, and so on, regardless of field name.

    This function instead copies "by field name", such that fields in the dst
    are assigned from the identically named field in the src. This applies
    recursively for nested structures. This is how structure assignment worked
    in numpy >= 1.6 to <= 1.13.

    Parameters
    ----------
    dst : ndarray
    src : ndarray
        The source and destination arrays during assignment.
    zero_unassigned : bool, optional
        If True, fields in the dst for which there was no matching
        field in the src are filled with the value 0 (zero). This
        was the behavior of numpy <= 1.13. If False, those fields
        are not modified.
    N.r)r'r(r)r3r4r5r4s    r#rr�s���4�y�����C�����	��3�3���s�y��&�&��
���D�	��!�#�d�)�S��Y�"1�
3�
3�
3�
3�3�3r%c��|fSrr )r��required_dtypes  r#�_require_fields_dispatcherr:�s	���8�Or%c�\�tj|j|���}t||��|S)a�
    Casts a structured array to a new dtype using assignment by field-name.

    This function assigns from the old to the new array by name, so the
    value of a field in the output array is the value of the field with the
    same name in the source array. This has the effect of creating a new
    ndarray containing only the fields "required" by the required_dtype.

    If a field name in the required_dtype does not exist in the
    input array, that field is created and set to 0 in the output array.

    Parameters
    ----------
    a : ndarray
       array to cast
    required_dtype : dtype
       datatype for output array

    Returns
    -------
    out : ndarray
        array with the new dtype, with field values copied from the fields in
        the input array with the same name

    Examples
    --------

    >>> from numpy.lib import recfunctions as rfn
    >>> a = np.ones(4, dtype=[('a', 'i4'), ('b', 'f8'), ('c', 'u1')])
    >>> rfn.require_fields(a, [('b', 'f4'), ('c', 'u1')])
    array([(1., 1), (1., 1), (1., 1), (1., 1)],
      dtype=[('b', '<f4'), ('c', 'u1')])
    >>> rfn.require_fields(a, [('b', 'f4'), ('newf', 'u1')])
    array([(1., 0), (1., 0), (1., 0), (1., 0)],
      dtype=[('b', '<f4'), ('newf', 'u1')])

    r�)rLr�r�r)r�r9�outs   r#rr�s0��N
�(�5�;�n�
5�
5�
5�C��#�u�%�%�%��Jr%c��|Srr )�arraysrzrsrt�autoconverts     r#�_stack_arrays_dispatcherr@ s���Mr%c	��t|t��r|St|��dkr|dSd�|D��}d�|D��}d�|D��}d�|D��}|d}	t|	��}
d�|
D��}|dd�D]�}t|��D]�\}
}|
|vr-|
�|
|f��|�|
���6|�|
��}|
|\}}|r|
t
||��f|
|<�n||krtd	|�d
|�d��������t|
��dkrtj	|��}n�tj
tj|��f|
��}tj
tjd|f��}g}t|||dd�|dd���D]d\}}}}|jj}|�||d
t|��z||�<�3|D].}||||||�<||vr|�|���/�et%t'||��||���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', np.double), ('C', np.double)])
    >>> test = rfn.stack_arrays((z,zz))
    >>> test
    masked_array(data=[(b'A', 1.0, --), (b'B', 2.0, --), (b'a', 10.0, 100.0),
                       (b'b', 20.0, 200.0), (b'c', 30.0, 300.0)],
                 mask=[(False, False,  True), (False, False,  True),
                       (False, False, False), (False, False, False),
                       (False, False, False)],
           fill_value=(b'N/A', 1.e+20, 1.e+20),
                dtype=[('A', 'S3'), ('B', '<f8'), ('C', '<f8')])

    rKrc�Z�g|](}tj|�������)Sr )rLr�r�r�s  r#r:z stack_arrays.<locals>.<listcomp>Rs.��:�:�:�a���q�!�!�'�'�)�)�:�:�:r%c�,�g|]}t|����Sr r8r�s  r#r:z stack_arrays.<locals>.<listcomp>Ss��*�*�*�1��A���*�*�*r%c��g|]	}|j��
Sr r�r�s  r#r:z stack_arrays.<locals>.<listcomp>Ts��
)�
)�
)�!�a�g�
)�
)�
)r%c��g|]	}|j��
Sr r;)r3r�s  r#r:z stack_arrays.<locals>.<listcomp>Us��(�(�(�A���(�(�(r%c��g|]\}}|��Sr r )r3r�r�s   r#r:z stack_arrays.<locals>.<listcomp>Ys��$�$�$�4�1�a�Q�$�$�$r%NzIncompatible type 'z' <> '�'r�zf%ir�)r\rr*r<r>�indexr��	TypeErrorrq�concatenater�rLr�cumsum�r_r�r'r(rur})r>rzrsrtr?rM�nrecordsrF�fldnames�dtype_l�newdescrr(�dtype_n�fname�fdtype�nameidxrI�cdtyper"r��seenrOr�r��jr4s                          r#rr%s���R�&�'�"�"���
�	�V����	�	��a�y��:�:�6�:�:�:�I�*�*�	�*�*�*�H�
)�
)�y�
)�
)�
)�F�(�(��(�(�(�H��Q�i�G��g�&�&�H�$�$�8�$�$�$�E��!�"�"�:�6�6��+�G�4�4�	6�	6�M�E�6��E�!�!�������0�0�0����U�#�#�#�#��+�+�e�,�,��$�W�-�	��6��6�).��F�F�0C�0C�(D�H�W�%�%��v�%�%�#�)�%+�V�V�V�V�V�%5�6�6�6�&�	6��8�}�}������	�*�*�������x� 0� 0�2�H�=�=����2�5��H��-�.�.�����	�8�V�C�R�C�[�&����*�M�M�	*�	*�L�Q��1�a��G�M�E��}�12��u�s�4�y�y�(�)�!�A�#�.�.��*�*�D�()�$��F�4�L��1��%��4�'�'����D�)�)�)��*�
�}�V�X�6�6�&�:�?�?�?�?r%c��|fSrr )rO�key�
ignoremask�return_indexs    r#�_find_duplicates_dispatcherr\}s	��
�4�Kr%c��tj|�����}t|j��}|}|r||D]
}||}�||}|���}||}|���}	|	dd�|	dd�k}
|r|j}d|
|dd�<tjdg|
f��}
|
dd�|
dd�z|
dd�<|||
}|r
|||
fS|S)a�
    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)
    (masked_array(data=[(1,), (1,), (2,), (2,)],
                 mask=[(False,), (False,), (False,), (False,)],
           fill_value=(999999,),
                dtype=[('a', '<i8')]), array([0, 1, 3, 4]))
    Nr�rKF)	rLr�r�rr'�argsortrr�
recordmaskrJ)
rOrYrZr[r1r�r9�sortidx�
sortedbase�
sorteddata�flag�
sortedmask�
duplicatess
             r#r
r
�s'��:	�
�a����� � �A�
���
(�
(�F��D�
�����	�	�A���7�D�D��C�y���l�l�n�n�G��g��J��"�"�$�$�J��s��s�O�z�!�"�"�~�-�D��%��*�
�$��Z����^��
�>�E�7�D�/�*�*�D��S�b�S�	�D����H�$�D��"��I��7��D�!�J����G�D�M�*�*��r%c	�
�||fSrr )	rY�r1�r2�jointype�	r1postfix�	r2postfixrzrsrts	         r#�_join_by_dispatcherrl��
��
��8�Or%�inner�1�2c	�
��|dvrtd|z���t�t��r�f�tt	�����t���kr:t�fd�t
���D����}	td|	z����D]B}
|
|jjvrtd|
z���|
|jjvrtd|
z����C|�	��}|�	��}t|��}|jj|jj}
}t	|��t	|
��zt	���z
}|r|s|sd}|dz
}t|����fd	�|D��}t||��}t||��}tj||f��}|�
��
��}||}tjdg|dd
�|d
d�kf��}|dd
�|d
d�z|d
d�<||}|||k}|||k|z
}t|��t|��}}|dkrd\}}n�|dkrq||}tj||||kf��}tj||||k|z
f��}t|��|z
t|��|z
}}nC|dkr=||}tj||||kf��}t|��|z
d}}||||}}t|j��} t|j��D] \}!}"|!�vr| �|!|"f���!t|j��D]�\}!}"t#d�| D����}#	|#�|!��}$| |$\}%}&|!�vr|!t'|"|&��f| |$<�Y|!|z|&f|!|z|"fg| |$|$dz�<�p#t$r| �|!|"f��Y��wxYwtj| ��} t'||��}'tj|'|z|zf| ���}(|(jj}#|D]J})||)}*|)|#vs
|)|
vr|s	|)�vr|)|z
})|(|)}+|*d
|�|+d
|�<|dvr|*|d
�|+|'|'|z�<�K|
D]L})||)}*|)|#vs
|)|vr|s	|)�vr|)|z
})|(|)}+|*d
|�|+d
|�<|dkr|r|*|d
�|+|d
�<�M|(���
��t-||���},t/t1|(|��fi|,��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...

    )rn�outer�	leftouterzWThe 'jointype' argument should be in 'inner', 'outer' or 'leftouter' (got '%s' instead)c3�@�K�|]\}}|�|dzd�v�|V��dS)rKNr )r3r��xrYs   �r#r5zjoin_by.<locals>.<genexpr>s7�����A�A���1�!�s�1�Q�3�4�4�y�.�.�1�.�.�.�.�A�Ar%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 both be emptyc���g|]}|�v�|��	Sr r )r3r�rYs  �r#r:zjoin_by.<locals>.<listcomp>s���-�-�-�1�1��8�8�Q�8�8�8r%)�orderFrKNr�rn)rrrrrsrc3� K�|]	\}}|V��
dSrr r2s   r#r5zjoin_by.<locals>.<genexpr>Es&����4�4�k�d�E�T�4�4�4�4�4�4r%r�)rrrsr�)r)r\rer*r��next�	enumerater'r(r�r�rqrJr^rLr<r>r�rHr�r��sort�dictrur})-rYrgrhrirjrkrzrsrt�dupr4�nb1�r1names�r2names�
collisionsr��key1�r1k�r2k�aux�idx_sort�flag_in�idx_in�idx_1�idx_2�r1cmn�r2cmn�r1spc�r2spc�idx_out�s1�s2rFrRrSr(rTrIrU�cmnr"r9�selectedr-�kwargss-`                                            r#rr�sT���h�6�6�6��<�>F�G���	�
�#�s�����f���3�s�8�8�}�}��C��� � ��A�A�A�A�	�#���A�A�A�A�A���0�3�6�7�7�7��E�E���r�x�~�%�%��<�t�C�D�D�D��r�x�~�%�%��<�t�C�D�D�D�&�
�����B�	�����B��b�'�'�C��(�.�"�(�.�g�W��g�,�,��W���-��S���9�J���9��	��H���$�$����o�o��.�-�-�-��-�-�-�D�
�r�4�
 �
 �C�
�r�4�
 �
 �C�
�.�#�s��
$�
$�C��{�{��{�%�%�H�

�h�-�C��n�u�g�s�1�2�2�w�#�c�r�c�(�':�;�<�<�G��1�2�2�;���"���-�G�C�R�C�L�
�g�
�F��F�S�L�"�E��F�c�M�#�c�)�E��%�j�j�#�e�*�*�E�U��7��������	�W�	�	��G�8�$�����w��#�
�'?�@�A�A�����w��3��'@�3�'F�G�H�H���e�*�*�u�,�c�%�j�j�5�.@����	�[�	 �	 ��G�8�$�����w��#�
�'?�@�A�A���e�*�*�u�,�a����5�	�2�e�9��R��C�I�
&�
&�F�(���1�1�+�+�
��v������M�M�5�&�/�*�*�*��(���1�1���
��v��4�4�V�4�4�4�4�4��	��k�k�%�(�(�G��w��I�A�v���|�|�#(�#�f�f�*=�*=�">��w���
�Y�&��/��Y�&��/�/��w�w��{�*�+�+���	+�	+�	+��M�M�5�&�/�*�*�*�*�*�	+����"�X�f�
�
�F��e�U�
�
�C�
�]�C�%�K�%�/�1��
@�
@�
@�F��L��E�
�8�8���a�5���E�>�>�a�7�l�l�9�l��#���
��N�A���)��"�6�E�6�*�������-�-�-�'/����'7�G�C��e��O�$��
�0�0���a�5���E�>�>�a�7�l�l�9�l��#���
��N�A���)��"�6�E�6�*����������U��'����/�G�U�F�G�G���
�K�K�c�K����
�'�j�
9�
9�
9�F��}�V�X�6�6�A�A�&�A�A�As�0P�!P%�$P%c�
�||fSrr )rYrgrhrirjrkrzs       r#�_rec_join_dispatcherr�vrmr%c�J�t||||dd���}t|||fi|��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)rirjrkrzrsrt)r|r)rYrgrhrirjrkrzr�s        r#rr|sB���8�y�I�#�U�t�E�E�E�F��3��B�)�)�&�)�)�)r%)F)NN)NT)TFr)NNNN)r�FFF)Nr�TF)FF)r)NNN)NFr�)NNNNN)NNFFr�)T)NTFF)NTF)NNNNNN)rnrorpNTF)rnrorpN)C�__doc__ri�numpyrL�numpy.marqrrr�numpy.ma.mrecordsr�numpy.core.overridesr�numpy.lib._iotoolsr�corer��__all__r$rr<rrrrPrSrr^rfrnrur}rrr�rr�r�rr�rr�r	r�rr�rr�r�r�rr#rr.r
r6rr:rr@rr\r
rlrr�rr r%r#�<module>r�s�������������������#�#�#�#�#�#�#�#� � � � � � �+�+�+�+�+�+�8�8�8�8�8�8�.�.�.�.�.�.��E�J�0�����������:�;�;�#�#�<�;�#�L
�
�
�>���@���@���4
�
�
�
� 8�8�8�8�,�,�,�,�^
�
�
�
�
�
� "�"�"�"�0����"����BF�6:�����
��1�2�2�38�+0�D�D�D�3�2�D�N������0�1�1�=G�=G�=G�2�1�=G�@G�G�G�G�2�����4�5�5�I�I�6�5�I������2�3�3�$�$�4�3�$�N9=�HL�������2�3�3�,0�:?�CG�CG�CG�4�3�CG�L����
��6�7�7�9�9�9�8�7�9�D������2�3�3�P"�P"�P"�4�3�P"�d#�#�#�#�J*�*�*�ZBF�37�������?�@�@�~1�~1�~1�A�@�~1�BCG�JN�������?�@�@�BG�3;�h'�h'�h'�A�@�h'�T�����7�8�8�&�&�9�8�&�T������:�;�;�#3�#3�#3�<�;�#3�J�����3�4�4�(�(�5�4�(�V=A�:>�����
��1�2�2�AF�"�T?�T?�T?�3�2�T?�p48�����
��4�5�5�6�6�6�6�5�6�t?C�04�������,�-�-�DG�49�pB�pB�pB�.�-�pB�h?C��������-�.�.�EH��*�*�*�/�.�*�*�*r%

Hacked By AnonymousFox1.0, Coded By AnonymousFox