HOME


sh-3ll 1.0
DIR:/opt/cloudlinux/venv/lib64/python3.11/site-packages/xarray/core/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/xarray/core/__pycache__/merge.cpython-311.pyc
�

���h5���ddlmZmZmZddlmZddlmZddlm	Z	m
Z
mZd�Zdd�Z
d	�Zd
�Zd�Ze��dd
fd�Zdd�Zd�ZdS)�)�align�
partial_align�align_variables)�ChainMap)�as_variable)�
basestring�	iteritems�OrderedDictc���	t||���}n#t$rtd���wxYw||jvr:|jdkrt	d|�d|j�d����|���}|S)z2Prepare a variable for adding it to a Dataset
    )�keyzXvariables must be given by arrays or a tuple of the form (dims, data[, attrs, encoding])rz
the variable z, has the same name as one of its dimensions z>, but it is not 1-dimensional and thus it is not a valid index)r�	TypeError�dims�ndim�
ValueError�to_coord)�name�vars  �F/opt/cloudlinux/venv/lib/python3.11/site-packages/xarray/core/merge.py�_as_dataset_variablers���D��#�4�(�(�(�����D�D�D��C�D�D�	D�D�����s�x����8�q�=�=��*�?C�t�t�S�X�X�X�O�P�P�
P��l�l�n�n���Js��.N�	identicalc���	�
��|�i}t��}t���
t||����
�fd��	��	�
�fd�}t|��D]s\}}t	|d��rR�
�|j��t|j��D]\}}||kr|||j���|j}|||���t|�
fS)a�Expand a dictionary of variables.

    Returns a dictionary of Variable objects suitable for inserting into a
    Dataset._variables dictionary.

    This includes converting tuples (dims, data) into Variable objects,
    converting coordinate variables into Coordinate objects and expanding
    DataArray objects into Variables plus coordinates.

    Raises ValueError if any conflicting values are found, between any of the
    new or old variables.
    Nc�Z���|}||jvr�||jvr|�|<dStt|j|j����}|�t|j|j����|�|���|<��|j��dSdS�N)rr
�zip�shape�update�expand_dims)rr�existing_var�common_dims�new_coord_names�	variabless    ��r�maybe_promote_or_replacez2expand_variables.<locals>.maybe_promote_or_replace,s���� �����|�(�(�(��s�x���"%�	�$����)�#�l�.?�.:�.@�+B�+B�C�C���"�"�3�s�x���#;�#;�<�<�<�".�":�":�;�"G�"G�	�$���&�&�s�x�0�0�0�0�0�)�(�c� ��t||��}|�vr'|�|<���|j��dSt�|���|��st	d|�d�|�d|������dkr�||��dSdS)Nzconflicting value for variable z:
first value: z
second value: �broadcast_equals)rrr�getattrr)rr�compatr"r r!s  ����r�add_variablez&expand_variables.<locals>.add_variable8s����"�4��-�-���y� � �!�I�d�O��"�"�9�T�?�#7�8�8�8�8�8�3�7�9�T�?�F�3�3�C�8�8�
A� �j�$(�D�D�)�D�/�/�/�3�3�"@�A�A�A��+�+�+�(�(��s�3�3�3�3�3�,�+r#�coords)r
�setrr	�hasattrrr)�variable)�
raw_variables�
old_variablesr'�
new_variablesr(rr�dim�coordr"r r!s  `      @@@r�expand_variablesr2s!���������
��M�M�M��e�e�O���
�6�6�I�
1�
1�
1�
1�
1�
1�4�4�4�4�4�4�4�4��}�-�-� � �	��c��3��!�!�	��"�"�3�:�.�.�.�'��
�3�3�
6�
6�
��U��$�;�;� �L��e�n�5�5�5���,�C���T�3������/�)�)r#c����t�fd�|���D����}t|||��\}}|���}|�|��|||fS)Nc3�.�K�|]\}}|�v�	||fV��dSr�)�.0�k�v�overwrite_varss   �r�	<genexpr>z _merge_expand.<locals>.<genexpr>SsA�����:�:���A�!"�.�!8�!8� !�!�f�!8�!8�!8�!8�:�:r#)�dict�itemsr2�copyr)r!�otherr9r'�possible_conflicts�new_varsr �replace_varss  `     r�
_merge_expandrBRs�����:�:�:�:����1B�1B�:�:�:�:�:�� 0��8J�F� S� S��H�o��>�>�#�#�L�����!�!�!���?�2�2r#c��t|||d���\}}t|j|j||��\}}}|�|j��|||fS)NF��joinr=)rrB�
_variablesr�_coord_names)	�selfr>r9r'rE�aligned_selfrAr@r s	         r�_merge_dataset_with_datasetrJ[sh����e�$�U�C�C�C��L�%�.;����!1�>�6�/K�/K�+�L�(�O����5�-�.�.�.���?�2�2r#c�R��t�dd����d�����D��}t|g�fd�|D���R|d|d��}|d}t������t||dd�����t
|j�||��S)	N�outerFrDc�8�g|]\}}t|d���|��S��indexes�r+�r6r7r8s   r�
<listcomp>z,_merge_dataset_with_dict.<locals>.<listcomp>hs+��F�F�F�t�q�!���9�0E�0E�F��F�F�Fr#c� ��g|]
}�|��Sr5r5)r6�ar>s  �rrRz,_merge_dataset_with_dict.<locals>.<listcomp>is���#@�#@�#@��E�!�H�#@�#@�#@r#)rEr=�exclude�r)rr<rr
rrrBrF)rHr>r9r'rE�	alignable�alignedrIs `      r�_merge_dataset_with_dictrYes�����E��e�<�<�<�E�F�F�u�{�{�}�}�F�F�F�I��D�K�#@�#@�#@�#@�i�#@�#@�#@�K�K�!%�E�>�K�K�K�G��1�:�L�����E�	�L�L��Y������,�,�-�-�-���0�%���P�P�Pr#r%rLc���ddlm}|dvrtd|z���t|t��r|g}t|��}t||��rt}nt}||||||���\}}}	|	t|j��z}
t|j	��t|��|	z
z}|
|z|z
}|rtdt|��z���||	fS)z
    Guts of Dataset.merge
    r)�Dataset)r%�equalsrzFcompat=%r invalid: must be 'broadcast_equals', 'equals' or 'identical')r'rEzZcannot merge: the following variables are coordinates on one dataset but not the other: %s)�datasetr[r�
