U
    ¿mœd�ƒ  ã                u   @  s$
  U d dl mZ d dlZd dlmZ d dlmZ d dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZmZmZmZmZmZ d dlZd dlmZmZmZ d dlmZmZmZ d d	lmZ d d
lm Z m!Z!m"Z"m#Z#m$Z$m%Z% d dl&Z'd dl&m(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 d dl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z;m<Z< d dl=m>Z>m?Z? d dl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZW d dlXmYZYmZZZ d dl[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZb d dlcmdZdmeZemfZf d dlgmhZh d dlimjZj e�r8d dl&mkZkmlZl d dlcmmZm dZndZoddddgZpdeqd< dd d!d"gZrd#eqd$< esd%d&d'd(gZtdeqd)< d*d+d,d-gZud#eqd.< epet Zvereu Zwevew•Zxd#eqd/< eyd0d1gZzdeqd2< d3d4gZ{d#eqd5< eze{•Z|d#eqd6< e}d7d8gZ~d#eqd9< ed:d;gZ€d#eqd<< d=d>gZ�d#eqd?< d@dAgZ‚d#eqdB< eƒdCgZ„d#eqdD< e…dEgZ†d#eqdF< e‡dGgZˆd#eqdH< ezev Z‰e{ew ZŠe‰eŠ•Z‹d#eqdI< e‹e~•ZŒd#eqdJ< e‰e~ e€ e� e‚ e„ eˆ e† Z�ejŽej�ej�ej‘ej’ej“ej”ej•gZ–dKdLdMœe Z—dej˜e'j™eydNƒe'jšedOƒgZ›dPdQ„ ejœej�fD ƒZže�s.d dlŸZ e  “¡ e  ”¡ e  •¡ e  ¡¡ gZ¢e  �¡ e  ‘¡ e  ’¡ e  £¡ gZ¤e¢e¤ Z¥dRdQ„ e¥D ƒZ¦e  �¡ e  §¡ gZ¨dSdQ„ e¨D ƒZ©e  ªdTdU¡gZ«e  	¡ gZ¬e  ­¡ gZ®e  ¯dV¡e  ¯dW¡e  °dX¡e  °dY¡gZ±e  ²¡ e  ³¡ gZ´dZdQ„ d[D ƒZµd\dQ„ d[D ƒZ¶e  ·¡ gZ¸e¥e¨ e« e¬ e® e± e´ eµ e¶ e¸ Z¹ng Z©g Z¦g Z¹e ºd]¡Z»d^d_œd`da„Z¼dCd_œdbdc„Z½�d-dCdeœdfdg„Z¾dhdi„ Z¿d:d_œdjdk„ZÀ�d.dmdndoœdpdq„ZÁ�d/dmdmdrdsœdtdu„ZÂ�d0dmdvdoœdwdx„ZÃ�d1dmdndoœdydz„ZÄ�d2dd{œdmd|dnd}œd~d„ZÅ�d3dd(d€œdmd�dnd}œd‚dƒ„ZÆ�d4ddd€œdmd�dnd}œd„d…„ZÇ�d5dmd†doœd‡dˆ„ZÈ�d6dd1d€œdmd�dnd}œd‰dŠ„ZÉ�d7dmdŒd�dŽœd�d�„ZÊ�d8dmdŒd’dŽœd“d”„ZË�d9dmd•doœd–d—„ZÌ�d:dmd˜œd™dš„ZÍd›dœ„ ZÎ�d;dmd�doœdždŸ„ZÏdej§fd d_œd¡d¢„ZÐ�d<d d_œd£d¤„ZÑ�d=d d_œd¥d¦„ZÒ�d>d d_œd§d¨„ZÓd©d_œdªd«„ZÔ�d?dŒd d¬œd­d®„ZÕ�d@d d_œd¯d°„ZÖ�dAdŒd©d¬œd±d²„Z×�dBd©d_œd³d´„ZØ�dCdŒdµd¬œd¶d·„ZÙdµd_œd¸d¹„ZÚdºd»„ ZÛdµd_œd¼d½„ZÜ�dDdµd_œd¾d¿„ZÝ�dEd:dÂdndÃœdÄdÅ„ZÞ�dFdÇdÇdmdmdµdÈœdÉdÊ„Zß�dGdËdÌœdÍdÎ„Zà�dHdËdµdÐœdÑdÒ„ZáG dÓdÔ„ dÔe1ƒZâG dÕdÖ„ dÖe+ƒZãG d×dØ„ dØe)ƒZä�dIdÙdÚ„ZådÛd:dÜœdÝdÞ„Zædßdàdáœdâdã„Zçe'jèjéjê ë¡ Zìdädå„ Zíd:dædçœdèdé„Zîdêdë„ Zïdìdí„ Zðdîdï„ Zñdðdñ„ Zòdòdó„ Zódôdõ„ ZôdCd_œdöd÷„ZõdødùdúdûdŸdüdýdþdÿ�d �d�d�d�d�d�d�d�d�d	�d
�d�d�d�d�d�d�d�ddódDdgdF�d�dd9dÞd?�d�d�d�d�ddcdãd5d2dkdå�ddë�dd»�ddéd´d«d²dõdñdœdïdzdudÊdÅd¹d�dŠd¤dxdƒdÒd½dšdd¨d¿d—d°d¢dˆdqd¦d·d”d®d…�d�d�d�d �d!dH�d"�d#da�d$�d%�d&�d'dí�d(�d)d÷d.d)d<dØdÖdÔdBdid$d�d*�d+�d,guZödS (J  é    )ÚannotationsN)Údatetime)ÚDecimal)Ú	byteorder)ÚTYPE_CHECKINGÚCallableÚContextManagerÚCounterÚIterableÚcast)Úcan_set_localeÚget_localesÚ
set_locale)ÚDtypeÚ	FrequencyÚNpDtype)Úpa_version_under7p0)Úis_float_dtypeÚis_integer_dtypeÚis_sequenceÚis_signed_integer_dtypeÚis_unsigned_integer_dtypeÚpandas_dtype)Ú
ArrowDtypeÚCategoricalÚCategoricalIndexÚ	DataFrameÚDatetimeIndexÚIndexÚIntervalIndexÚ
MultiIndexÚ
RangeIndexÚSeriesÚbdate_range)ÚcloseÚnetworkÚround_trip_localpathÚround_trip_pathlibÚround_trip_pickleÚwrite_to_compressed)ÚrandsÚrands_array)Úassert_produces_warningÚmaybe_produces_warning)Úassert_almost_equalÚassert_attr_equalÚassert_categorical_equalÚassert_class_equalÚassert_contains_allÚassert_copyÚassert_datetime_array_equalÚassert_dict_equalÚassert_equalÚassert_extension_array_equalÚassert_frame_equalÚassert_index_equalÚ!assert_indexing_slices_equivalentÚassert_interval_array_equalÚassert_is_sortedÚ"assert_is_valid_plot_return_objectÚassert_metadata_equivalentÚassert_numpy_array_equalÚassert_period_array_equalÚassert_series_equalÚassert_sp_array_equalÚassert_timedelta_array_equalÚraise_assert_detail)Ú	get_dtypeÚget_obj)Údecompress_fileÚensure_cleanÚ!ensure_safe_environment_variablesÚraises_chained_assignment_errorÚset_timezoneÚuse_numexprÚwith_csv_dialect)ÚBaseMaskedArrayÚExtensionArrayÚPandasArray)ÚNDArrayBackedExtensionArray)Úextract_array)ÚPeriodIndexÚTimedeltaIndex)ÚArrowExtensionArrayé   é   Úuint8Úuint16Úuint32Úuint64zlist[NpDtype]ÚUNSIGNED_INT_NUMPY_DTYPESZUInt8ZUInt16ZUInt32ZUInt64zlist[Dtype]ÚUNSIGNED_INT_EA_DTYPESÚint8Úint16Úint32Úint64ÚSIGNED_INT_NUMPY_DTYPESZInt8ZInt16ZInt32ZInt64ÚSIGNED_INT_EA_DTYPESÚALL_INT_DTYPESÚfloat32Úfloat64ÚFLOAT_NUMPY_DTYPESZFloat32ZFloat64ÚFLOAT_EA_DTYPESÚALL_FLOAT_DTYPESZ	complex64Z
complex128ÚCOMPLEX_DTYPESÚstrÚUÚSTRING_DTYPESzdatetime64[ns]zM8[ns]ÚDATETIME64_DTYPESztimedelta64[ns]zm8[ns]ÚTIMEDELTA64_DTYPESÚboolÚBOOL_DTYPESÚbytesÚBYTES_DTYPESÚobjectÚOBJECT_DTYPESÚALL_REAL_DTYPESÚALL_NUMERIC_DTYPESú<ú>)ÚlittleÚbigÚnanÚNaNc                 C  s    g | ]}d D ]}|d|ƒ‘qqS ))ÚYÚMÚWÚDÚhÚmÚsÚmsÚusÚnsZpsÚfsÚasÚNaT© )Ú.0ÚclsÚunitr‹   r‹   úQ/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/pandas/_testing/__init__.pyÚ
<listcomp>¶   s    þr�   c                 C  s   g | ]}t t|ƒƒ‘qS r‹   ©rk   r   ©rŒ   Útypr‹   r‹   r�   r�   Ð   s    c                 C  s   g | ]}t t|ƒƒ‘qS r‹   r‘   r’   r‹   r‹   r�   r�   ×   s    é   é   r„   r…   r†   r‡   c                 C  s$   g | ]}d D ]}t j||d�‘qqS ))NÚUTCz
US/Pacificz
US/Eastern)rŽ   Útz)ÚpaÚ	timestamp)rŒ   rŽ   r—   r‹   r‹   r�   r�   å   s    þ)r„   r…   r†   r‡   c                 C  s   g | ]}t  |¡‘qS r‹   )r˜   Úduration)rŒ   rŽ   r‹   r‹   r�   r�   ê   s     z^$ÚNone)Úreturnc                   C  s   t jddd� dS )zJ
    Reset the display options for printing and representing objects.
    z	^display.T)ZsilentN)ÚpdZreset_optionr‹   r‹   r‹   r�   Úreset_display_options  s    rž   c                 C  s   t | ƒt |ƒkS )zO
    Checks if the set of unique elements of arr1 and arr2 are equivalent.
    )Ú	frozenset)Zarr1Zarr2r‹   r‹   r�   ÚequalContents  s    r    T)Ú	transposec                 C  sÌ   |t jkr6t| tƒr&tt | j¡ƒ} qÈt j| dd�} n’|tkrHt| ƒ} n€|t	krZt	| ƒ} nn|t
krŽt	| ƒ ¡ } |rÈ| j} t j| gd dd�} n:|tjks¢|tjkr®t | ¡} n|tkrÀt| ƒ} nt|ƒ‚| S )z÷
    Helper function to wrap the expected output of a test in a given box_class.

    Parameters
    ----------
    expected : np.ndarray, Index, Series
    box_cls : {Index, Series, DataFrame}

    Returns
    -------
    subclass of box_cls
    F©Úcopyé   T)Zignore_index)r�   ÚarrayÚ
isinstancer!   rP   ÚnpÚasarrayÚ_valuesr   r"   r   Zto_frameÚTÚconcatÚndarrayÚto_arrayÚNotImplementedError)ÚexpectedZbox_clsr¡   r‹   r‹   r�   Úbox_expected  s&    




r°   c                 C  s*   t | ddƒ}|dkrt | ¡S t| dd�S )zQ
    Similar to pd.array, but does not cast numpy dtypes to nullable dtypes.
    ÚdtypeNT)Zextract_numpy)Úgetattrr§   r¨   rR   )Úobjr±   r‹   r‹   r�   r­   @  s    
r­   c                 C  s   t jd | … S ©N)ÚstringÚascii_uppercase©Úkr‹   r‹   r�   ÚgetColsQ  s    r¹   é
   Úintr   )r¸   rœ   c                 C  s   t td| d�|d�S )Nrº   )ÚncharsÚsize©Úname)r   r+   ©r¸   r¿   r‹   r‹   r�   ÚmakeStringIndexV  s    rÁ   r   )r¸   Únrœ   c                 K  s6   t d|dd�}ttjt | ¡| |d�fd|i|—ŽS )z%make a length k index or n categoriesrW   F)r¼   r½   Úreplace)Ú
