
    ɯei                        U d Z ddlZddlZddlZddlZddlZddlZddlmZm	Z	 ddl
mZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZ ddlZddlZddlmZmZ ddlm Z m!Z! dd	l"m#Z# dd
l$m%Z% ddl&m'Z' ddl(m)Z)  ed      Z*	  ede      Z+	 e G d de             Z,e G d de             Z-e G d de             Z.e G d de             Z/dej`                   dZ1dZ2	 de3de3fdZ4de3de5fdZ6d ee7e3f   de7fd!Z8d"e3d#e3de3fd$Z9d e3d%e3de3fd&Z:d'e3dee+ge+f   fd(Z;	 	 	 dld)e<d*e<d+e=d,eee3e7e3   f      d-ee+   d.ee3   d/eee<e3ge3f      ddfd0Z>g Z?e7ee3gdf      e@d1<    eA       ZBeAeCeDe3f      e@d2<   d3e<de=fd4ZEd5e%ddfd6ZF	 	 dmd7ZGg d8ddfd9e<d:e7e<   d;e=d,eee3e7e3   f      d/eee<e3ge3f      dee+ge+f   fd<ZH e%j                  eF       d=e3dee+ge+f   fd>ZJd?e3de7eKe3e3f      fd@ZLdAe7eKe3e3f      de3fdBZMdCe	e   dDedee5   fdEZNg d8dfd9e<d:e7e<   d;e=d,eee3e7e3   f      dee+ge+f   f
dFZOdGe,defdHZPd3e=de=fdIZQdnd3edJe=defdKZRdLdMdNedOe=de7e   fdPZSdQedefdRZTdSeg e*f   de*fdTZUdUe3d'e3dej                  fdVZWdWede=fdXZXdYe3dZe=dee   fd[ZYdYe3dZe=d\e3ddfd]ZZd^eee5e	e5   ed_   f      d`eee	e   ef      de=fdaZ[dbedefdcZ\dndde5dee3dfe=de5fdgZ]dhede3de3fdiZ^ G dj dk      Z_y)ozACollection of general utility functions, mostly for internal use.    N)HashableSequence)Path)dedentindent)	AnyCallableLiteralNoReturnOptionalProtocolTypeVarUnionruntime_checkable)	NoDefault
no_default)is_float
is_integer)Appender)	DocModule)ErrorMessage)WarningMessageTFn)boundc                       e Zd ZdZdefdZy)SupportsPrivateToPandaszWStructural type for objects with a ``_to_pandas`` method (note the leading underscore).returnc                      y N selfs    `/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/snowflake/snowpark/modin/utils.py
_to_pandasz"SupportsPrivateToPandas._to_pandasC   s        N)__name__
__module____qualname____doc__r   r%   r!   r&   r$   r   r   ?   s    aC r&   r   c                       e Zd ZdZdefdZy)SupportsPublicToPandaszWStructural type for objects with a ``to_pandas`` method (without a leading underscore).r   c                      y r    r!   r"   s    r$   	to_pandasz SupportsPublicToPandas.to_pandasL       r&   N)r'   r(   r)   r*   r   r.   r!   r&   r$   r,   r,   H   s    a3 r&   r,   c                       e Zd ZdZdefdZy)SupportsPublicToNumPyzVStructural type for objects with a ``to_numpy`` method (without a leading underscore).r   c                      y r    r!   r"   s    r$   to_numpyzSupportsPublicToNumPy.to_numpyT   r/   r&   N)r'   r(   r)   r*   r   r3   r!   r&   r$   r1   r1   P   s    `# r&   r1   c                       e Zd ZdZdefdZy)SupportsPrivateToNumPyzVStructural type for objects with a ``_to_numpy`` method (note the leading underscore).r   c                      y r    r!   r"   s    r$   	_to_numpyz SupportsPrivateToNumPy._to_numpy\   r/   r&   N)r'   r(   r)   r*   r   r7   r!   r&   r$   r5   r5   X   s    `3 r&   r5   z.https://pandas.pydata.org/pandas-docs/version/z/reference/api/{}.html__reduced__tokenr   c                 ,    t         j                  |       S )a  
    Generate the link to pandas documentation.

    Parameters
    ----------
    token : str
        Part of URL to use for generation.

    Returns
    -------
    str
        URL to pandas doc.

    Notes
    -----
    This function is extracted for better testability.
    )PANDAS_API_URL_TEMPLATEformat)r9   s    r$   _make_api_urlr=   j   s    $ #))%00r&   docc                 6    t        |       }|rt        |      S dS )z
    Compute indentation in docstring.

    Parameters
    ----------
    doc : str
        The docstring to compute indentation for.

    Returns
    -------
    int
        Minimal indent (excluding empty lines).
    r   )_get_indentsmin)r>   indentss     r$   _get_indentrC      s     3G"3w<))r&   sourcec                     g }t        | t              s| j                         } | D ]>  }|j                         st	        |      D ]  \  }}|dk7  s n |j                         @ |S )aQ  
    Compute indentation for each line of the source string.

    Parameters
    ----------
    source : str or list of str
        String to compute indents for. Passed list considered
        as a list of lines of the source string.

    Returns
    -------
    list of ints
        List containing computed indents for each line.
     )
isinstancelist
splitlinesstrip	enumerateappend)rD   rB   lineposchs        r$   r@   r@      sr     Gfd#""$ zz|  	GCSy	 	s Nr&   templatekwargsc           	      ,   d}| j                         D ]  }|j                         dk(  rt        j                  ||      }|0t	        |j                  d            }|j                  d      }|j                  |      }|sot        |      }|d   dk(  r|dd }|j                         }|dd D cg c]  }|dk7  rt        |d|z        n| }	}|d	   dk(  r	|	d|z  gz  }	dj                  |d   g|	      }
|
||<     | j                  d
i |S c c}w )a  
    Insert passed values at the corresponding placeholders of the specified template.

    In contrast with the regular ``str.format()`` this function computes proper
    indents for the placeholder values.

    Parameters
    ----------
    template : str
        Template to substitute values in.
    **kwargs : dict
        Dictionary that maps placeholder names with values.

    Returns
    -------
    str
        Formated string.
    z^( *)\{(\w+)\} N      r   
rF   r!   )rI   rJ   researchlengroupgetr   r   joinr<   )rP   rQ   regexrM   matchnspaceskeyvaluevalue_linesindented_linesindented_values              r$   format_stringrf      sG   . E##% "%::<2		%&=ekk!n%kk!n

3u 8t!"IE &&(
 $AB
 ,04<F4w'TA
 

 9sW}o-NKN#D^#DE$sE"%H 8??$V$$
s   1Dtargetc                 L    t        |       }t        |      }t        |d|z        S )a  
    Align indents of two strings.

    Parameters
    ----------
    source : str
        Source string to align indents with.
    target : str
        Target string to align indents.

    Returns
    -------
    str
        Target string with indents aligned with the source.
    rF   )rC   r   r   )rD   rg   source_indents      r$   align_indentsrj      s)       'MF^F&#-..r&   messagec                 ,     dt         dt         f fd}|S )z
    Create a decorator which appends passed message to the function's docstring.

    Parameters
    ----------
    message : str
        Message to append.

    Returns
    -------
    callable
    funcr   c                 Z    t        | j                  xs d      } t        |      |       S )NrS   )rj   r*   r   )rm   	to_appendrk   s     r$   	decoratorz&append_to_docstring.<locals>.decorator  s*    !$,,"4"g>	"x	"4((r&   r   )rk   rp   s   ` r$   append_to_docstringrr     s    ) )r ) r&   
source_obj
target_obj	overwriteapilink
parent_cls	attr_name
modify_docc           
         t        |t        t        f      r|j                  }| j                  xs d}|j                  xs d}|xs | }|r|n|}	|rb|s`t        |t
              r|j                  j                  }n9t        |t        t        f      r|j                  j                  }n|j                  }|j                         r|rd|vr|xs dj                  d      st        |t              s|r|gn|}
