Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/core/computation/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/core/computation/__pycache__/scope.cpython-312.pyc

�

Mٜg�'�	�X�dZddlmZddlmZddlZddlZddlmZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlmZddlmZed	�Zed
�ZGd�deeef�Z	d			dd�Zdd�Zdd�Zeej
ddeeej:ej:d�Zdd�ZGd�d
�Z y)z
Module for scope operations
�)�annotations)�ChainMapN)�StringIO)�TypeVar)�	Timestamp)�UndefinedVariableError�_KT�_VTc� �eZdZdZdd�Zdd�Zy)�DeepChainMapz~
    Variant of ChainMap that allows direct updates to inner scopes.

    Only works when all passed mapping are mutable.
    c�`�|jD]
}||vs�|||<y||jd|<y)Nr)�maps)�self�key�value�mappings    �H/usr/local/lib/python3.12/site-packages/pandas/core/computation/scope.py�__setitem__zDeepChainMap.__setitem__!s7���y�y�G��g�~�$�����!�"��	�	�!��S��c�L�|jD]}||vs�||=yt|��)z\
        Raises
        ------
        KeyError
            If `key` doesn't exist.
        N)r�KeyError)rrrs   r�__delitem__zDeepChainMap.__delitem__(s/���y�y�G��g�~��C�L��!��s�m�rN)rr	rr
�return�None)rr	rr)�__name__�
__module__�__qualname__�__doc__rr�rrrrs���"�rr�Scopec�(�t|dz||||��S)z.Ensure that we are grabbing the correct scope.�)�global_dict�
local_dict�	resolvers�target)r )�levelr#r$r%r&s     r�ensure_scoper(6s$���
��	������rc�f�	t|�}t|�S#t$r|}Yt|�SwxYw)z�
    Replace a number with its hexadecimal representation. Used to tag
    temporary variables with their calling scope's id.
    )�ord�	TypeError�hex)�x�hexins  r�	_replacerr/Cs<����A���
�u�:���	�����u�:��	�s��0�0c��tjdt|��}dj|D�cgc]
}t	|���c}�Scc}w)z,Return the padded hexadecimal id of ``obj``.z@P�)�struct�pack�id�joinr/)�obj�packedr-s   r�_raw_hex_idr8Ss=���[�[��r�#�w�
'�F�
�7�7�&�1�&�Q�I�a�L�&�1�2�2��1s�ATF)r�datetime�True�False�list�tuple�inf�Infc�d�t�}tj||��|j�S)z�
    Return a prettier version of obj.

    Parameters
    ----------
    obj : object
        Object to pretty print

    Returns
    -------
    str
        Pretty print object repr
    )�stream)r�pprint�getvalue)r6�sios  r�_get_pretty_stringrEfs%���*�C�
�M�M�#�c�"��<�<�>�rc��eZdZUdZgd�Zded<ded<ded<ded	<	d			dd�Zdd�Zedd
��Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zedd��Zedd��Zy
)r a�
    Object to hold scope, with a few bells to deal with some custom syntax
    and contexts added by pandas.

    Parameters
    ----------
    level : int
    global_dict : dict or None, optional, default None
    local_dict : dict or Scope or None, optional, default None
    resolvers : list-like or None, optional, default None
    target : object

    Attributes
    ----------
    level : int
    scope : DeepChainMap
    target : object
    temps : dict
    )r'�scoper&r%�temps�intr'rrGr%�dictrHNc�Z�|dz|_ttj��|_||_t
|t�r]|jj|j�|j
�|j
|_|j|j�tj|j�}	|jj|�|n|jj��}t|�|_t
|t�sG|jj|�|n|jj��}t|�|_~t
|t�r"|t|j j"�z
}t|�|_i|_y#~wxYw)Nr")r'r�DEFAULT_GLOBALS�copyrGr&�
isinstancer �update�_update�sys�	_getframe�	new_child�	f_globals�f_localsr=r%rrH)	rr'r#r$r%r&�frame�scope_global�scope_locals	         r�__init__zScope.__init__�sS���Q�Y��
�"�/�"6�"6�"8�9��
�����j�%�(��J�J���j�.�.�/�� � �,�(�/�/����L�L��)�)�*��
�
�d�j�j�)��	� �:�:�/�/� +� 7��U�_�_�R�R�T��L�&�l�3�D�J��j�%�0�"�j�j�2�2�#-�#9�Z�u�~�~�S�S�U���*�+�6��
���j�%�(���z�3�3�8�8�9�9�I�%�y�1�����
��
�s
�BF'�'F*c���tt|jj���}tt|jj���}t|�j�d|�d|�d�S)Nz(scope=z, resolvers=�))rEr<rG�keysr%�typer)r�
scope_keys�res_keyss   r�__repr__zScope.__repr__�s\��'��T�Z�Z�_�_�->�(?�@�
�%�d�4�>�>�+>�+>�+@�&A�B���t�*�%�%�&�g�j�\��h�Z�q�Q�Qrc�>�tt|j��S)z�
        Return whether we have any extra scope.

        For example, DataFrames pass Their columns as resolvers during calls to
        ``DataFrame.eval()`` and ``DataFrame.query()``.

        Returns
        -------
        hr : bool
        )�bool�lenr%�rs r�
has_resolverszScope.has_resolvers�s���C����'�(�(rc��	|r|j|S|jr|j|S|s|jrJ�|j|S#t$r1	|j|cYS#t$r}t||�|�d}~wwxYwwxYw)a�
        Resolve a variable name in a possibly local context.

        Parameters
        ----------
        key : str
            A variable name
        is_local : bool
            Flag indicating whether the variable is local or not (prefixed with
            the '@' symbol)

        Returns
        -------
        value : object
            The value of a particular variable
        N)rGrer%rrHr)rr�is_local�errs    r�resolvez
Scope.resolve�s���"	E���z�z�#��&��!�!��~�~�c�*�*� ��(:�(:�:�:��:�:�c�?�"���	E�
E��z�z�#��&���
E�,�S�(�;��D��
E��
	E�s9�A
�A
�A
�
	B�A(�%B�(	B�1
A>�>B�Bc��|jr.|jj|jjz}n|jj}|j	|j
�|D]
}||vs�|||<yy)a]
        Replace a variable name, with a potentially new value.

        Parameters
        ----------
        old_key : str
            Current variable name to replace
        new_key : str
            New variable name to replace `old_key` with
        new_value : object
            Value to be replaced along with the possible renaming
        N)rer%rrG�appendrH)r�old_key�new_key�	new_valuerrs      r�swapkeyz
Scope.swapkey�se������>�>�&�&������8�D��:�:�?�?�D����D�J�J���G��'�!�#,��� ��rc���tj||�}|D]F\}\}}}}}}	t|d|���}t|jj|��|_~�Hy#~wxYw)a�
        Get specifically scoped variables from a list of stack frames.

        Parameters
        ----------
        stack : list
            A list of stack frames as returned by ``inspect.stack()``
        scopes : sequence of strings
            A sequence containing valid stack frame attribute names that
            evaluate to a dictionary. For example, ('locals', 'globals')
        �f_N)�	itertools�product�getattrrrGrS)r�stack�scopes�	variablesrGrV�_�ds        r�	_get_varszScope._get_varssp���%�%�f�e�4�	�-6�)�E�)�E�1�a��A�q�
��E�R��w�<�0��)�$�*�*�*>�*>�q�*A�B��
�
�.7���s�8A#�#A&c��|dz}tj�}	|j|d|dg��|dd�=~y#|dd�=~wxYw)z�
        Update the current scope by going back `level` levels.

        Parameters
        ----------
        level : int
        r"N�locals)rv)�inspectrurz)rr'�slrus    rrPz
Scope._update&sJ���Q�Y��
�
�
���	 ��N�N�5��"�:�x�j�N�9��a��%���a��%�s	�9�Ac���t|�j�d|j�dt|���}||jvsJ�||j|<||jvsJ�|S)a#
        Add a temporary variable to the scope.

        Parameters
        ----------
        value : object
            An arbitrary object to be assigned to a temporary variable.

        Returns
        -------
        str
            The name of the temporary variable created.
        rx)r]r�ntempsr8rH)rr�names   r�add_tmpz
Scope.add_tmp:sj���u�+�&�&�'�q����
�Q�{�4�7H�6I�J���4�:�:�%�%�%� ��
�
�4���t�z�z�!�!�!��rc�,�t|j�S)z/The number of temporary variables in this scope)rcrHrds rr�zScope.ntempsRs���4�:�:��rc��|jg|jjz|jjz}t	|�S)z�
        Return the full scope for use with passing to engines transparently
        as a mapping.

        Returns
        -------
        vars : DeepChainMap
            All variables in this scope.
        )rHr%rrGr)rrs  r�
full_scopezScope.full_scopeWs6���
�
�|�d�n�n�1�1�1�D�J�J�O�O�C���T�"�"r�NNrN)r'rIrr�r�str)rrb)rr�rgrb)N)rlr�rmr�rr)rvz	list[str]rr)rrI)rr)rrrr�	__slots__�__annotations__rYr`�propertyrerirorzrPr�r�r�rrrr r ys����(C�I��J������K�SW�&��&�	
�&�PR�
�)��)�%E�N�2�. �(�0�����#��#rr�)r'rIrr r�)!r�
__future__r�collectionsrr9r}�iorrrrBr2rQ�typingr�numpy�np�pandas._libs.tslibsr�
pandas.errorsrr	r
rr(r/r8r<r=r>rLrEr rrr�<module>r�s����#� �����
�
�
���)�0�
�e�n��
�e�n���8�C��H�%��:IM�
��
�
�
�
� 3���!�!��
��
�
�6�6�
�6�6�	���&j#�j#r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists