Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
recfunctions.cpython-313.pyc902 linesDownload Raw Back to __pycache__
1�

2z�j$����SrSSKrSSKrSSKJr SSKJs Jr SSK	J3r4 SSKJr /SQr
Sr\5"\5S5rSrS	rS6rSrS7SjrS7S
jrS8SjrSrSrS9SjrS:SjrS;SjrS<Sjr\7"\5S=Sj5rS8Sjr\8"\5S:Sj5rS:Sjr Sr!\9"\!5S5r"Sr#\10"\#5S5r$S<Sjr%\11"\%5S>Sj5r&S;Sjr'\12"\'5S;S j5r(S8S!jr)\13"\)5S?S"j5r*S@S#jr+S$r,SAS%jr-\14"\-5SBS&j5r.SCS'jr/\15"\/5SDS(j5r0S)r1\16"\15S*5r2S;S+jr3\17"\35SES,j5r4S-r5\18"\55S.5r6S<S/jr7\19"\75SFS0j5r8SAS1jr9\20"\95SGS2j5r:SHS3jr;\21"\;5SIS4j5r<S<S5jr=\22"\=5SJS6j5r>C23g)Kz�24Collection of utilities to manipulate structured arrays.25 26Most of these functions were initially implemented by John Hunter for27matplotlib.  They have been rewritten and extended for convenience.28 29�N)�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��X4$�N�)�input�outputs  �\D:\code\apps\devtools\python\user_packages\Python313\site-packages\numpy/lib/recfunctions.py�!_recursive_fill_fields_dispatcherr s30���?��c���URnURH?nXnURRb[XAU5 M/XAUS[	U5&MA U$![a MRf=f)a531Fills fields from output with fields from input,32with support for nested structures.33 34Parameters35----------36input : ndarray37    Input array.38output : ndarray39    Output array.40 41Notes42-----43* `output` should be at least the same size as `input`44 45Examples46--------47>>> import numpy as np48>>> from numpy.lib import recfunctions as rfn49>>> a = np.array([(1, 10.), (2, 20.)], dtype=[('A', np.int64), ('B', np.float64)])50>>> b = np.zeros((3,), dtype=a.dtype)51>>> rfn.recursive_fill_fields(a, b)52array([(1, 10.), (2, 20.), (0,  0.)], dtype=[('A', '<i8'), ('B', '<f8')])53 54N)�dtype�names�55ValueErrorr�len)rr�newdtype�field�currents     rrrsr��6�|�|�H�����	��l�G��=�=���*�!�'�%�=�9�+2�5�M�-�3�w�<�(� ��M��
�	��	�s�A�56A,�+A,c��^�TRcST4/$U4SjTR5nUVVs/sH"up#[U5S:XaUOUSU4US4PM$ snn$s snnf)a557Produce a list of name/dtype pairs corresponding to the dtype fields58 59Similar to dtype.descr, but the second item of each tuple is a dtype, not a60string. As a result, this handles subarray dtypes61 62Can be passed to the dtype constructor to reconstruct the dtype, noting that63this (deliberately) discards field offsets.64 65Examples66--------67>>> import numpy as np68>>> dt = np.dtype([(('a', 'A'), np.int64), ('b', np.double, 3)])69>>> dt.descr70[(('a', 'A'), '<i8'), ('b', '<f8', (3,))]71>>> _get_fieldspec(dt)72[(('a', 'A'), dtype('int64')), ('b', dtype(('<f8', (3,))))]73 74�c3�D># �UHoTRU4v� M g7fr)�fields)�.0�namer#s  �r�	<genexpr>�!_get_fieldspec.<locals>.<genexpr>_s����E������d�+�,��s� �r)r$r&)r#r-r/�fs`   r�_get_fieldspecr4Gso���(
�{�{���U��}��E����E��"�75�!�����V�q�[�T�q��t�T�l�A�a�D�9�!�76�	77��78s�)Ac	���/nURnUHLnXnURb'URU[[U5545 M;URU5 MN [U5$)a79Returns the field names of the input datatype as a tuple. Input datatype80must have fields otherwise error is raised.81 82Parameters83----------84adtype : dtype85    Input datatype86 87Examples88--------89>>> import numpy as np90>>> from numpy.lib import recfunctions as rfn91>>> rfn.get_names(np.empty((1,), dtype=[('A', int)]).dtype)92('A',)93>>> rfn.get_names(np.empty((1,), dtype=[('A',int), ('B', float)]).dtype)94('A', 'B')95>>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])])96>>> rfn.get_names(adtype)97('a', ('b', ('ba', 'bb')))98)r$�append�tupler��adtype�	listnamesr$r/r)s     rrrgse��,�I��L�L�E����,���=�=�$����d�E�)�G�*<�$=�>�?����T�"�����r!c���/nURnUHAnURU5 XnURcM'UR[U55 MC [	U5$)aU99Returns the field names of the input datatype as a tuple. Input datatype100must have fields otherwise error is raised.101Nested structure are flattened beforehand.102 103Parameters104----------105adtype : dtype106    Input datatype107 108Examples109--------110>>> import numpy as np111>>> from numpy.lib import recfunctions as rfn112>>> rfn.get_names_flat(np.empty((1,), dtype=[('A', int)]).dtype) is None113False114>>> rfn.get_names_flat(np.empty((1,), dtype=[('A',int), ('B', str)]).dtype)115('A', 'B')116>>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])])117>>> rfn.get_names_flat(adtype)118('a', 'b', 'ba', 'bb')119)r$r6�extendr
r7r8s     rr
r
�s[��.�I��L�L�E���������,���=�=�$����^�G�4�5�	�120���r!c���URnUcSU44$/nUHOnURUupEURbUR[U55 M=UR	X445 MQ [U5$)a;121Flatten a structured data-type description.122 123Examples124--------125>>> import numpy as np126>>> from numpy.lib import recfunctions as rfn127>>> ndtype = np.dtype([('a', '<i4'), ('b', [('ba', '<f8'), ('bb', '<i4')])])128>>> rfn.flatten_descr(ndtype)129(('a', dtype('int32')), ('ba', dtype('float64')), ('bb', dtype('int32')))130 131r+)r$r-r<r132r6r7)�ndtyper$�descrr(�typ�_s      rr133r134�sr��
�L�L�E��}��V�������E��}�}�U�+�H�S��y�y�$����]�3�/�0����e�\�*���U�|�r!c�p�/nU(a.UH'nUR[UR55 M) OjUHdnURnURb5[	UR5S:XaUR[U55 MQUR
SU45 Mf [R"U5$)N�r+)r<r135r#r$r&r4r6�np)�	seqarrays�flattenr'�ar)s     r�136_zip_dtyperH�s����H���A��O�O�M�!�'�'�2�3���A��g�g�G��}�}�(�S����-?�1�-D�����w� 7�8�����W�
�.�
��8�8�H��r!c�(�[XS9R$)z�137Combine the dtype description of a series of arrays.138 139Parameters140----------141seqarrays : sequence of arrays142    Sequence of arrays143flatten : {boolean}, optional144    Whether to collapse nested descriptions.145�rF)rHr?)rErFs  r�146_zip_descrrK�s���i�1�7�7�7r!c�`�Uc0nURnUH�nXnURb.U(aU/X$'O/X$'UR[XTU55 MB[UR	U/5=(d /5nU(aURU5 O147U(aU/nU=(d /X$'M� U$)a)148Returns a dictionary with fields indexing lists of their parent fields.149 150This function is used to simplify access to fields nested in other fields.151 152Parameters153----------154adtype : np.dtype155    Input datatype156lastname : optional157    Last processed field name (used internally during recursion).158parents : dictionary159    Dictionary of parent fields (used internally during recursion).160 161Examples162--------163>>> import numpy as np164>>> from numpy.lib import recfunctions as rfn165>>> ndtype =  np.dtype([('A', int),166...                     ('B', [('BA', int),167...                            ('BB', [('BBA', int), ('BBB', int)])])])168>>> rfn.get_fieldstructure(ndtype)169... # XXX: possible regression, order of BBA and BBB is swapped170{'A': [], 'B': [], 'BA': ['B'], 'BB': ['B'], 'BBA': ['B', 'BB'], 'BBB': ['B', 'BB']}171 172)r$�updater�list�getr6)r9�lastname�parentsr$r/r)�173lastparents       rrr�s���6�����L�L�E����,���=�=�$��!)���
� "��
��N�N�-�g�W�E�F��g�k�k�(�B�7�=�2�>�J���!�!�(�+��&�\�174�&�,�"�G�M���Nr!c#�# �UHDn[U[R5(a[[	U55Shv�N M@Uv� MF gN7f)zi175Returns an iterator of concatenated fields from a sequence of arrays,176collapsing any nested structure.177 178N)�179isinstancerD�void�_izip_fields_flatr7��iterable�elements  rrVrVs<������g�r�w�w�'�'�(��w��8�8�8��M�	�8�s�<A�A�Ac#�<# �UH�n[US5(a*[U[5(d[U5Shv�N M>[U[R1805(a-[
[U55S:Xa[U5Shv�N M�Uv� M� gN[N7f)zH181Returns an iterator of concatenated fields from a sequence of arrays.182 183�__iter__NrC)�hasattrrT�str�_izip_fieldsrDrUr&r7rWs  rr^r^sw���184���G�Z�(�(��w��,�,�#�G�,�,�,�
�����
)�
)�c�%��.�.A�Q�.F�#�G�,�,�,��M��
-�
-�s"�:B�B�AB�B�	B�Bc#�# �U(a[nO[n[R"USU06Hn[	U"U55v� M g7f)a185Returns an iterator of concatenated items from a sequence of arrays.186 187Parameters188----------189seqarrays : sequence of arrays190    Sequence of arrays.191fill_value : {None, integer}192    Value used to pad shorter iterables.193flatten : {True, False},194    Whether to195�	fillvalueN)rVr^�	itertools�zip_longestr7)rE�196fill_valuerF�zipfunc�tups     r�
_izip_recordsrf/s>����#�����$�$�i�F�:�F���G�C�L�!�!�G�s�AAc��[U[R5(dSnU(a(U(aUR[R1975nU$[R"U5nU(aUR[R5nU$)zt198Private function: return a recarray, a ndarray, a MaskedArray199or a MaskedRecords depending on the input parameters200F)	rT�ma�MaskedArray�view�mrec�
MaskedRecords�filledrD�recarray)r�usemask�201asrecarrays   r�_fix_outputrqGse��202�f�b�n�n�-�-������[�[��!3�!3�4�F�203�M����6�"����[�[����-�F��Mr!c���URRnURURURpTnU=(d 0R5HupgXb;dMXuU'XsUXF'M U$)zd204Update the fill_value and masked data of `output`205from the default given in a dictionary defaults.206)r#r$�data�maskrc�items)r�defaultsr$rsrtrc�k�vs        r�
_fix_defaultsryXsf��207
�L�L���E� &���V�[�[�&�:K�:K��T��>�r�(�(�*����:��q�M� ��G�D�G��+��Mr!c��U$rr)rErcrFrorps     r�_merge_arrays_dispatcherr{fs���r!c208�l	�[U5S:Xa[R"US5n[U[R[R20945(a�URnURc[R"SU4/5nU(a[U4SS9U:XawUR5nU(a)U(a[RnO9[RnO(U(a[RnO[RnURXVS9$U4nO&UVs/sHn[R"U5PM nn[!SU55n[#U5n	[XS9n210/n/nU(Ga�[%X5GHiup�X�-211nU
R5R'5n[R("U
5R5nU(a�[R*"XR5n[U[R[R21245(an[UR5S:XaUR-5SnSnOD[R."UU
RSS	9n[R0"S213URS9nOSnSnUR3[4R6"UU/U-55 UR3[4R6"UW/U-55 GMl [![9X�S95n[R."[R:"UX�S9[=[9X�S95S
9nU(aUR[R5nU$[%X5H�up�X�-214nU
R5R'5nU(a�[R*"XR5n[U[R[R21545(aM[UR5S:XaUR-5SnO#[R."UU
RSS	9nOSnUR3[4R6"UU/U-55 M� [R:"[![9X�S95X�S9nU(aUR[R5nU$s snf)a�216Merge arrays field by field.217 218Parameters219----------220seqarrays : sequence of ndarrays221    Sequence of arrays222fill_value : {float}, optional223    Filling value used to pad missing data on the shorter arrays.224flatten : {False, True}, optional225    Whether to collapse nested fields.226usemask : {False, True}, optional227    Whether to return a masked array or not.228asrecarray : {False, True}, optional229    Whether to return a recarray (MaskedRecords) or not.230 231Examples232--------233>>> import numpy as np234>>> from numpy.lib import recfunctions as rfn235>>> rfn.merge_arrays((np.array([1, 2]), np.array([10., 20., 30.])))236array([( 1, 10.), ( 2, 20.), (-1, 30.)],237      dtype=[('f0', '<i8'), ('f1', '<f8')])238 239>>> rfn.merge_arrays((np.array([1, 2], dtype=np.int64),240...         np.array([10., 20., 30.])), usemask=False)241 array([(1, 10.0), (2, 20.0), (-1, 30.0)],242         dtype=[('f0', '<i8'), ('f1', '<f8')])243>>> rfn.merge_arrays((np.array([1, 2]).view([('a', np.int64)]),244...               np.array([10., 20., 30.])),245...              usemask=False, asrecarray=True)246rec.array([( 1, 10.), ( 2, 20.), (-1, 30.)],247          dtype=[('a', '<i8'), ('f1', '<f8')])248 249Notes250-----251* Without a mask, the missing value will be filled with something,252  depending on what its corresponding type:253 254  * ``-1``      for integers255  * ``-1.0``    for floating point numbers256  * ``'-'``     for characters257  * ``'-1'``    for strings258  * ``True``    for boolean values259* XXX: I just obtained these values empirically260rCrNr+TrJ)r#�typec3�8# �UHoRv� M g7fr)�size)r.rGs  rr0�merge_arrays.<locals>.<genexpr>�s���,�)�Q�&�&�)�s�)r#�ndmin)rC�r#)r#�count)rt)r&rD�261asanyarrayrT�ndarrayrUr#r$rH�ravelrkrlrhrirnrjr7�max�zip�	__array__�getmaskarray�_check_fill_value�item�array�onesr6ra�chainrf�fromiterrN)rErcrFrorp�seqdtype�seqtype�_m�sizes�	maxlengthr'�seqdata�seqmaskrG�n�	nbmissingrsrt�fval�fmskrs                     rrrksr��d	�I��!���M�M�)�A�,�/�	��)�b�j�j�"�'�'�2�3�3��?�?���>�>�!��x�x�"�h�� 0�1�H��*�i�\�4�@�H�L�!���)�I���"�0�0�G� �n�n�G���+�+���*�*���>�>��>�?�?�"��I�2;�;��2�R�]�]�2�&��	�;��,�)�,�,�E��E�262�I��)�5�H��G��G���)�+�F�Q�"��I��7�7�9�&�&�(�D��?�?�1�%�+�+�-�D���-�-�j�'�'�B���d�R�Z�Z����$9�:�:��4�:�:��!�+�#�y�y�{�1�~��#��!�x�x��A�G�G�1�E��!�w�w�t�4�:�:�>��������N�N�9�?�?�4�$��)�1C�D�E��N�N�9�?�?�4�$��)�1C�D�E�),�,�]�7�<�=�����"�+�+�d�(�L�#�M�'�$K�L�N����[�[��!3�!3�4�F�*�M�%�)�+�F�Q�"��I��7�7�9�&�&�(�D���-�-�j�'�'�B���d�R�Z�Z����$9�:�:��4�:�:��!�+�#�y�y�{�1�~��!�x�x��A�G�G�1�E������N�N�9�?�?�4�$��)�1C�D�E�,����U�=��#J�K�#+�>����[�[����-�F��M��u<s� R1c��U4$rr)�base�263drop_namesrorps    r�_drop_fields_dispatcherr���	���7�Nr!c��^�[U5(aU/nO[U5nU4SjmT"URU5n[R"UR264US9n[
X5n[XRUS9$)a265Return a new array with fields in `drop_names` dropped.266 267Nested fields are supported.268 269Parameters270----------271base : array272    Input array273drop_names : string or sequence274    String or sequence of strings corresponding to the names of the275    fields to drop.276usemask : {False, True}, optional277    Whether to return a masked array or not.278asrecarray : string or sequence, optional279    Whether to return a recarray or a mrecarray (`asrecarray=True`) or280    a plain ndarray or masked array with flexible dtype. The default281    is False.282 283Examples284--------285>>> import numpy as np286>>> from numpy.lib import recfunctions as rfn287>>> a = np.array([(1, (2, 3.0)), (4, (5, 6.0))],288...   dtype=[('a', np.int64), ('b', [('ba', np.double), ('bb', np.int64)])])289>>> rfn.drop_fields(a, 'a')290array([((2., 3),), ((5., 6),)],291      dtype=[('b', [('ba', '<f8'), ('bb', '<i8')])])292>>> rfn.drop_fields(a, 'ba')293array([(1, (3,)), (4, (6,))], dtype=[('a', '<i8'), ('b', [('bb', '<i8')])])294>>> rfn.drop_fields(a, ['ba', 'bb'])295array([(1,), (4,)], dtype=[('a', '<i8')])296c��>�URn/nUHRnXnXA;aMURb%T"XQ5nU(aURXF45 M>M@URXE45 MT U$r)r$r6)r>r�r$r'r/r)r?�_drop_descrs       �rr�� drop_fields.<locals>._drop_descr sl����������D��l�G��!���}�}�(�#�G�8����O�O�T�M�2�������0���r!r��rorp)r�setr#rD�empty�shaperrq)r�r�rorpr'rr�s      @rrr�sc���F�z�"�"� �\�297���_�298�
��4�:�:�z�2�H�
�X�X�d�j�j��
1�F�
"�4�
0�F��v�:�F�Fr!c��UVs/sHoDURU4PM nn[R"URUS9n[	X5n[XbUS9$s snf)aL299Return a new array keeping only the fields in `keep_names`,300and preserving the order of those fields.301 302Parameters303----------304base : array305    Input array306keep_names : string or sequence307    String or sequence of strings corresponding to the names of the308    fields to keep. Order of the names will be preserved.309usemask : {False, True}, optional310    Whether to return a masked array or not.311asrecarray : string or sequence, optional312    Whether to return a recarray or a mrecarray (`asrecarray=True`) or313    a plain ndarray or masked array with flexible dtype. The default314    is False.315r�r�)r#rDr�r�rrq)r��316keep_namesrorpr�r'rs       r�_keep_fieldsr�6sS��&-7�7�J�q�D�J�J�q�M�"�J�H�7�
�X�X�d�j�j��
1�F�
"�4�
0�F��v�:�F�F��8s�Ac��U4$rr�r�r�s  r�_rec_drop_fields_dispatcherr�Or�r!c��[XSSS9$)zC317Returns a new numpy.recarray with fields in `drop_names` dropped.318FTr�)rr�s  rrrSs��319�t��4�H�Hr!c��U4$rr)r��320namemappers  r�_rename_fields_dispatcherr�[r�r!c�X^�U4SjmT"URU5nURU5$)a�321Rename the fields from a flexible-datatype ndarray or recarray.322 323Nested fields are supported.324 325Parameters326----------327base : ndarray328    Input array whose fields must be modified.329namemapper : dictionary330    Dictionary mapping old field names to their new version.331 332Examples333--------334>>> import numpy as np335>>> from numpy.lib import recfunctions as rfn336>>> a = np.array([(1, (2, [3.0, 30.])), (4, (5, [6.0, 60.]))],337...   dtype=[('a', int),('b', [('ba', float), ('bb', (float, 2))])])338>>> rfn.rename_fields(a, {'a':'A', 'bb':'BB'})339array([(1, (2., [ 3., 30.])), (4, (5., [ 6., 60.]))],340      dtype=[('A', '<i8'), ('b', [('ba', '<f8'), ('BB', '<f8', (2,))])])341 342c��>�/nURHRnURX35nXnURbURUT"XQ545 M@URXE45 MT U$r)r$rOr6)r>r�r'r/�newnamer)�_recursive_rename_fieldss      �rr��/rename_fields.<locals>._recursive_rename_fieldsxsg������L�L�D� �n�n�T�0�G��l�G��}�}�(�����6�w�K�L������ 2�3�!��r!)r#rj)r�r�r'r�s   @rrr_s)���2�(��343�344�J�?�H��9�9�X��r!c#�,# �Uv� UShv�N gN7frr)r�r$rs�dtypesrcrorps       r�_append_fields_dispatcherr��s���345�J��O�O���346��c�Z�[U[[45(a&[U5[U5:wa
Sn[	U5eO[U[3475(aU/nU/nUcaUVs/sHn[R"USSS9PM nn[X5V	Vs/sH"up�URX�R4/5PM$ nn	nO�[U[[45(dU/n[U5[U5:wa+[U5S:XaU[U5-nO
Sn[	U5e[X!U5VV348Vs/sH.up�n[R"USSUS9RX�4/5PM0 nn349nn[XUS9n[U5S:�a
[USUUS	9nOUR5n[R"[[U5[U55[!UR5[!UR5-S3509n[#X5n[#X,5n[%X�US9$s snfs snn	fs snn351nf)a�352Add new fields to an existing array.353 354The names of the fields are given with the `names` arguments,355the corresponding values with the `data` arguments.356If a single field is appended, `names`, `data` and `dtypes` do not have357to be lists but just values.358 359Parameters360----------361base : array362    Input array to extend.363names : string, sequence364    String or sequence of strings corresponding to the names365    of the new fields.366data : array or sequence of arrays367    Array or sequence of arrays storing the fields to add to the base.368dtypes : sequence of datatypes, optional369    Datatype or sequence of datatypes.370    If None, the datatypes are estimated from the `data`.371fill_value : {float}, optional372    Filling value used to pad missing data on the shorter arrays.373usemask : {False, True}, optional374    Whether to return a masked array or not.375asrecarray : {False, True}, optional376    Whether to return a recarray (MaskedRecords) or not.377 378z7The number of arrays does not match the number of namesNT)�copy�subokrCz5The dtypes argument must be None, a dtype, or a list.)r�r�r#)rorc)rFrorcr�r�)rTr7rNr&r%r]rDr�r�rjr#r�poprh�379masked_allr�r4rrq)
r�r$rsr�rcrorp�msgrGr/r��drs
             rrr�s���@�%�%���'�'��u�:��T��"�K�C��S�/�!�#�380�E�3�	�	��	���x��
�~�<@�A�D�q������T�2�D��A�;>�u�;K�L�;K�i�t�����w�w��(�)�;K��L���&�5�$�-�0�0��Z�F��t�9��F��#��6�{�a���#�d�)�+��M�� ��o�%�!$�T�&�!9�;�!9�I�Q�1������T��;�@�@�1�&��J�!9�	
�;���*�E�D�381�4�y�1�}��D�$��'1�3���x�x�z��
�]�]��C��I�s�4�y�!��T�Z�Z�(�>�$�*�*�+E�E�G�F�#�4�
0�F�
"�4�
0�F��v�:�F�F��7B��L��;s�$ H�)H �25H&c#�,# �Uv� UShv�N gN7frr�r�r$rsr�s    r�_rec_append_fields_dispatcherr��s���382�J��O�O�r�c	��[XX#SSS9$)a�383Add new fields to an existing array.384 385The names of the fields are given with the `names` arguments,386the corresponding values with the `data` arguments.387If a single field is appended, `names`, `data` and `dtypes` do not have388to be lists but just values.389 390Parameters391----------392base : array393    Input array to extend.394names : string, sequence395    String or sequence of strings corresponding to the names396    of the new fields.397data : array or sequence of arrays398    Array or sequence of arrays storing the fields to add to the base.399dtypes : sequence of datatypes, optional400    Datatype or sequence of datatypes.401    If None, the datatypes are estimated from the `data`.402 403See Also404--------405append_fields406 407Returns408-------409appended_array : np.recarray410TF)rsr�rpro)rr�s    rrr�s��>��4�$(�%�9�9r!c��U4$rr)rG�align�recurses   r�_repack_fields_dispatcherr��s	��
�4�Kr!c���[U[R5(d$[URXS9nUR	USS9$UR411cU$/nUR412HUnURUnU(a[USUSS9nOUSn[U5S:XaUSU4nURXW45 MW [R"XAS9n[R"URU45$)	ac413Re-pack the fields of a structured array or dtype in memory.414 415The memory layout of structured datatypes allows fields at arbitrary416byte offsets. This means the fields can be separated by padding bytes,417their offsets can be non-monotonically increasing, and they can overlap.418 419This method removes any overlaps and reorders the fields in memory so they420have increasing byte offsets, and adds or removes padding bytes depending421on the `align` option, which behaves like the `align` option to422`numpy.dtype`.423 424If `align=False`, this method produces a "packed" memory layout in which425each field starts at the byte the previous field ended, and any padding426bytes are removed.427 428If `align=True`, this methods produces an "aligned" memory layout in which429each field's offset is a multiple of its alignment, and the total itemsize430is a multiple of the largest alignment, by adding padding bytes as needed.431 432Parameters433----------434a : ndarray or dtype435   array or dtype for which to repack the fields.436align : boolean437   If true, use an "aligned" memory layout, otherwise use a "packed" layout.438recurse : boolean439   If True, also repack nested structures.440 441Returns442-------443repacked : ndarray or dtype444   Copy of `a` with fields repacked, or `a` itself if no repacking was445   needed.446 447Examples448--------449>>> import numpy as np450 451>>> from numpy.lib import recfunctions as rfn452>>> def print_offsets(d):453...     print("offsets:", [d.fields[name][1] for name in d.names])454...     print("itemsize:", d.itemsize)455...456>>> dt = np.dtype('u1, <i8, <f8', align=True)457>>> dt458dtype({'names': ['f0', 'f1', 'f2'], 'formats': ['u1', '<i8', '<f8'], 'offsets': [0, 8, 16], 'itemsize': 24}, align=True)459>>> print_offsets(dt)460offsets: [0, 8, 16]461itemsize: 24462>>> packed_dt = rfn.repack_fields(dt)463>>> packed_dt464dtype([('f0', 'u1'), ('f1', '<i8'), ('f2', '<f8')])465>>> print_offsets(packed_dt)466offsets: [0, 1, 9]467itemsize: 17468 469)r�r�F)r�rT�r2�r�)470rTrDr#r�astyper$r-r&r6r})rGr�r��dt�	fieldinfor/re�fmts        rrrs���z�a����"�"�
�1�7�7�%�
A���x�x���x�'�'��w�w�����I������h�h�t�n�����A��e�T�B�C��a�&�C��s�8�q�=���F�D�>�D����$��%��471���)�	)�B�
�8�8�Q�V�V�R�L�!�!r!c���Sn/nURH�nURUnUSUSpvU"U5uphURc.UR[R"Xh445X�U-45 M`[XgU-5n	URn472[U5HKnUS:XaURU	5 MURU	VV
Vs/sHup�o�X�X�--4PM snn
n5 MM M� U$s snn
nf)z�473Returns a flat list of (dtype, count, offset) tuples of all the474scalar fields in the dtype "dt", including nested fields, in left475to right order.476c��SnURS:wa5URHnX-nM	 URnURS:waM5X4$)NrCr)r�r�)r�r�rs   r�477count_elem�+_get_fields_and_offsets.<locals>.count_elem^sG�����h�h�"�n������
��!����B��h�h�"�n��y�r!rrC)	r$r-r6rDr#�_get_fields_and_offsets�itemsize�ranger<)r��offsetr�r-r/r(�f_dt�f_offsetr��	subfieldsr�ir��c�os               rr�r�Us�����F������	�	�$����q��5��8�h��T�"����:�:���M�M�2�8�8�T�4�L�1�1��6G�H�I�/���6G�H�I��=�=�D��1�X����6��M�M�)�,��M�M�y�"Q�y�G�A�!�q�a�h�,�#7�y�"Q�R���"�M��#Rs�C,c�L�[U5S::aU$USUS:nU(a[[U5[U55nO[X5nSnSnUHBupxUS:wa U(a gUcUnXb:wa gXxS-478U--n	OUn	UbXu-479n480UcU481nXj:wa gU	nMD U(aU*$U$)z�482Returns the stride between the fields, or None if the stride is not483constant. The values in "counts" designate the lengths of484subarrays. Subarrays are treated as many contiguous fields, with485always positive stride.486rCrN)r&r��reversed)�offsets�countsr��negative�it�prev_offset�strider�r��487end_offset�488new_strides           r�_common_strider�zs����7�|�q�����q�z�G�A�J�&�H��
��'�"�H�V�$4�
5��
��
!���K�
�F��
���A�:����~�!���!���1�9��"8�8�J��J��"��-�J��~�#���#�� ��'�*��w���Mr!c��U4$rr)�arrr#r��castings    r�&_structured_to_unstructured_dispatcherr���	���6�Mr!c�$^�URRc[S5e[UR5n[	U5nUS:XaUc[S5eUS:Xa[S5e[
U6upgn[U5V	s/sHn	SU	3PM489 n490n	Uc.[R"UVs/sHo�RPM sn6mO[R"U5m[R"U491UUURRS.5nURU5n[U5[R[R[R 4;n
U(GdDU
(Ga<[#U4SjU55(Ga![%X�TR5nUGbUR&nUR([+U5TR4-nUR,[/U5S	4-nUS492[R04R[R25nUS493[5U5S24n[R6R8R;UUUSS9nURT5S
nUS:a494US495SSS24n[U5[UR<5LaU"U5nU$[R"U496UVs/sHnTUR(4PM snS.5nUR?UX#S9nURT[+U5445$s sn	fs snfs snf)a�497Converts an n-D structured array into an (n+1)-D unstructured array.498 499The new array will have a new last dimension equal in size to the500number of field-elements of the input array. If not supplied, the output501datatype is determined from the numpy type promotion rules applied to all502the field datatypes.503 504Nested fields, as well as each element of any subarray fields, all count505as a single field-elements.506 507Parameters508----------509arr : ndarray510   Structured array or dtype to convert. Cannot contain object datatype.511dtype : dtype, optional512   The dtype of the output unstructured array.513copy : bool, optional514    If true, always return a copy. If false, a view is returned if515    possible, such as when the `dtype` and strides of the fields are516    suitable and the array subtype is one of `numpy.ndarray`,517    `numpy.recarray` or `numpy.memmap`.518 519    .. versionchanged:: 1.25.0520        A view can now be returned if the fields are separated by a521        uniform stride.522 523casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional524    See casting argument of `numpy.ndarray.astype`. Controls what kind of525    data casting may occur.526 527Returns528-------529unstructured : ndarray530   Unstructured array with one more dimension.531 532Examples533--------534>>> import numpy as np535 536>>> from numpy.lib import recfunctions as rfn537>>> a = np.zeros(4, dtype=[('a', 'i4'), ('b', 'f4,u2'), ('c', 'f4', 2)])538>>> a539array([(0, (0., 0), [0., 0.]), (0, (0., 0), [0., 0.]),540       (0, (0., 0), [0., 0.]), (0, (0., 0), [0., 0.])],541      dtype=[('a', '<i4'), ('b', [('f0', '<f4'), ('f1', '<u2')]), ('c', '<f4', (2,))])542>>> rfn.structured_to_unstructured(a)543array([[0., 0., 0., 0., 0.],544       [0., 0., 0., 0., 0.],545       [0., 0., 0., 0., 0.],546       [0., 0., 0., 0., 0.]])547 548>>> b = np.array([(1, 2, 5), (4, 5, 7), (7, 8 ,11), (10, 11, 12)],549...              dtype=[('x', 'i4'), ('y', 'f4'), ('z', 'f8')])550>>> np.mean(rfn.structured_to_unstructured(b[['x', 'z']]), axis=-1)551array([ 3. ,  5.5,  9. , 11. ])552 553N�arr must be a structured arrayrz(arr has no fields. Unable to guess dtypez#arr with no fields is not supportedr3�r$�formatsr�r�c3�@># �UHoRT:Hv� M g7fr)r�)r.r��	out_dtypes  �rr0�-structured_to_unstructured.<locals>.<genexpr>s����&J�c��w�w�)�';�c�s�rC.T)r��.r������r$r��r�r�) r#r$r%r�r&�NotImplementedErrorr�r�rD�result_typer�r�rjr}r�rn�memmap�allr��__array_wrap__r��sum�strides�abs�newaxis�uint8�min�lib�
stride_tricks�554as_strided�__self__r�)r�r#r�r�r-�n_fields�dtsr�r�r�r$r��flattened_fields�can_view�
common_stride�wrap�	new_shape�new_strides�
packed_fieldsr�s                   @rrr�s����x�y�y�����9�:�:�
$�S�Y�Y�
/�F��6�{�H��1�}����C�D�D�	�Q��!�"G�H�H���<��C��#�H�o�.�o��q���W�o�E�.��}��N�N�s�$;�s��W�W�s�$;�<�	��H�H�U�O�	��x�x�%�,/�,3�-0�Y�Y�-?�-?�!A�B���(�(�#�555$�C�556�C�y�R�Z�Z����b�i�i�@�@�H��h�3�&J�c�&J�#J�#J�'�w�	�8J�8J�K�
��$��%�%�D��	�	�S��[�)�2D�2D�$E�E�I��+�+��]�);�Q�(?�?�K��c�2�:�:�o�&�+�+�B�H�H�5�C��c�3�w�<�=�(�)�C��&�&�&�&�1�1�#�2;�2=�8<�2�>�C��(�(�9�%�f�-�C��q� ��#�t��t�)�n���C�y��T�]�]� 3�3��3�i���J��H�H�u�JM�)N�#�B�9�b�h�h�*?�#�)N�P�Q�M�557
�*�*�]��*�558?�C��8�8�Y��V���/�0�0��q
/��%<��b*Os�L�)L�5L
559c��U4$rr)r�r#r$r�r�r�s      r�&_unstructured_to_structured_dispatcherr.r�r!c�<�URS:Xa[S5eURSnUS:Xa[S5eUciUc[U5Vs/sHnSU3PM560 nn[R561"UVs/sHowUR5624PM snUS9n[
U5n	[U	6up�nO�Ub[S5e[R563"U5n[
U5n	[U	5S:Xa///p�n564O[U	6up�nU[U5:wa[S	5eUnU(aUR(d[S5655e[[U	55Vs/sHnSU3PM566 nn[R567"UU568V
s/sHo�R569U
R4PM sn
S.5n[R"U5RU5n[R570"UU571UURS.5nURX�US
9nURU5S$s snfs snfs snfs sn
f)ar572Converts an n-D unstructured array into an (n-1)-D structured array.573 574The last dimension of the input array is converted into a structure, with575number of field-elements equal to the size of the last dimension of the576input array. By default all output fields have the input array's dtype, but577an output structured dtype with an equal number of fields-elements can be578supplied instead.579 580Nested fields, as well as each element of any subarray fields, all count581towards the number of field-elements.582 583Parameters584----------585arr : ndarray586   Unstructured array or dtype to convert.587dtype : dtype, optional588   The structured dtype of the output array589names : list of strings, optional590   If dtype is not supplied, this specifies the field names for the output591   dtype, in order. The field dtypes will be the same as the input array.592align : boolean, optional593   Whether to create an aligned memory layout.594copy : bool, optional595    See copy argument to `numpy.ndarray.astype`. If true, always return a596    copy. If false, and `dtype` requirements are satisfied, a view is597    returned.598casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional599    See casting argument of `numpy.ndarray.astype`. Controls what kind of600    data casting may occur.601 602Returns603-------604structured : ndarray605   Structured array with fewer dimensions.606 607Examples608--------609>>> import numpy as np610 611>>> from numpy.lib import recfunctions as rfn612>>> dt = np.dtype([('a', 'i4'), ('b', 'f4,u2'), ('c', 'f4', 2)])613>>> a = np.arange(20).reshape((4,5))614>>> a615array([[ 0,  1,  2,  3,  4],616       [ 5,  6,  7,  8,  9],617       [10, 11, 12, 13, 14],618       [15, 16, 17, 18, 19]])619>>> rfn.unstructured_to_structured(a, dt)620array([( 0, ( 1.,  2), [ 3.,  4.]), ( 5, ( 6.,  7), [ 8.,  9.]),621       (10, (11., 12), [13., 14.]), (15, (16., 17), [18., 19.])],622      dtype=[('a', '<i4'), ('b', [('f0', '<f4'), ('f1', '<u2')]), ('c', '<f4', (2,))])623 624rz$arr must have at least one dimensionr�rz&last axis with size 0 is not supportedr3r�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 alignedr�r�r�r�)r�r%r�r�rDr#r�r�r&r�isalignedstruct�ascontiguousarrayrjr�r�)r�r#r$r�r�r��n_elemr�r�r-rr�r�r�rrs                rrr2s��r�y�y�B���?�@�@�
�Y�Y�r�]�F�
��{�!�"J�K�K��}��=�&+�F�m�4�m��q���W�m�E�4��H�H�e�<�e��#�)�)�n�e�<�E�J�	�(��3��"�F�|���W����@�A�A�������(��/���v�;�!��#%�r�2��C��#&��<� �C���S��[� ��I�J�
J��	���2�2��F�G�G�#�C��K�0�1�0��q���W�0�E�1�625�H�H�u�JM�)N�#�B�9�9�b�h�h�*?�#�)N�P�Q�M�626�627�628�s�629#�630(�631(��6327�C��x�x�%�,/�,3�-6�-?�-?�!A�B���*�*�%�'�*�633B�C��8�8�I��v�&�&��Q5��<��,
2��*Os�H634�4H�H�2!H635c��U4$rr)�funcr�s  r�_apply_along_fields_dispatcherr�s	���6�Mr!c�j�URRc[S5e[U5nU"USS9$)a636Apply function 'func' as a reduction across fields of a structured array.637 638This is similar to `numpy.apply_along_axis`, but treats the fields of a639structured array as an extra axis. The fields are all first cast to a640common type following the type-promotion rules from `numpy.result_type`641applied to the field's dtypes.642 643Parameters644----------645func : function646   Function to apply on the "field" dimension. This function must647   support an `axis` argument, like `numpy.mean`, `numpy.sum`, etc.648arr : ndarray649   Structured array for which to apply func.650 651Returns652-------653out : ndarray654   Result of the reduction operation655 656Examples657--------658>>> import numpy as np659 660>>> from numpy.lib import recfunctions as rfn661>>> b = np.array([(1, 2, 5), (4, 5, 7), (7, 8 ,11), (10, 11, 12)],662...              dtype=[('x', 'i4'), ('y', 'f4'), ('z', 'f8')])663>>> rfn.apply_along_fields(np.mean, b)664array([ 2.66666667,  5.33333333,  8.66666667, 11.        ])665>>> rfn.apply_along_fields(np.mean, b[['x', 'z']])666array([ 3. ,  5.5,  9. , 11. ])667 668r�r�)�axis)r#r$r%r)rr��uarrs   rrr�s6��H�y�y�����9�:�:�%�c�*�D���2��r!c��X4$rr)�dst�src�zero_unassigneds   r�!_assign_fields_by_name_dispatcherr#�s	���8�Or!c���URRcXS'gURRH<nX1RR;aU(aSX'M)M+[XXU5 M> g)az669Assigns values from one structured array to another by field name.670 671Normally in numpy >= 1.14, assignment of one structured array to another672copies fields "by position", meaning that the first field from the src is673copied to the first field of the dst, and so on, regardless of field name.674 675This function instead copies "by field name", such that fields in the dst676are assigned from the identically named field in the src. This applies677recursively for nested structures. This is how structure assignment worked678in numpy >= 1.6 to <= 1.13.679 680Parameters681----------682dst : ndarray683src : ndarray684    The source and destination arrays during assignment.685zero_unassigned : bool, optional686    If True, fields in the dst for which there was no matching687    field in the src are filled with the value 0 (zero). This688    was the behavior of numpy <= 1.13. If False, those fields689    are not modified.690N.r)r#r$r)r r!r"r/s    rrr�s`��4�y�y�����C����	�	�����y�y���&����	��
"�#�)�S�Y�"1�
3� r!c��U4$rr)r��required_dtypes  r�_require_fields_dispatcherr'�s	���8�Or!c�Z�[R"URUS9n[X 5 U$)a�691Casts a structured array to a new dtype using assignment by field-name.692 693This function assigns from the old to the new array by name, so the694value of a field in the output array is the value of the field with the695same name in the source array. This has the effect of creating a new696ndarray containing only the fields "required" by the required_dtype.697 698If a field name in the required_dtype does not exist in the699input array, that field is created and set to 0 in the output array.700 701Parameters702----------703a : ndarray704   array to cast705required_dtype : dtype706   datatype for output array707 708Returns709-------710out : ndarray711    array with the new dtype, with field values copied from the fields in712    the input array with the same name713 714Examples715--------716>>> import numpy as np717 718>>> from numpy.lib import recfunctions as rfn719>>> a = np.ones(4, dtype=[('a', 'i4'), ('b', 'f8'), ('c', 'u1')])720>>> rfn.require_fields(a, [('b', 'f4'), ('c', 'u1')])721array([(1., 1), (1., 1), (1., 1), (1., 1)],722  dtype=[('b', '<f4'), ('c', 'u1')])723>>> rfn.require_fields(a, [('b', 'f4'), ('newf', 'u1')])724array([(1., 0), (1., 0), (1., 0), (1., 0)],725  dtype=[('b', '<f4'), ('newf', 'u1')])726 727r�)rDr�r�r)r�r&�outs   rrr�s&��P
�(�(�5�;�;�n�7285�C��#�%��Jr!c��U$rr)�arraysrvrorp�autoconverts     r�_stack_arrays_dispatcherr-&s���Mr!c	�<�[U[R5(aU$[U5S:XaUS$UVs/sH'n[R"U5R5PM) nnUVs/sHn[U5PM nnUVs/sHoURPM nnUV	s/sHo�RPM n729n	USn[U5nUV
V	s/sHup�U
PM	 nn
n	USSH�n[U5H}unnUU;a&URUU45 URU5 M2URU5nUUunnU(aU[UU54UU'MeUU:wdMm[SUSUS35e M� [U5S:Xa[R"U5nO�[R"[R "U54U5n[R""[R$SU45n/n['XjUSSUSS5Hcup]nnURRnUcUUS[U53UU&M6U
H'nUUUUUU&UU;dMURU5 M) Me [)[+UU5X#S	9$s snfs snfs snfs sn	fs sn	n
f)730a�731Superposes arrays fields by fields732 733Parameters734----------735arrays : array or sequence736    Sequence of input arrays.737defaults : dictionary, optional738    Dictionary mapping field names to the corresponding default values.739usemask : {True, False}, optional740    Whether to return a MaskedArray (or MaskedRecords is741    `asrecarray==True`) or a ndarray.742asrecarray : {False, True}, optional743    Whether to return a recarray (or MaskedRecords if `usemask==True`)744    or just a flexible-type ndarray.745autoconvert : {False, True}, optional746    Whether automatically cast the type of the field to the maximum.747 748Examples749--------750>>> import numpy as np751>>> from numpy.lib import recfunctions as rfn752>>> x = np.array([1, 2,])753>>> rfn.stack_arrays(x) is x754True755>>> z = np.array([('A', 1), ('B', 2)], dtype=[('A', '|S3'), ('B', float)])756>>> zz = np.array([('a', 10., 100.), ('b', 20., 200.), ('c', 30., 300.)],757...   dtype=[('A', '|S3'), ('B', np.double), ('C', np.double)])758>>> test = rfn.stack_arrays((z,zz))759>>> test760masked_array(data=[(b'A', 1.0, --), (b'B', 2.0, --), (b'a', 10.0, 100.0),761                   (b'b', 20.0, 200.0), (b'c', 30.0, 300.0)],762             mask=[(False, False,  True), (False, False,  True),763                   (False, False, False), (False, False, False),764                   (False, False, False)],765       fill_value=(b'N/A', 1e+20, 1e+20),766            dtype=[('A', 'S3'), ('B', '<f8'), ('C', '<f8')])767 768rCrNzIncompatible type 'z' <> '�'r�r3r�)rTrDr�r&r�r�r#r$r4r6�indexr��	TypeErrorrh�concatenater�r�cumsum�r_r�rqry)r+rvrorpr,rGrE�nrecordsr>r��fldnames�dtype_l�newdescrr�r$�dtype_n�fname�fdtype�nameidxrA�cdtyperr��seenr��jr/s                           rrr+sq��T�&�"�*�*�%�%��
�	�V���	��a�y��39�:�6�a����q�!�'�'�)�6�I�:� )�*�	�1��A��	�H�*�(�
)�y�!�g�g�y�F�
)�!'�(��A����H�(��Q�i�G��g�&�H�#�$�8�4�1�Q�8�E�$��!�"�:��+�G�4�M�E�6��E�!�������0����U�#��+�+�e�,��$�W�-�	��6��).��F�F�0C�(D�H�W�%��v�%�#�&9�&����x�q�$Q�R�R�5���8�}������	�*��������x� 0�2�H�=�����2�5�5��H��-�.�����	�V�C�R�[�&���*�M�L�Q�1�a��G�G�M�M�E��}�/0���3�t�9�+��'��!�,��D�()�$��F�4�L��1�%��4�'����D�)��N��}�V�X�6�&�?�?��M;��*��
)��(��
%s�.J�.J	�	J�$J�Jc��U4$rr)rG�key�769ignoremask�return_indexs    r�_find_duplicates_dispatcherrD�s	��
�4�Kr!c��[R"U5R5n[UR5nUnU(aXAHnXVnM	 XQnUR5nXWnUR
5n	U	SSU	SS:Hn770U(aURnSX�SS'[R"S/U77145n772U773SSU774SS-U775SS&XU776nU(aX�U7774$U$)a�778Find the duplicates in a structured array along a given key779 780Parameters781----------782a : array-like783    Input array784key : {string, None}, optional785    Name of the fields along which to check the duplicates.786    If None, the search is performed by records787ignoremask : {True, False}, optional788    Whether masked data should be discarded or considered as duplicates.789return_index : {False, True}, optional790    Whether to return the indices of the duplicated values.791 792Examples793--------794>>> import numpy as np795>>> from numpy.lib import recfunctions as rfn796>>> ndtype = [('a', int)]797>>> a = np.ma.array([1, 1, 1, 2, 2, 3, 3],798...         mask=[0, 0, 1, 0, 0, 0, 1]).view(ndtype)799>>> rfn.find_duplicates(a, ignoremask=True, return_index=True)800(masked_array(data=[(1,), (1,), (2,), (2,)],801             mask=[(False,), (False,), (False,), (False,)],802       fill_value=(999999,),803            dtype=[('a', '<i8')]), array([0, 1, 3, 4]))804Nr�rCF)	rDr�r�rr#�argsortrm�805recordmaskr2)
rGrArBrCr-r�r3�sortidx�806sortedbase�807sorteddata�flag�808sortedmask�809duplicatess
             rr	r	�s���<	�
�
�a���� �A�
����
(�F��D�810���A��7�D���y���l�l�n�G���J��"�"�$�J��s��O�z�!�"�~�-�D���*�*�811�$����^��
�>�>�E�7�D�/�*�D��S�b�	�D���H�$�D��"�I���D�!�J���D�M�*�*��r!c	��X4$rr)	rA�r1�r2�jointype�	r1postfix�	r2postfixrvrorps	         r�_join_by_dispatcherrT����
�8�Or!c	�812^�US;a[SU-5e[T[5(aT4m[[	T55[T5:wa-[U4Sj[
T555n	[SU	<35eTHSn813X�RR;a[SU814<35eX�RR;dMF[SU815<35e UR5nUR5n[U5[U5p�URRURRp�[	U
5[	U5-[	T5-816nU(a U(dU(dSnUS-
n[U5eU
Vs/sH
nUT;dMUPM nn[UU5n[UU5n[R"UU45nURTS	9nUUn[R"S817/USSUSS
:H45nUSSUSS
-USS
&UUnUUU:nUUU:�U-818n[U5[U5nnUS:XaSunnO�US:XabUU)n[R"UUUU:45n[R"UUUU:�U-81945n[U5U-820[U5U-821nnO:US:Xa4UU)n[R"UUUU:45n[U5U-822SnnUUUUn!n [UR5n"[UR5H!un#n$U#T;dMU"R!U#U$45 M# [UR5Hdun#n$U"V823V%s/sHun824n%U825PM826 n&n827n%U&R#U#5n'U"U'un(n)U#T;aU#[%U$U)54U"U''MPU#U-U)4U#U-U$4/U"U'U'S-&Mf [R"U"5n"[%UU5n*[R&"U*W-W-4U"S9n+U+RRn&U
HFn,U U,n-U,U&;dU,U;aU(dU,T;aU,U-
n,U+U,n.U-SUU.SU&US;dM;U-USU.U*U*U-&MH UHMn,U!U,n-U,U&;dU,U
;aU(dU,T;aU,U-
n,U+U,n.U-SUU.SU&US:XdM;U(dMDU-USU.U*S&MO U+R)TS	9 XxS.n/[+[-U+U540U/D6$s snfs sn%n828f![a U"R!U#U$45 GM�f=f)a�829Join arrays `r1` and `r2` on key `key`.830 831The key should be either a string or a sequence of string corresponding832to the fields used to join the array.  An exception is raised if the833`key` field cannot be found in the two input arrays.  Neither `r1` nor834`r2` should have any duplicates along `key`: the presence of duplicates835will make the output quite unreliable. Note that duplicates are not836looked for by the algorithm.837 838Parameters839----------840key : {string, sequence}841    A string or a sequence of strings corresponding to the fields used842    for comparison.843r1, r2 : arrays844    Structured arrays.845jointype : {'inner', 'outer', 'leftouter'}, optional846    If 'inner', returns the elements common to both r1 and r2.847    If 'outer', returns the common elements as well as the elements of848    r1 not in r2 and the elements of not in r2.849    If 'leftouter', returns the common elements and the elements of r1850    not in r2.851r1postfix : string, optional852    String appended to the names of the fields of r1 that are present853    in r2 but absent of the key.854r2postfix : string, optional855    String appended to the names of the fields of r2 that are present856    in r1 but absent of the key.857defaults : {dictionary}, optional858    Dictionary mapping field names to the corresponding default values.859usemask : {True, False}, optional860    Whether to return a MaskedArray (or MaskedRecords is861    `asrecarray==True`) or a ndarray.862asrecarray : {False, True}, optional863    Whether to return a recarray (or MaskedRecords if `usemask==True`)864    or just a flexible-type ndarray.865 866Notes867-----868* The output is sorted along the key.869* A temporary array is formed by dropping the fields not in the key for870  the two arrays and concatenating the result. This array is then871  sorted, and the common entries selected. The output is constructed by872  filling the fields with the selected entries. Matching is not873  preserved if there are some duplicates...874 875)�inner�outer�	leftouterzWThe 'jointype' argument should be in 'inner', 'outer' or 'leftouter' (got '%s' instead)c3�H># �UHupUTUS-S;dMUv� M g7f)rCNr)r.r��xrAs   �rr0�join_by.<locals>.<genexpr>s&����D����1��A��E�F��3C�1�1��s�"�	"zduplicate join key zr1 does not have key field zr2 does not have key field z8r1 and r2 contain common names, r1postfix and r2postfix zcan't both be empty)�orderFrCNr�rW)rrrXrYrr�)rXrYr�)r%rTr]r&r��next�	enumerater#r$r�r�rhr2rFrDr4r6r0r�r��sortrqry)0rArOrPrQrRrSrvrorp�dupr/�nb1�nb2�r1names�r2names�876collisionsr�r��key1�r1k�r2k�aux�idx_sort�flag_in�idx_in�idx_1�idx_2�r1cmn�r2cmn�r1spc�r2spc�idx_out�s1�s2r>r:r;r#r$r<rAr=�cmnrr3�selectedr)�kwargss0`                                               rrr�s[���h�6�6��<�>F�G��	�877�#�s����f���3�s�8�}��C�� ��D��3��D�D���.�s�g�6�7�7����x�x�~�~�%��:�4�(�C�D�D��x�x�~�~�%��:�4�(�C�D�D�	�878����B�	����B��b�'�3�r�7�#��(�(�.�.�"�(�(�.�.�g��g�,��W��-��S��9�J��9�	�H���$�$����o���+�w�!�!�s�(�A�w�D�+�879�r�4�880 �C�881�r�4�882 �C�
�.�.�#�s��883$�C��{�{��{�%�H�884
�h�-�C��n�n�u�g�s�1�2�w�#�c�r�(�':�;�<�G��1�2�;���"��-�G�C�R�L�
�g�
�F��F�S�L�"�E��F�c�M�#�c�)�E��%�j�#�e�*�E�U��7������	�W�	��G�8�$������w��#�
�'?�@�A������w��3��'@�3�'F�G�H���e�*�u�,�c�%�j�5�.@����	�[�	 ��G�8�$������w��#�
�'?�@�A���e�*�u�,�a����5�	�2�e�9��R��C�I�I�
&�F�(����1�
��v�����M�M�5�&�/�*�2�885(����1�
��v�*0�0��+�$�����0�	��k�k�%�(�G��w��I�A�v���|�#(�#�f�f�*=�">��w��886�Y�&��/��Y�&��/�/��w�w��{�+�%2�.�X�X�f�
�F��e�U�887�C�
�]�]�C�%�K�%�/�1��
@�F��L�L���E�
���a�5���E�>�a�7�l�9��#��
��N�A���)��"�6�E�*������-�-�'/���'7�G�C��e��$�����a�5���E�>�a�7�l�9��#��
��N�A���)��"�6�E�*��������U�U�'���/�G�U�F�G����K�K�c�K�� �
;�F��}�V�X�6�A�&�A�A��s,��V1���	+��M�M�5�&�/�*�*�	+�s$�888S�S�"S �5S&�&T�Tc��X4$rr)rArOrPrQrRrSrvs       r�_rec_join_dispatcherr{{rUr!c�,�X4UUSSS.n[XU40UD6$)z�889Join arrays `r1` and `r2` on keys.890Alternative to join_by, that always returns a np.recarray.891 892See Also893--------894join_by : equivalent function895FT)rQrRrSrvrorp)r)rArOrPrQrRrSrvrys        rrr�s*��#��&�5��N�F��3�B�)�&�)�)r!)F)NN)NT)TFr)NNNN)r�FFF)Nr�TF)FF)r)NNN)NF�unsafe)NNNNN)NNFFr})T)NTFF)NTF)NNNNNN)rW�1�2NTF)rWr~rN)?�__doc__ra�numpyrD�numpy.marh�numpy.ma.mrecords�mrecordsrk�numpy._core.overridesr�numpy.lib._iotoolsr�__all__r rr4rr
r896rHrKrrVr^rfrqryr{rr�rr�r�rr�rr�rr�rr�rr�r�r�rrrrrr#rr'rr-rrDr	rTrr{rrr!r�<module>r�s������ � �9�.�����:�;�$�<�$�N897�@�B�B�6
� 8�-�`898�
� "�0�"�BF�6:��899�1�2�38�+0�E�3�E�P��0�1�:G�2�:G�zG�2��4�5�I�6�I���2�3�%�4�%�P9=�HL���2�3�,0�:?�CG�4�CG�L�900�6�7�9�8�9�D��2�3�Q"�4�Q"�f#�J*�ZBF�37���?�@�1�A�1�DCG�JN���?�@�BG�3;�i'�A�i'�V��7�8�'�9�'�V��:�;�#3�<�#3�J��3�4�)�5�)�X=A�:>��901�1�2�AF�"�T?�3�T?�p48��902�4�5�7�6�7�v?C�04���,�-�DG�49�nB�.�nB�d?C����-�.�EH��*�/�*�r!
codekingpro/portable-devtools · Team Ai