categoriesr¿   )r+   r   r   Z
from_codesr§   Úarange)r¸   rÂ   r¿   ÚkwargsÚxr‹   r‹   r�   ÚmakeCategoricalIndexZ  s    ÿÿÿrÈ   r   c                 K  s*   t jdd| d d�}tj|fd|i|—ŽS )zmake a length k IntervalIndexr   éd   é   )Únumr¿   )r§   Zlinspacer   Zfrom_breaks)r¸   r¿   rÆ   rÇ   r‹   r‹   r�   ÚmakeIntervalIndexd  s    rÌ   c                 C  sL   | dkrt dg|d�S | dkr.t ddg|d�S t ddgdg| d   |d�S )NrÊ   Tr¾   r¤   F)r   rÀ   r‹   r‹   r�   ÚmakeBoolIndexj  s
    rÍ   r¾   zDtype | None)r¸   r±   rœ   c                C  sª   t |ƒ}t|tjƒst‚t|ƒrNtj| |d�}t|ƒrœ|d|jd d  7 }nNt	|ƒrŽtj
 | ¡tj
 d¡ }| ¡  |dtj
 dd¡  }ntd|› �ƒ‚t|||d	�S )
N©r±   r¤   é   rÊ   rº   r   é	   zwrong dtype )r±   r¿   )r   r¦   r§   r±   ÚAssertionErrorr   rÅ   r   Úitemsizer   ÚrandomZrandom_sampleÚsortÚrandintr®   r   )r¸   r¿   r±   Úvaluesr‹   r‹   r�   ÚmakeNumericIndexr  s    r×   ©r¿   r±   r   c                C  s,   t |ƒ}t|ƒstd|› �ƒ‚t| ||d�S ©NzWrong dtype rØ   )r   r   Ú	TypeErrorr×   ©r¸   r¿   r±   r‹   r‹   r�   ÚmakeIntIndex„  s    rÜ   c                C  s,   t |ƒ}t|ƒstd|› �ƒ‚t| ||d�S rÙ   )r   r   rÚ   r×   rÛ   r‹   r‹   r�   ÚmakeUIntIndex‹  s    rÝ   r!   c                 K  s   t d| dfd|i|—ŽS )Nr   rÊ   r¿   )r!   )r¸   r¿   rÆ   r‹   r‹   r�   ÚmakeRangeIndex’  s    rÞ   c                C  s,   t |ƒ}t|ƒstd|› �ƒ‚t| ||d�S rÙ   )r   r   rÚ   r×   rÛ   r‹   r‹   r�   ÚmakeFloatIndex–  s    rß   ÚBr   r   )r¸   Úfreqrœ   c                 K  s0   t dddƒ}t|| ||d�}t|fd|i|—ŽS )NéÐ  rÊ   )Úperiodsrá   r¿   r¿   )r   r#   r   )r¸   rá   r¿   rÆ   ÚdtZdrr‹   r‹   r�   ÚmakeDateIndex�  s    rå   r�   rT   c                 K  s   t jf d| ||dœ|—ŽS )Nz1 day©Ústartrã   rá   r¿   )r�   Ztimedelta_range)r¸   rá   r¿   rÆ   r‹   r‹   r�   ÚmakeTimedeltaIndex¥  s    rè   rS   c                 K  s&   t dddƒ}tjf || d|dœ|—ŽS )Nrâ   rÊ   rà   ræ   )r   r�   Zperiod_range)r¸   r¿   rÆ   rä   r‹   r‹   r�   ÚmakePeriodIndex«  s    ré   r·   c                 K  sJ   | d d }t |ƒ}tjd|gfd|i|—Ž}t|ƒ| ks>t‚|d | … S )Nr¤   rÊ   )ZfooÚbarÚnames)Úranger    Zfrom_productÚlenrÑ   )r¸   rë   rÆ   ÚNÚrngÚmir‹   r‹   r�   ÚmakeMultiIndex°  s
    rñ   c                  c  s    t ttttttg} | E d H  d S r´   )rå   ré   rè   rÞ   rÌ   rÈ   rñ   )Úmake_index_funcsr‹   r‹   r�   Úindex_subclass_makers_generator¸  s    ù	ró   zIterable[Index]c                 c  s$   t ttg}|D ]}|| d�V  qdS )z¿
    Generator which can be iterated over to get instances of all the classes
    which represent time-series.

    Parameters
    ----------
    k: length of each of the index instances
    r·   N)rå   ré   rè   )r¸   rò   Zmake_index_funcr‹   r‹   r�   Úall_timeseries_index_generatorÅ  s    