g }|
D ]1  }|r| d| }n|}t        |      }|j                  d| d| d       3 dt        |	      z  }d	| d
| d}| ddj                  |      j                          d}||z   }||	v r|	j                  ||      }	n|	|z  }	|	 |||	      }	|r_t        |t
              rO|rd|j                  _        |J t#        ||t        |j                  |j$                  |j&                  |	             y|rd|_        |	|_        y)a  
    Replace docstring in `target_obj`, possibly taking from `source_obj` and augmenting.

    Can append the link to pandas API online documentation.

    Parameters
    ----------
    source_obj : object
        Any object from which to take docstring from.
    target_obj : object
        The object which docstring to replace.
    overwrite : bool
        Forces replacing the docstring with the one from `source_obj` even
        if `target_obj` has its own non-empty docstring.
    apilink : str | List[str], optional
        If non-empty, insert the link(s) to pandas API documentation.
        Should be the prefix part in the URL template, e.g. "pandas.DataFrame".
    parent_cls : class, optional
        If `target_obj` is an attribute of a class, `parent_cls` should be that class.
        This is used for generating the API URL as well as for handling special cases
        like `target_obj` being a property.
    attr_name : str, optional
        Gives the name to `target_obj` if it's an attribute of `parent_cls`.
        Needed to handle some special cases and in most cases could be determined automatically.
    modify_doc: Optional[Callable[[object, str],str]], default: None
        If not None, then call this function to retrieve a new docstring to use.
    rS   zpandas API documentation for _.`z <z>`_rF   rV   zNote
z-----
z!See pandas API documentation for z, z for more.
NT)rG   staticmethodclassmethod__func__r*   propertyfgetr'   rJ   
startswithrH   r=   rL   rC   r]   replace__doc_inherited__setattrfsetfdel)rs   rt   ru   rv   rw   rx   ry   
source_doc
target_docr>   	apilink_llinkslinkr9   urlindent_linenotes_sectionurl_linenotes_section_with_urls                      r$   _replace_docr     s#   H *|[9:  ((
##)rJ##)rJ+^I!*zC)j(+"00I
\;$?@"++44I"++I 	+:=/r--c2%/%>7WIPW	 	0D&)-&CLL1UG2cU#./	0 K,,[M}GD!]"CDIIeDTDZDZD\C]]ij!.!9C++m-CDC))C S)jX604JOO-$$$Z__joozL	
 +/J( 
r&   _docstring_inheritance_calls$_attributes_with_docstrings_replacedobjc                     t        t        |       xsD t        | t              xr | j                  xs$ t        | t
        t        f      xr | j                        S )z*Check if `obj` docstring could be patched.)boolcallablerG   r   r   r~   r   r   r   s    r$   _documentable_objr     sM     	KsH%2#((	Ks\;78IS\\ r&   
doc_modulec                 p    t         j                          t        D ]  } || j                                 y)z
    Update all inherited docstrings.

    Parameters
    ----------
    doc_module: DocModule
        The current DocModule
    r   N)r   clearr   r\   )r   doc_inheritance_calls     r$   _update_inherited_docstringsr     s/     )..0 < :
(89:r&   c                    t        j                  |      }|}|t        j                  k7  rDdt	        t        |dd            v r,t        | dd      dk(  rdnt        |dd      }	t        ||	|      }||k7  rd }d}||vrt        || |||       t        | t        j                        st               }
| j                  D ]  }|t        u r|j                  j                         D ]  \  }}||
v s
||ft        v r|
j!                  |       t        ||t        ||d             }||v st#        |      rt#        |      sYt        ||||| ||       t        j!                  ||f         y y )	Npandasr(   rS   r'   BasePandasDatasetT)ry   )rw   rx   ry   )	importlibimport_moduler   defaultstrgetattrr   rG   typesFunctionTypeset__mro__object__dict__itemsr   addr   )cls_or_funcr   parentexcludedoverwrite_existingrv   ry   imported_doc_moduledefault_parentparent_nameseenbaseattrr   
parent_objs                  r$   _inherit_docstrings_in_placer     s    $11*= N Y&&&8sb)8 , {J37JJ  
 R0 	 ,k6B!XK!3W	
 k5#5#56u'' 	GDv~!]]002 G	c4<D$<3W#W %VT7>4QU3VW
(*,Z8,S1&*") 588$F3G	G 7r&   Fr   r   r   c                 <     dt         dt         f fd}|S )a  
    Create a decorator which overwrites decorated object docstring(s).

    It takes `parent` __doc__ attribute. Also overwrites __doc__ of
    methods and properties defined in the target or its ancestors if it's a class
    with the __doc__ of matching methods and properties from the `parent`.

    Parameters
    ----------
    parent : object
        Parent object from which the decorated object inherits __doc__.
    excluded : list, default: []
        List of parent objects from which the class does not
        inherit docstrings.
    overwrite_existing : bool, default: False
        Allow overwriting docstrings that already exist in
        the decorated class.
    apilink : str | List[str], optional
        If non-empty, insert the link(s) to pandas API documentation.
        Should be the prefix part in the URL template, e.g. "pandas.DataFrame".
    modify_doc: Optional[Callable[[str],str]], default: None
        If not None, then call this function to retrieve a new docstring to use.

    Returns
    -------
    callable
        Decorator which replaces the decorated object's documentation with `parent` documentation.

    Notes
    -----
    Keep in mind that the function will override docstrings even for attributes which
    are not defined in target class (but are defined in the ancestor class),
    which means that ancestor class attribute docstrings could also change.
    r   r   c           	          t        j                  t        |       } |t        j                                t
        j                  |       | S )N)r   r   r   r   rv   ry   r   )	functoolspartialr   r   r\   r   rL   )r   inherit_docstring_in_placerv   r   ry   r   r   s     r$   rp   z&_inherit_docstrings.<locals>.decorator  sN    %.%6%6(#1!&
" 	#immo>$++,FGr&   rq   )r   r   r   rv   ry   rp   s   ````` r$   _inherit_docstringsr     s$    Vr b   r&   argnamec                 ,     dt         dt         f fd}|S )a&  
    Decorate a function replacing its path argument with "user-expanded" value.

    Parameters
    ----------
    argname : str
        Name of the argument which is containing a path to be expanded.

    Returns
    -------
    callable
        Decorator which performs the replacement.
    rm   r   c                     t        j                         t        j                  j	                        dd       k(  sJ d  d d       t        j                         dt        dt        dt        f fd       }|S )	Nnamez	Function z does not take 'z' as argumentargskwr   c                      j                   | i |}|j                  j                  d       x}rt        |t              r>|j                  d      r-t        j                  j                  |      |j                  <   n-t        |t              r|j                         |j                  <    |j                  i |j                  S  | i |S )N~)bind	argumentsr\   rG   r   r   ospath
expanduserr   r   rQ   )r   r   paramspathargr   rm   	signatures       r$   wrappedz7expanduser_path_arg.<locals>.decorator.<locals>.wrappedB  s    #Y^^T0R0F **..w==w=gs+0B0B1 130B0B70KF$$W-.070B0B0DF$$W-V[[:FMM::$$$r&   )
inspectr   r   
parametersr\   r   wrapstupledictr   )rm   r   r   r   s   ` @r$   rp   z&expanduser_path_arg.<locals>.decorator<  s    %%d+	I((,,W5vtDO	Dtf,WI]C	DO 
	
	%5 
	% 
	% 
	% 

	% r&   rq   )r   rp   s   ` r$   expanduser_path_argr   -  s     r * r&   textc                 .   | j                  d      }t        t        d t        d t	        t        t        |            |                        }d}d}g }|D ]z  }d}|dz
  dk\  r&||dz
     }t        |j                               dk(  rd}|||dz
   }|d   j                  d      r|dd }|j                  |dj                  |      d	       |}|}| ||d }|d   j                  d      r|dd }|j                  |dj                  |      d	       |S )
z
    split docstring into sections.
    Args:
        text: input text

    Returns:
        list of dictionaries where each dictionary contains a key heading, and a key content.
    rV   c                     | d   S Nr   r!   ts    r$   <lambda>z"extract_sections.<locals>.<lambda>b  
    ad r&   c                 n    t        | d         dkD  xr# | d   j                  d      t        | d         k(  S )NrT   r   -)rZ   countr   s    r$   r   z"extract_sections.<locals>.<lambda>d  s0    #ad)a-HAaDJJsOs1Q4y,H r&   r   rS   rT   r   Nheadingcontent)splitrH   mapfilterziprangerZ   rJ   r   rL   r]   )	r   linesheading_linenoslast_linenolast_headingsectionslinenor   section_liness	            r$   extract_sectionsr   T  sB    JJtE HE#e*%u-	