isinstancerr*rJrY�	data_varsr)�list)
r]r>r9r'rEr[�
merge_funcrAr@r �newly_coords�no_longer_coords�ambiguous_coordss
             r�merge_datasetsrets9��
!� � � � � �
�@�@�@��3�5;�<�=�=�	=��.�*�-�-�*�(�)����(�(�N��%��!�!�.�0�
�
�-�
�.8�j����v�D�/B�/B�/B�+�L�(�O�#�S��):�%;�%;�;�L��7�>�*�*�c�(�m�m�o�.M�N��$�'7�7�>�I���3��L�� 0�1�1�2�3�3�	3���(�(r#Fc�d���d�����D��}g}|D]X�t��fd�|���D����}|���jdd|i|�����Yt	���}|�t
||����|S)zMReindex all DataArrays in the provided dict, leaving other values alone.
    c�8�g|]\}}t|d���|��SrNrPrQs   rrRz._reindex_variables_against.<locals>.<listcomp>�s+��J�J�J�t�q�!�G�A�y�4I�4I�J��J�J�Jr#c3�D�K�|]\}}|��jv�||fV��dSr)r)r6r7r8rTr!s   ��rr:z-_reindex_variables_against.<locals>.<genexpr>�sH�����8�8���1� !�Y�q�\�%6� 6� 6� ��V� 6� 6� 6� 6�8�8r#r=r5)r<r;�append�reindexr
rr)r!rOr=rWrX�
valid_indexesr/rTs`      @r�_reindex_variables_againstrl�s�����K�J�y���0�0�J�J�J�I��G�
�I�I���8�8�8�8�8��
�
���8�8�8�8�8�
����+�y��|�+�G�G��G��G�G�H�H�H�H��	�*�*�M�����Y��0�0�1�1�1��r#c�|�t|dd���}t||d���}t|||d���\}}}|S)zt
    Return the new dictionary of coordinate variables given by merging in
    ``other`` to to these variables.
    rLFrD)r=r%)r')rrlrB)rOr!r>rA�_�__s      r�merge_dataarray_coordsrp�sW��

�E��e�<�<�<�E�&�u�g�E�B�B�B�E�'��5�%�(:�<�<�<��L�!�R��r#)Nr)F)�	alignmentrrr�utilsrr,r�pycompatrr	r
rr2rBrJrYr*rerlrpr5r#r�<module>rts��<�<�<�<�<�<�<�<�<�<�������!�!�!�!�!�!�:�:�:�:�:�:�:�:�:�:����$6*�6*�6*�6*�r3�3�3�3�3�3�Q�Q�Q�36�#�%�%�,�7�)�)�)�)�D����	�	�	�	�	r#