ýrô   r"   c              	   C  sH   t tƒ}tj t¡}tjdd�� |j|dd�}W 5 Q R X t||| d�S )NÚignore)ÚinvalidFr¢   ©Úindexr¿   )rÁ   Ú_Nr§   rÓ   ÚrandnZerrstateÚastyper"   )r¿   r±   rø   Údatar‹   r‹   r�   Úmake_rand_seriesØ  s
    rý   c                 C  s
   t | d�S ©Nr¾   ©rý   r¾   r‹   r‹   r�   ÚmakeFloatSeriesà  s    r   c                 C  s
   t | d�S rþ   rÿ   r¾   r‹   r‹   r�   ÚmakeStringSeriesä  s    r  c                 C  s*   t tƒ}t|td�}t tƒ}t||| d�S )NrÎ   r÷   )rÁ   rù   r   rt   r"   )r¿   rü   rø   r‹   r‹   r�   ÚmakeObjectSeriesè  s    r  zdict[str, Series]c                     s   t tƒ‰ ‡ fdd„ttƒD ƒS )Nc                   s"   i | ]}|t tj t¡ˆ d �“qS )©rø   )r"   r§   rÓ   rú   rù   ©rŒ   Úcr  r‹   r�   Ú
<dictcomp>ñ  s      z!getSeriesData.<locals>.<dictcomp>)rÁ   rù   r¹   Ú_Kr‹   r‹   r  r�   ÚgetSeriesDataï  s    r  )rá   rœ   c                 C  s*   | d krt } ttj | ¡t| |d�|d�S )N)rá   r÷   )rù   r"   r§   rÓ   rú   rå   )Únperrá   r¿   r‹   r‹   r�   ÚmakeTimeSeriesô  s    
 
 ÿr
  c                 C  s&   | d krt } ttj | ¡t| ƒ|d�S )Nr÷   )rù   r"   r§   rÓ   rú   ré   )r	  r¿   r‹   r‹   r�   ÚmakePeriodSeriesü  s    r  c                   s   ‡ ‡fdd„t tƒD ƒS )Nc                   s   i | ]}|t ˆˆ ƒ“qS r‹   )r
  r  ©rá   r	  r‹   r�   r    s      z%getTimeSeriesData.<locals>.<dictcomp>©r¹   r  )r	  rá   r‹   r  r�   ÚgetTimeSeriesData  s    r  c                   s   ‡ fdd„t tƒD ƒS )Nc                   s   i | ]}|t ˆ ƒ“qS r‹   )r  r  ©r	  r‹   r�   r    s      z!getPeriodData.<locals>.<dictcomp>r  r  r‹   r  r�   ÚgetPeriodData  s    r  r   c                 C  s   t | |ƒ}t|ƒS r´   )r  r   )r	  rá   rü   r‹   r‹   r�   ÚmakeTimeDataFrame  s    
r  c                  C  s   t ƒ } t| ƒS r´   )r  r   )rü   r‹   r‹   r�   ÚmakeDataFrame  s    r  c                  C  sN   t dddddgƒ} dddd	d
gdddddgdddddgtddd�dœ}| |fS )NÚaÚbr  ÚdÚeg        ç      ð?g       @g      @g      @Zfoo1Zfoo2Zfoo3Zfoo4Zfoo5z1/1/2009é   )rã   )ÚArà   ÚCr�   )r   r#   )rø   rü   r‹   r‹   r�   ÚgetMixedTypeDict  s    
ür  c                   C  s   t tƒ d ƒS )NrÊ   )r   r  r‹   r‹   r‹   r�   ÚmakeMixedDataFrame"  s    r  c                 C  s   t | ƒ}t|ƒS r´   )r  r   )r	  rü   r‹   r‹   r�   ÚmakePeriodFrame&  s    r  ú#Fzbool | str | list[str] | None)Úprefixrë   rœ   c                   sd  |dkrdg| }t |ƒr&t|ƒ|ks*t‚|dksR|dksR|dksRt|ƒ|ksRt‚|dksn|dkrj|dksnt‚|dkrŒ‡ fdd„t|ƒD ƒ}|dkr˜d}t|tƒr°|dkr°|g}tttt	t
tdœ}| |¡}|rê|| ƒ}|ræ|d	 |_|S |dk	�rtt|ƒ› d
�ƒ‚t|ƒ|k �r,| dg|t|ƒ  ¡ t|ƒ|k�s>t‚tdd„ |D ƒƒ�sVt‚g }	t|ƒD ]x}
dd„ }| ||
  d }t ¡ }t|ƒD ]&}ˆ › d|