O KLH! A:?FQJ'G 7==?#q(kFQJ7 &&s+)!"-MLTYY}=UVW%* +,'M Q""3'%ab)OO=9QRSOr&   r   c                 :    dj                  t        d |             S )a  
    create docstring from individual sections given as dictionaries (see extract sections)
    Args:
        sections:
            list of dictionaries where each dictionary contains a key heading, and a key content.
    Returns:
        combined string
    rV   c                 H    | d   dz   dt        | d         z  z   dz   | d   z   S )Nr   rV   r   r   )rZ   )sections    r$   r   z-assemble_sections_to_string.<locals>.<lambda>  sC    GI.C	*++,  i 	! r&   )r]   r   )r   s    r$   assemble_sections_to_stringr     s'     99!
 	
	 	r&   seq	predicatec                     t        t        d t        fdt        t	        t        |             |                         }|sy|d   S )a$  
    find index of element that satisfies first condition from left to right
    Args:
        seq: iterable to check with predicate
        predicate: predicate function to determine whether a match occurred or not

    Returns:
        index of first matching element, if no match None
    c                     | d   S r   r!   r   s    r$   r   zfind_index.<locals>.<lambda>  r   r&   c                      | d         S )NrT   r!   )r   r   s    r$   r   zfind_index.<locals>.<lambda>  s    Yqt_ r&   Nr   )rH   r   r   r   r   rZ   )r   r   indicess    ` r$   
find_indexr     sF     ,c%C/3.GH	
G 1:r&   c                 N    dt         dt        dt        fd}t        | ||||      S )Nr   r>   r   c                 D   t        |      }t        |d       }|J |j                  |ddd       |j                  |ddd       | j                  }|j                  |dd| dd       d|v sd	|v r|j                  |dd
d       d|v r|j                  |ddd       d|v sd|v r|j                  |ddd       dd l}dddt
        j                  gg dd}dddt
        j                  dgg dd}d}d}	|dv r||}}|	|}	}|dv r7dddt
        j                  gg dd}dddt
        j                  dgg dd}d}d}	 |j                  d*i |}
 |j                  d*i |}t        |
|      sJ  t        |
|      |      }|dv r|j                  t              }d |dd g<   d!|z   d"z   }|d#z  }|t        |
      d"z   z  }|d$|	z   d"z   z  }|d%z  }|t        |      d"z   z  }|d&| d'z  }|t        |      d"z   z  }t        |d(       }|J d)|d||<   t        |      S )+Nc                     | d   dk(  S Nr   Examplesr!   ss    r$   r   z@_create_operator_docstring.<locals>.modify_doc.<locals>.<lambda>      q|z/I r&   CautionzXSnowpark pandas API does not support `fill_value` and `level` except for default values.r   zXSnowpark pandas API denotes invalid numeric results with `None` while pandas uses `NaN`.z{In Snowpark pandas API, whenever a binary operation involves a NULL value, the result will preserve NULL values, e.g. NULL.z(<other>) will yield NULL.floordivtruedivzSnowpark pandas API will always produce a division by zero error if the right hand side contains one or more zeroes. This is different from pandas which only produces a ZeroDivisionError exception when ``dtype='object'``.powa  In Snowpark pandas API, zero raised to negative powers produces `inf` value as the result while pandas raises a ValueError. In Snowpark pandas API, `None` raised to `0` and `1` raised to `None` produce `1.0` as the result. pandas produces `np.nan` for both cases.modrmoda  
                    Snowpark pandas API computes `mod` differently from pandas and Python. Snowpark pandas API only supports numeric data with the `mod` operator. Below is a table highlighting the differences in modulo computation for Python, pandas, and Snowpark pandas.
                    +---------------------------+---------------------------+---------------------------+
                    | Python                    | pandas                    | Snowpark pandas           |
                    +---------------------------+---------------------------+---------------------------+
                    |  7 %  5 =  2              |  7 %  5 =  2              |  7 %  5 =  2              |
                    +---------------------------+---------------------------+---------------------------+
                    |  7 % -5 = -3              |  7 % -5 = -3              |  7 % -5 =  2              |
                    +---------------------------+---------------------------+---------------------------+
                    | -7 %  5 =  3              | -7 %  5 =  3              | -7 %  5 = -2              |
                    +---------------------------+---------------------------+---------------------------+
                    | -7 % -5 = -2              | -7 % -5 = -2              | -7 % -5 = -2              |
                    +---------------------------+---------------------------+---------------------------+
                    r   rT   )abcd)dataindex   )r  r  r  r  fz9pd.Series([1, -2, 0, np.nan], index=['a', 'b', 'c', 'd'])zApd.Series([-2, 1, 3, np.nan, 1], index=['a', 'b', 'c', 'd', 'f']))rtruediv	rfloordiv)r  r  rU   z8pd.Series([1, 2, 0, np.nan], index=['a', 'b', 'c', 'd'])z@pd.Series([2, 1, 3, np.nan, 1], index=['a', 'b', 'c', 'd', 'f']))eqnegelegtltr  r  z>>> a = rV   z>>> a
z>>> b = z>>> b
z>>> a.z(b)
c                     | d   dk(  S r  r!   r  s    r$   r   z@_create_operator_docstring.<locals>.modify_doc.<locals>.<lambda>E  r  r&   r  r!   )r   r   insertr'   r   npnanSerieshasattrr   astyper   r   r   )r   r>   r   r  op_namepda_datab_dataa_docb_docr  r  ansr   s                 r$   ry   z._create_operator_docstring.<locals>.modify_doc  s   #C( 8%IJ   $u	
 	$u	
 //$CCJ)Keg	
  I$8OO(   GOO(  i Gv0OO( : 	 b!RVV,7KLq!RVVQ/:STKS //#VFF %5E o% !Q/:NOF !Q2=VWFNEVEBIIBIIq'"""!ga!!$ ::**V$C"Cc
Ou$t+93q6D= :%,,93q6D= VG9E**3s8d?" 8%IJ   &0WE*844r&   )r   rv   ry   )r   r   r   )r   r   r   rv   ry   s        r$   _create_operator_docstringr.    s?    I56 I5 I5 I5V - r&   	modin_objc                 "    | j                         S )a:  
    Convert a Modin DataFrame/Series to a pandas DataFrame/Series.

    Parameters
    ----------
    modin_obj : modin.DataFrame, modin.Series
        The Modin DataFrame/Series to convert.

    Returns
    -------
    pandas.DataFrame or pandas.Series
        Converted object with type depending on input.
    )r%   )r/  s    r$   r.   r.   U  s     !!r&   c                 T    t        | d      sy	 t        |        y# t        $ r Y yw xY w)z
    Return whether the `obj` is hashable.

    Parameters
    ----------
    obj : object
        The object to check.

    Returns
    -------
    bool
    __hash__FT)r%  hash	TypeErrorr   s    r$   hashabler5  f  s6     3
#S	   s    	''squeezec           	      b   t        | t              r&| j                         }|r|j                  d      }|S t        | t              r[| j                         }|r|j                  d      }t        t        |dd      t              r|j                  t        k(  rd|_        |S t        | t        t        f      r* t        |       | D cg c]  }t        ||       c}      S t        | t              r/| j                         D ci c]  \  }}|t        ||       c}}S t!        |       rxt        | dd      }|dgn|j#                  d      }t        | d	d      }|rF|d
   dk(  r>|d   dk(  rt        t$        j&                  ||       S t        t$        j(                  ||       S | S c c}w c c}}w )a  
    Convert `obj` and all nested objects from Modin to pandas if it is possible.

    If no convertion possible return `obj`.

    Parameters
    ----------
    obj : object
        Object to convert from Modin to pandas.
    squeeze : bool, default: False
        Squeeze the converted object(s) before returning them.

    Returns
    -------
    object
        Converted object.
    rT   )axisr   N)r6  r(   rS   r|   r'   r   modinrW   	dataframe)rG   r   r%   r6  r,   r.   r   r   r   MODIN_UNNAMED_SERIES_LABELrH   r   typetry_cast_to_pandasr   r   r   r   r   	DataFramer$  )r   r6  resultokvmodule_hierarchyfn_names           r$   r=  r=    s   $ #./!^^^+F#-.^^^+F wvvt4c:99FK#e}%tCy#NQ,Q@NOO#tFIiikRda%a99RR}"3d;$,RD2B2H2H2M 	 #z40'*g5 $B';6 (('37 V]]GS9
 J ORs   F&F+T)skipnar   rE  c                     dt         dt        fd}g }|D ]@  }| r	 ||      rt        |t              r|j	                  |       0|j                  |       B |S )a  
    Wrap a sequence of passed values in a flattened list.

    If some value is a list by itself the function appends its values
    to the result one by one instead inserting the whole list object.

    Parameters
    ----------
    *args : tuple
        Objects to wrap into a list.
    skipna : bool, default: True
        Whether or not to skip nan or None values.

    Returns
    -------
    list
        Passed values wrapped in a list.
    r@  r   c                 \    | d u xs' t        | t              xr t        j                  |       S r    )rG   floatr"  isnan)r@  s    r$   rI  zwrap_into_list.<locals>.isnan  s%    DyBZ51AbhhqkBr&   )r   r   rG   rH   extendrL   )rE  r   rI  resr@  s        r$   wrap_into_listrL    sa    (C C C C eAhaJJqMJJqM Jr&   rm   c                 Z     dt         dt         dt         f fd} j                  |_        |S )z
    Create a decorator that makes `func` return pandas objects instead of Modin.

    Parameters
    ----------
    func : callable
        Function to wrap.

    Returns
    -------
    callable
    r   rQ   r   c                  *     | i |}t        |      S r    )r=  )r   rQ   r?  rm   s      r$   wrapperz"wrap_udf_function.<locals>.wrapper  s    t&v& "&))r&   )r   r'   )rm   rO  s   ` r$   wrap_udf_functionrP    s0    *s *c *c * }}GNr&   _classc                      |        S )a=  
    Create a dummy instance each time this is imported.

    This serves the purpose of allowing us to use all of pandas plotting methods
    without aliasing and writing each of them ourselves.

    Parameters
    ----------
    _class : object

    Returns
    -------
    object
        Instance of `_class`.
    r!   )rQ  s    r$   	instancerrS    s      8Or&   r   c                 |    	 t        j                  |       S # t        $ r t        d|  d| dd|  dz         dw xY w)a  
    Import an optional dependecy.

    Parameters
    ----------
    name : str
        The module name.
    message : str
        Additional text to include in the ImportError message.

    Returns
    -------
    module : ModuleType
        The imported module.
    zMissing optional dependency 'z'. rF   zUse pip or conda to install r|   N)r   r   ImportError)r   rk   s     r$   import_optional_dependencyrV    s\     &&t,, +D6WIQ?,TF!45
 	s    $;ra   c                 &    t        |       t        k(  S )z"Check whether `key` is a property.)r<  r   )ra   s    r$   is_propertyrX    s    9  r&   param	conditionc                 8    |rt        j                  |  d       y)aV  
    Raises a ``NotImplementedError`` for a parameter ``param``
    when its argument ``arg`` is not None.

    Parameters
    ----------
    param : str
    Name of the parameter that is not implemented.

    arg : Any
    Value of the parameter that is not implemented.

    Raises
    ------
    NotImplementedError if ``arg`` is None
    z is not implemented.N)r   not_implemented)rY  rZ  s     r$   error_not_implemented_parameterr]    s     $ $$w.B%CDr&   fnc                 8    |rt        j                  || d       yy)aj  
    Invokes ``WarningMessage.ignored_argument`` for parameter ``param``
    of function ``fn`` if its argument ``arg`` is not None.

    Parameters
    ----------
    param : str
    Name of the parameter that has been ignored.

    arg : Any
    Value of the parameter that has been ignored.

    fn : str
    Name of the function with parameter ``param``
    rS   N)r   ignored_argument)rY  rZ  r^  s      r$   warn_not_supported_parameterra  7  s    " ''E26 r&   headerinfernamesc                 (    | dv xr |du xs | dk(  }|S )a  
    Returns whether the first row of a CSV file is used as
    the column names for a DataFrame.

    Parameters
    ----------
    header : int, list of int, None
    Row number(s) to use as the column names, and the start of the
    data.

    names : array-like
    List of column names to use.

    Returns
    -------
    Whether the first row of the CSV file will be used as column names.
    )rc  r   Nr   r!   )rb  rd  should_parse_first_rows      r$   should_parse_headerrg  L  s(    , $|3V$9U&TU+!!r&   argc                     | t         u rdS | S )z
    Returns None if `arg` is no_default, otherwise `arg`.

    Parameters
    ----------
    arg : Any
    Argument `arg` to be translated.

    Returns
    -------
    None if `arg` is no_default, otherwise the original
    value of `arg`.
    N)r   )rh  s    r$   translate_pandas_defaultrj  g  s     *$4-#-r&   rb   arg_namefloat_allowedc                     t        |       s|r&t        |       r| j                         rt        |       S t        | d      )a  
    check whether the argument passed is integer type

    Parameters
    ----------
    value : int
        The integer value to be validated
    arg_name: str
        Name of the argument. To be reflected in the error message.
    float_allowed: bool
        Whether allow integer value to be represented in float, for example, 1.0.
        However, values like 2.3 is not valid.

    Returns
    -------
    Integer representation of the value.

    ValueError is raised if the value is not a valid integer
    z must be an integer)r   r   int