› d|› �}||
 ||< �qŽt| ¡ |d�d| … }|	 |¡ �qbtt|	Ž ƒ}| dk�r|dk�r dn|d	 }t|d	 |d�}nF|dk�rR|dk�r2dn|d	 }tdd„ |D ƒ|d�}ntj||d�}|S )aÒ  
    Create an index/multindex with given dimensions, levels, names, etc'

    nentries - number of entries in index
    nlevels - number of levels (> 1 produces multindex)
    prefix - a string prefix for labels
    names - (Optional), bool or list of strings. if True will use default
       names, if false will use no names, if a list is given, the name of
       each level in the index will be taken from the list.
    ndupe_l - (Optional), list of ints, the number of rows for which the
       label will repeated at the corresponding level, you can specify just
       the first few, the rest will use the default ndupe_l of 1.
       len(ndupe_l) <= nlevels.
    idx_type - "i"/"f"/"s"/"dt"/"p"/"td".
       If idx_type is not None, `idx_nlevels` must be 1.
       "i"/"f" creates an integer/float index,
       "s" creates a string
       "dt" create a datetime index.
       "td" create a datetime index.

        if unspecified, string labels will be generated.
    NrÊ   FT)ÚiÚfr„   Úurä   ÚpÚtdc                   s   g | ]}ˆ t |ƒ ‘qS r‹   )rk   )rŒ   r   ©r  r‹   r�   r�   S  s     z#makeCustomIndex.<locals>.<listcomp>)r   r!  r„   rä   r$  r#  r   zE is not a legal value for `idx_type`, use  'i'/'f'/'s'/'dt'/'p'/'td'.c                 s  s   | ]}|d kV  qdS ©r   Nr‹   ©rŒ   rÇ   r‹   r‹   r�   Ú	<genexpr>v  s     z"makeCustomIndex.<locals>.<genexpr>c                 S  s"   t  dd| ¡ d¡}dd„ |D ƒS )Nz[^\d_]_?Ú Ú_c                 S  s   g | ]}t |ƒ‘qS r‹   )r»   )rŒ   rË   r‹   r‹   r�   r�   }  s     z4makeCustomIndex.<locals>.keyfunc.<locals>.<listcomp>)ÚreÚsubÚsplit)rÇ   Znumeric_tupler‹   r‹   r�   Úkeyfunc{  s    z makeCustomIndex.<locals>.keyfuncZ_lZ_g)Úkeyr¾   c                 s  s   | ]}|d  V  qdS r&  r‹   r'  r‹   r‹   r�   r(  •  s     )rë   )r   rí   rÑ   rì   r¦   rk   rÜ   rß   rÁ   rå   rè   ré   Úgetr¿   Ú
ValueErrorÚreprÚextendÚallÚcollectionsr	   ÚsortedÚelementsÚappendÚlistÚzipr   r    Úfrom_tuples)ZnentriesÚnlevelsr  rë   Úndupe_lÚidx_typeZidx_func_dictZidx_funcÚidxZlist_of_listsr   r.  Z
div_factorZcntÚjÚlabelÚresultZtuplesr¿   rø   r‹   r%  r�   ÚmakeCustomIndex+  sn    
(ÿÿú


ÿ

rC  rÊ   zbool | list[str])Úc_idx_namesÚr_idx_namesÚc_idx_nlevelsÚr_idx_nlevelsrœ   c                   s°   |dkst ‚|dkst ‚|dks4|dkr0|dks4t ‚|
dksP|
dkrL|dksPt ‚tˆ|d|||
d�}t| |d|||d�}ˆ dkrˆdd	„ ‰ ‡ ‡fd
d„t| ƒD ƒ}t||||	d�S )a‡
  
    Create a DataFrame using supplied parameters.

    Parameters
    ----------
    nrows,  ncols - number of data rows/cols
    c_idx_names, r_idx_names  - False/True/list of strings,  yields No names ,
            default names or uses the provided names for the levels of the
            corresponding index. You can provide a single string when
            c_idx_nlevels ==1.
    c_idx_nlevels - number of levels in columns index. > 1 will yield MultiIndex
    r_idx_nlevels - number of levels in rows index. > 1 will yield MultiIndex
    data_gen_f - a function f(row,col) which return the data value
            at that position, the default generator used yields values of the form
            "RxCy" based on position.
    c_ndupe_l, r_ndupe_l - list of integers, determines the number
            of duplicates for each label at a given level of the corresponding
            index. The default `None` value produces a multiplicity of 1 across
            all levels, i.e. a unique index. Will accept a partial list of length
            N < idx_nlevels, for just the first N levels. If ndupe doesn't divide
            nrows/ncol, the last label might have lower multiplicity.
    dtype - passed to the DataFrame constructor as is, in case you wish to
            have more control in conjunction with a custom `data_gen_f`
    r_idx_type, c_idx_type -  "i"/"f"/"s"/"dt"/"td".
        If idx_type is not None, `idx_nlevels` must be 1.
        "i"/"f" creates an integer/float index,
        "s" creates a string index
        "dt" create a datetime index.
        "td" create a timedelta index.

            if unspecified, string labels will be generated.

    Examples
    --------
    # 5 row, 3 columns, default names on both, single index on both axis
    >> makeCustomDataframe(5,3)

    # make the data a random int between 1 and 100
    >> mkdf(5,3,data_gen_f=lambda r,c:randint(1,100))

    # 2-level multiindex on rows with each label duplicated
    # twice on first level, default names on both axis, single
    # index on both axis
    >> a=makeCustomDataframe(5,3,r_idx_nlevels=2,r_ndupe_l=[2])

    # DatetimeIndex on row, index with unicode labels on columns
    # no names on either axis
    >> a=makeCustomDataframe(5,3,c_idx_names=False,r_idx_names=False,
                             r_idx_type="dt",c_idx_type="u")

    # 4-level multindex on rows with names provided, 2-level multindex
    # on columns with default labels and default names.
    >> a=makeCustomDataframe(5,3,r_idx_nlevels=4,
                             r_idx_names=["FEE","FIH","FOH","FUM"],
                             c_idx_nlevels=2)

    >> a=mkdf(5,3,r_idx_nlevels=2,c_idx_nlevels=4)
    r   N)r   r!  r„   rä   r#  r$  rÊ   r  )r<  r  rë   r=  r>  ÚRc                 S  s   d| › d|› �S )NrH  r  r‹   )Úrr  r‹   r‹   r�   Ú<lambda>ÿ  ó    z%makeCustomDataframe.<locals>.<lambda>c                   s$   g | ]‰ ‡‡ fd d„t ˆƒD ƒ‘qS )c                   s   g | ]}ˆ ˆ|ƒ‘qS r‹   r‹   r  )Ú
data_gen_frI  r‹   r�   r�     s     z2makeCustomDataframe.<locals>.<listcomp>.<listcomp>)rì   )rŒ   ©rL  Úncols)rI  r�   r�     s     z'makeCustomDataframe.<locals>.<listcomp>rÎ   )rÑ   rC  rì   r   )ÚnrowsrN  rD  rE  rF  rG  rL  Z	c_ndupe_lZ	r_ndupe_lr±   Z
c_idx_typeZ
r_idx_typeÚcolumnsrø   rü   r‹   rM  r�   ÚmakeCustomDataframe›  s@    Hÿÿÿÿúú
rQ  Úfloat)Údensityc                   s¼   |d krt j}nt j |¡}td| ˆ ˆ  ƒ‰d}d}tˆ| |ˆ ƒ}‡ ‡‡fdd„}|||ƒ}|jˆk r‚|d9 }|||ƒ}qdt  |d ˆ ¡ t¡}	||	ˆ   t¡}
|
 	¡ |	 	¡ fS )NrÊ   r  gR¸…ëQð?c                   s.   |   t|ƒ¡}t t |ˆ ˆ  ¡¡d ˆ… S r´   )Zrandr»   r§   ÚuniqueÚfloor)rï   Z_extra_sizeÚind©rN  rO  r½   r‹   r�   Ú_gen_unique_rand  s    z-_create_missing_idx.<locals>._gen_unique_randgÍÌÌÌÌÌð?r  )
r§   rÓ   ZRandomStateÚroundÚminr½   rU  rû   r»   Útolist)rO  rN  rS  Úrandom_stateZmin_rowsZfacÚ
extra_sizerX  rV  r@  r   r‹   rW  r�   Ú_create_missing_idx  s    

r^  çÍÌÌÌÌÌì?)rS  rœ   c                 C  s0   t ƒ }t|j| |dœŽ\}}tj|j||f< |S )N)rS  r\  )r  r^  Úshaper§   r|   Úiloc)rS  r\  Zdfr   r@  r‹   r‹   r�   ÚmakeMissingDataframe!  s    rb  c                   @  s,   e Zd ZddgZedd„ ƒZedd„ ƒZdS )ÚSubclassedSeriesÚtestattrr¿   c                 C  s   dd„ S )Nc                  _  s
   t | |ŽS r´   ©rc  ©ÚargsrÆ   r‹   r‹   r�   rJ  2  rK  z/SubclassedSeries._constructor.<locals>.<lambda>r‹   ©Úselfr‹   r‹   r�   Ú_constructor+  s    zSubclassedSeries._constructorc                 C  s   dd„ S )Nc                  _  s
   t | |ŽS r´   ©ÚSubclassedDataFramerf  r‹   r‹   r�   rJ  6  rK  z9SubclassedSeries._constructor_expanddim.<locals>.<lambda>r‹   rh  r‹   r‹   r�   Ú_constructor_expanddim4  s    z'SubclassedSeries._constructor_expanddimN)Ú__name__Ú