ValueError)rb   rk  rl  s      r$   validate_int_kwargrp  y  s<    ( %]x5CSCSCU5z
z!45
66r&   _objc                 0    t        j                  dd|      S )a/  
    Helper function to be passed as the `modify_doc` parameter to `_inherit_docstrings`. This replaces
    all unqualified instances of "DataFrame" with ":class:`~modin.pandas.DataFrame`" to
    prevent it from linking automatically to snowflake.snowpark.DataFrame: see SNOW-1233342.

    To prevent it from overzealously replacing examples in doctests or already-qualified paths, it
    replaces matches of DataFrame that are preceded by whitespace and followed by whitespace or a comma
    (to cover cases like "param: Series or DataFrame, optional").
    z(?<=\s)DataFrame(?=[\s,])z :class:`~modin.pandas.DataFrame`)rX   sub)rq  r>   s     r$   doc_replace_dataframe_with_linkrt    s     66$* r&   c                   4    e Zd ZdZdeddfdZdededefdZy)	classpropertyaD  
    Decorator that allows creating read-only class properties.

    Parameters
    ----------
    func : method

    Examples
    --------
    >>> class A:
    ...     field = 10
    ...     @classproperty
    ...     def field_x2(cls):
    ...             return cls.field * 2
    ...
    >>> print(A.field_x2)
    20
    rm   r   Nc                     || _         y r    r   )r#   rm   s     r$   __init__zclassproperty.__init__  s	    	r&   instanceownerc                 $    | j                  |      S r    rx  )r#   rz  r{  s      r$   __get__zclassproperty.__get__  s    yyr&   )r'   r(   r)   r*   r   ry  r}  r!   r&   r$   rv  rv    s4    &S T    C  C  r&   rv  )NNN)r   N)F)`r*   r   r   r   r   rX   r   collections.abcr   r   pathlibr   textwrapr   r   typingr   r	   r
   r   r   r   r   r   r   numpyr"  r   pandas._libs.libr   r   pandas.core.dtypes.inferencer   r   pandas.util._decoratorsr   snowflake.snowpark.modin.configr   3snowflake.snowpark.modin.plugin.utils.error_messager   5snowflake.snowpark.modin.plugin.utils.warning_messager   r   r   r   r,   r1   r5   __version__r;   r;  r   r=   rn  rC   rH   r@   rf   rj   rr   r   r   r   r   __annotations__r   r   r   r<  r   r   r   r   	subscriber   r   r   r   r   r.  r.   r5  r=  rL  rP  rS  
ModuleTyperV  rX  r]  ra  rg  rj  rp  rt  rv  r!   r&   r$   <module>r     s  , H    	 	  .  #
 
 
   2 = , 5 L PCL T" [ h   X   H   X   K6K]K]J^^vw * 1 1 1**S *S *$tSy) d <<%C <%3 <%3 <%~/# /s /s /* 2$(); 4  $#9=a!a!a! a! eCcN+,	a!
 a! }a! 63-"456a! 
a!P =? d8SE4K#89 > ?Be $c%c	*:&; C6 d :Y :4 :JG 
JG^  $/39=996l9 9 eCcN+,	9
 63-"4569 rdBh9x 	  0 1$ $2$(); $N63 64S#X#7 6r$tCH~*> 3 ,HSM h 8C= 2  $/3	WW6lW W eCcN+,	W
 rdBhWv"0 "S ""$ 4 22C 2$ 23 2j /3 # t tCy DH  0hr1uo ! &S 3 5;K;K 2!S !T !
3 4 HXDV 07 7 7# 7$ 7*"U3ww/??@A"E(8,i789" 
"6.# .# .$7c 7S 7 7RU 74# C C "   r&   