__module__Ú__qualname__Ú	_metadataÚpropertyrj  rm  r‹   r‹   r‹   r�   rc  (  s
   
rc  c                   @  s*   e Zd ZdgZedd„ ƒZedd„ ƒZdS )rl  rd  c                 C  s   dd„ S )Nc                  _  s
   t | |ŽS r´   rk  rf  r‹   r‹   r�   rJ  >  rK  z2SubclassedDataFrame._constructor.<locals>.<lambda>r‹   rh  r‹   r‹   r�   rj  <  s    z SubclassedDataFrame._constructorc                 C  s   dd„ S )Nc                  _  s
   t | |ŽS r´   re  rf  r‹   r‹   r�   rJ  B  rK  z9SubclassedDataFrame._constructor_sliced.<locals>.<lambda>r‹   rh  r‹   r‹   r�   Ú_constructor_sliced@  s    z'SubclassedDataFrame._constructor_slicedN)rn  ro  rp  rq  rr  rj  rs  r‹   r‹   r‹   r�   rl  9  s
   
rl  c                   @  s   e Zd Zedd„ ƒZdS )ÚSubclassedCategoricalc                 C  s   t S r´   )rt  rh  r‹   r‹   r�   rj  F  s    z"SubclassedCategorical._constructorN)rn  ro  rp  rr  rj  r‹   r‹   r‹   r�   rt  E  s   rt  c                   s"   ˆr‡fdd„}n‡ fdd„}|S )a`  
    Create a function for calling on an array.

    Parameters
    ----------
    alternative : function
        The function to be called on the array with no NaNs.
        Only used when 'skipna_alternative' is None.
    skipna_alternative : function
        The function to be called on the original array

    Returns
    -------
    function
    c                   s
   ˆ | j ƒS r´   )rÖ   ©rÇ   )Úskipna_alternativer‹   r�   Úskipna_wrapper]  s    z,_make_skipna_wrapper.<locals>.skipna_wrapperc                   s"   |   ¡ }t|ƒdkrtjS ˆ |ƒS )Nr   )Zdropnarí   r§   r|   )rÇ   Znona)Úalternativer‹   r�   rw  b  s    r‹   )rx  rv  rw  r‹   )rx  rv  r�   Ú_make_skipna_wrapperK  s    ry  z	list[str])Ú	rows_listrœ   c                 C  s   t j}| | ¡| S )aW  
    Convert list of CSV rows to single CSV-formatted string for current OS.

    This method is used for creating expected value of to_csv() method.

    Parameters
    ----------
    rows_list : List[str]
        Each element represents the row of csv.

    Returns
    -------
    str
        Expected output of to_csv() in current OS.
    )ÚosÚlinesepÚjoin)rz  Úsepr‹   r‹   r�   Úconvert_rows_list_to_csv_strk  s    r  ztype[Exception]r   )Úexpected_exceptionrœ   c                 C  s   ddl }|j| dd�S )a$  
    Helper function to mark pytest.raises that have an external error message.

    Parameters
    ----------
    expected_exception : Exception
        Expected error to raise.

    Returns
    -------
    Callable
        Regular `pytest.raises` function with `match` equal to `None`.
    r   N)Úmatch)ÚpytestZraises)r€  r‚  r‹   r‹   r�   Úexternal_error_raised  s    rƒ  c                   s@   g }|D ]2\‰‰ |  ˆˆˆ f¡ |‡ ‡‡fdd„tD ƒ7 }q|S )a±  
    Combine frame, functions from com._cython_table
    keys and expected result.

    Parameters
    ----------
    ndframe : DataFrame or Series
    func_names_and_expected : Sequence of two items
        The first item is a name of a NDFrame method ('sum', 'prod') etc.
        The second item is the expected return value.

    Returns
    -------
    list
        List of three items (DataFrame, function, expected result)
    c                   s"   g | ]\}}|ˆkrˆ|ˆ f‘qS r‹   r‹   )rŒ   Úfuncr¿   ©r¯   Ú	func_nameÚndframer‹   r�   r�   ©  s   þz+get_cython_table_params.<locals>.<listcomp>)r8  Úcython_table)r‡  Zfunc_names_and_expectedÚresultsr‹   r…  r�   Úget_cython_table_params•  s    þ
rŠ  r   )Úop_namerœ   c                   sP   |   d¡}ztt|ƒ}W n2 tk
rJ   tt|dd… ƒ‰ ‡ fdd„}Y nX |S )zì
    The operator function for a given op name.

    Parameters
    ----------
    op_name : str
        The op name, in form of "add" or "__add__".

    Returns
    -------
    function
        A function performing the operation.
    r*  rÊ   Nc                   s
   ˆ || ƒS r´   r‹   )rÇ   Úy©Zropr‹   r�   rJ  Å  rK  z"get_op_from_name.<locals>.<lambda>)Ústripr²   ÚoperatorÚAttributeError)r‹  Zshort_opnameÚopr‹   r�  r�   Úget_op_from_name±  s    
r’  c                 C  s   | S r´   r‹   ru  r‹   r‹   r�   ÚgetitemÎ  s    r“  c                 C  s   | S r´   r‹   ru  r‹   r‹   r�   ÚsetitemÒ  s    r”  c                 C  s   | j S r´   )Úlocru  r‹   r‹   r�   r•  Ö  s    r•  c                 C  s   | j S r´   )ra  ru  r‹   r‹   r�   ra  Ú  s    ra  c                 C  s   | j S r´   )Úatru  r‹   r‹   r�   r–  Þ  s    r–  c                 C  s   | j S r´   )Úiatru  r‹   r‹   r�   r—  â  s    r—  c                 C  sÒ  t | tjƒr$t |tjƒr$t | |¡S t | tjƒr:t|| ƒS t | tƒrHdS t | tƒr^t| j|ƒS t | ttfƒrxt| j	|ƒS t | t
ƒrŽt| j|ƒS t | tjjjƒrªt| j|ƒS t | tjjjƒrÒt| j|ƒpÐt| j|ƒS t | tƒ�rN| jdk�rNtd| ƒ} t |tƒ�rN|jdk�rNtd|ƒ}| j}|j}| d¡ ¡ d }| d¡ ¡ d }||kS t | tƒ�rˆt |tƒ�rˆt | j|j¡�p†t | j|j¡S t | tƒ�r¼t| jjƒdk�r¼| jjd }t||ƒS tt | ƒt |ƒƒ‚dS )z-
    Pandas-compat for np.shares_memory.
    Fzstring[pyarrow]rU   r   rÊ   N)!r¦   r§   r¬   Úshares_memoryr!   r    Ú_codesr   r"   r©   rQ   Z_ndarrayr�   ÚcoreZarraysZSparseArrayZ	sp_valuesZIntervalArrayÚ_leftÚ_rightrO   r±   r   Ú_dataÚchunkÚbuffersrN   Z_maskr   rí   Z_mgrr®   Útype)ÚleftÚrightZleft_pa_dataZright_pa_dataZ	left_buf1Z
right_buf1Zarrr‹   r‹   r�   r˜  é  sD    





 ÿ
r˜  ÚALL_INT_EA_DTYPESÚALL_INT_NUMPY_DTYPESÚALL_NUMPY_DTYPESÚALL_REAL_NUMPY_DTYPESr.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   r,   rA   rB   rC   r   r$   rG   ÚEMPTY_STRING_PATTERNÚENDIANrH   rI   rE   r   rF   r-   ÚNARROW_NP_DTYPESr%   ÚNP_NAT_OBJECTSÚNULL_OBJECTSrD   r*   rJ   r&   r'   r(   r   rK   rL   rM   r)   )T)rº   N)rº   r•   N)rº   N)rº   N)rº   )rº   )rº   )rº   N)rº   )rº   rà   N)rº   r�   N)rº   N)rº   N)rº   )N)N)N)Nrà   N)NN)Nrà   )N)Nrà   )N)r  FNN)
TTrÊ   rÊ   NNNNNN)N)r_  N)N)÷Ú
__future__r   r5  r   Údecimalr   r�  r{  r+  rµ   Úsysr   Útypingr   r   r   r	   r
   r   Únumpyr§   Zpandas._config.localizationr   r   r   Zpandas._typingr   r   r   Zpandas.compatr   Zpandas.core.dtypes.commonr   r   r   r   r   r   Zpandasr�   r   r   r   r   r   r   r   r    r!   r"   r#   Zpandas._testing._ior$   r%   r&   r'   r(   r)   Zpandas._testing._randomr*   r+   Zpandas._testing._warningsr,   r-   Zpandas._testing.assertersr.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   Zpandas._testing.compatrE   rF   Zpandas._testing.contextsrG   rH   rI   rJ   rK   rL   rM   Zpandas.core.arraysrN   rO   rP   Zpandas.core.arrays._mixinsrQ   Zpandas.core.constructionrR   rS   rT   rU   rù   r  r\   Ú__annotations__r]   r»   rb   rc   r¤  r£  rd   rR  rg   rh   ri   Úcomplexrj   rk   rm   rn   ro   rp   rq   rr   rs   rt   ru   r¦  ZALL_REAL_EXTENSION_DTYPESrv   rw   r¥  Zfloat16re   r^   r_   r`   rX   rY   rZ   r©  r¨  r|   rŠ   ZNAr«  Z
datetime64Ztimedelta64rª  Zpyarrowr˜   r[   ZUNSIGNED_INT_PYARROW_DTYPESra   ZSIGNED_INT_PYARROW_DTYPESZALL_INT_PYARROW_DTYPESZALL_INT_PYARROW_DTYPES_STR_REPRrf   ZFLOAT_PYARROW_DTYPESZFLOAT_PYARROW_DTYPES_STR_REPRZ
decimal128ZDECIMAL_PYARROW_DTYPESZSTRING_PYARROW_DTYPESÚbinaryZBINARY_PYARROW_DTYPESZtime32Ztime64ZTIME_PYARROW_DTYPESZdate32Zdate64ZDATE_PYARROW_DTYPESZDATETIME_PYARROW_DTYPESZTIMEDELTA_PYARROW_DTYPESZbool_ZBOOL_PYARROW_DTYPESZALL_PYARROW_DTYPESÚcompiler§  rž   r    r°   r­   r¹   rÁ   rÈ   rÌ   rÍ   r×   rÜ   rÝ   rÞ   rß   rå   rè   ré   rñ   ró   rô   rý   r   r  r  r  r
  r  r  r  r  r  r  r  r  rC  rQ  r^  rb  rc  rl  rt  ry  r  rƒ  rš  ÚcommonZ_cython_tableÚitemsrˆ  rŠ  r’  r“  r”  r•  ra  r–  r—  r˜  Ú__all__r‹   r‹   r‹   r�   Ú<module>   sŽ    	 	4 d$	ÿþýüûúùÿø
þÿÿ

üþ
ÿþýüûúùø	÷ÿ
)    ÿ
    ÿ	    ÿ   ús         ôk 2‹