B
    •xŠ\zF  ã               @   s  d dl mZmZmZ d dlmZ d dlZd dlmZm	Z	 d dl
Z
d dl
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  mZ d dlZe
jjdd	e
je
jj fd
 e
j !d¡ dd„ Z"dd„ Z#ej$dddd„ ƒZ%ej$dddd„ ƒZ&ej$dddddddgddd„ ƒZ'ej$d dd d!gd"d#„ d$d%d&„ ƒZ(e(Z)ej$d d gd'd#„ d$d(d)„ ƒZ*ej$d*d+„ ƒZ+ej$dd,dgdd-d.„ ƒZ,d/d0d1d2d3d4d5d6d7d8d9d:d;d<gZ-es¸e- .d=d>g¡ ej$e-dd?d@„ ƒZ/dAdBdCdDdEdFdGdHdIdJg
Z0ej$e0ddKdL„ ƒZ1dMdNgZ2ej$e2ddOdP„ ƒZ3ej4j5j6j7 8¡ Z7ej$e9e7ƒddQdR„ ƒZ:dSdT„ Z;ej$dUdVdWdXdYdZgdd[d\„ ƒZ<ej$dd]d^d_ej=d`ej>dagddbdc„ ƒZ?ej$d]d^d_ej=d`ej>dagdddde„ ƒZ@ej$dd,gddfdg„ ƒZAej$dhdidjdk„ ƒZBdldmee	ƒ gZCerd dnl mDZD eC EeDj¡ ej$eCddodp„ ƒZFej$dqdrdsdtgddudv„ ƒZGej$dwdx„ ƒZHej$dydz„ ƒZIej$d{d|„ ƒZJej$d}d~gddd€„ ƒZKej$dsdtdd‚gddƒd„„ ƒZLej$dsdtdd‚gdd…d†„ ƒZMej$dejNejOePd‡ƒe Pdˆ¡gdd‰dŠ„ ƒZQeQZRej$dejNejOgdd‹dŒ„ ƒZSeSZTdddŽddd‘e	ƒ eƒ ed’ƒed ƒed“ƒgZUe VeWeUƒ¡ej$eUdd”d•„ ƒƒZXe VeWeUdd… ƒ¡ej$eUdd… dd–d—„ ƒƒZYd˜d™dšd›gZZdœddždŸgZ[e\d d¡d¢d£gZ]d¤d¥d¦d§gZ^eZe] Z_e[e^ Z`ePd¨d©gZaebdªd«gZceWd¬d­gZdd®d¯gZed°d±gZfegd²gZheid³gZjekd´gZleae_ Zmemec ed ee ef eh el eje  Znej$edddµd¶„ ƒZoej$eadd·d¸„ ƒZpej$ecdd¹dº„ ƒZqej$e]dd»d¼„ ƒZrej$eZdd½d¾„ ƒZsej$e_dd¿dÀ„ ƒZtej$emddÁdÂ„ ƒZuej$enddÃdÄ„ ƒZvdÅdÆejNdÇgfesôdÈndÅedÆƒejNedÇƒgferd³ndÅdÉejNdÊgfdËejNejNejNgfdËg fdÌdÆejNdÍgfdÎdÆejNdÏgfdÐdÑejNdÏgfdÒdejNdÍgfdÓdejNdÏgfdÔedƒejNedÍƒgfdÕdejNd,gfdÖe wd×¡ejNe wdØ¡gfdÙe xdÚ¡ejNe xdÛ¡gfdÜedÝddƒejNedÞddƒgfdßedƒejNedÍƒgfdàedƒejNedÍƒgfdáe ydÝ¡ejOe ydÞ¡gfdâe zd d¡ejNe zd dÍ¡gfgZ{e|e{Ž \Z}Z~ej$e{e}d$dãdä„ ƒZej$dådæ„ ej€jD ƒddçdè„ ƒZ‚xDdé ƒ¡ D ]8Z„e…ej†j€e„ƒZ‡e ˆe‡ej‰e‡e Šdêdë¡e ‹¡ dì¡ q¬W xPdí ƒ¡ D ]DZ„e…ej†j€e„ƒZ‡e ˆe‡ej‰e‡e Šdîdï¡e ‹¡ ejŠddðdñdò¡ qòW xPdó ƒ¡ D ]DZ„e…ej†j€e„ƒZ‡e ˆe‡ej‰e‡e Šdôdõ¡e ‹¡ ejŠddðdñdö¡ qDW dS )÷é    )ÚdateÚtimeÚ	timedelta)ÚDecimalN)ÚtzlocalÚtzutc)Ú
strategies)ÚFixedOffsetÚutc)ÚPY3ÚuZciiô  )ZdeadlineZtimeoutZsuppress_health_checkc             C   sd   | j dddd | j dddd | j dddd | j d	dd
d | j dddd | j dddd d S )Nz--skip-slowÚ
store_truezskip slow tests)ÚactionÚhelpz--skip-networkzskip network testsz	--skip-dbzskip db testsz--run-high-memoryzrun high memory testsz--only-slowzrun only slow testsz--strict-data-filesz0Fail if a test is skipped for missing data file.)Z	addoption)Úparser© r   ú.lib/python3.7/site-packages/pandas/conftest.pyÚpytest_addoption   s    r   c             C   s¤   d| j kr | j d¡r t d¡ d| j kr@| j d¡r@t d¡ d| j kr`| j d¡r`t d¡ d	| j kr€| j d
¡r€t d¡ d| j kr | j d¡s t d¡ d S )NZslowz--skip-slowzskipping due to --skip-slowz--only-slowzskipping due to --only-slowZnetworkz--skip-networkzskipping due to --skip-networkZdbz	--skip-dbzskipping due to --skip-dbZhigh_memoryz--run-high-memoryz=skipping high memory test since --run-high-memory was not set)ÚkeywordsZconfigÚ	getoptionÚpytestÚskip)Úitemr   r   r   Úpytest_runtest_setup.   s    



r   T)Zautousec               C   s   t  dd¡ d S )NZchained_assignmentÚraise)ÚpdZ
set_optionr   r   r   r   Úconfigure_testsC   s    r   c             C   s   t | d< t| d< d S )NÚnpr   )r   r   )Zdoctest_namespacer   r   r   Úadd_importsJ   s    r   ZbsrZcooZcscZcsrZdiaZdokZlil)Úparamsc             C   s   ddl m} t|| jd ƒS )Nr   )ÚsparseZ_matrix)Zscipyr    ÚgetattrÚparam)Úrequestr    r   r   r   ÚspmatrixP   s    r$   é   ÚindexÚcolumnsc             C   s
   d  | ¡S )Nz	axis {!r})Úformat)Úxr   r   r   Ú<lambda>W   s    r*   )r   Úidsc             C   s   | j S )zB
     Fixture for returning the axis numbers of a DataFrame.
     )r"   )r#   r   r   r   ÚaxisV   s    r,   c             C   s
   d  | ¡S )Nz	axis {!r})r(   )r)   r   r   r   r*   b   s    c             C   s   | j S )z?
     Fixture for returning the axis numbers of a Series.
     )r"   )r#   r   r   r   Úaxis_seriesb   s    r-   c              C   s    t jddd ddlm}  | ƒ S )zj
    Get an instance of IPython.InteractiveShell.

    Will raise a skip if IPython is not installed.
    ZIPythonz6.0.0)Z
minversionr   )ÚInteractiveShell)r   ZimportorskipZIPython.core.interactiveshellr.   )r.   r   r   r   Úipj   s    r/   Fc             C   s   | j S )az   pass in the observed keyword to groupby for [True, False]
    This indicates whether categoricals should return values for
    values which are not in the grouper [False / None], or only values which
    appear in the grouper [True]. [None] is supported for future compatiblity
    if we decide to change the default (and would need to warn if this
    parameter is not passed))r"   )r#   r   r   r   Úobservedw   s    r0   Ú__add__Ú__radd__Ú__sub__Ú__rsub__Ú__mul__Ú__rmul__Ú__floordiv__Ú__rfloordiv__Ú__truediv__Ú__rtruediv__Ú__pow__Ú__rpow__Ú__mod__Ú__rmod__Z__div__Z__rdiv__c             C   s   | j S )zC
    Fixture for dunder names for common arithmetic operations
    )r"   )r#   r   r   r   Úall_arithmetic_operators   s    r?   ÚsumÚmaxÚminZmeanZprodZstdÚvarZmedianZkurtZskewc             C   s   | j S )z-
    Fixture for numeric reduction names
    )r"   )r#   r   r   r   Úall_numeric_reductionsš   s    rD   ÚallÚanyc             C   s   | j S )z-
    Fixture for boolean reduction names
    )r"   )r#   r   r   r   Úall_boolean_reductions¥   s    rG   c             C   s   | j S )N)r"   )r#   r   r   r   Úcython_table_items°   s    rH   c                sD   g }x:|D ]2\‰‰ |  ˆˆˆ f¡ |‡ ‡‡fdd„tD ƒ7 }q
W |S )aÀ  combine frame, functions from SelectionMixin._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
    -------
    results : list
        List of three items (DataFrame, function, expected result)
    c                s"   g | ]\}}|ˆkrˆ|ˆ f‘qS r   r   )Ú.0ÚfuncÚname)ÚexpectedÚ	func_nameÚndframer   r   ú
<listcomp>È   s    z,_get_cython_table_params.<locals>.<listcomp>)ÚappendÚ_cython_table)rN   Zfunc_names_and_expectedZresultsr   )rL   rM   rN   r   Ú_get_cython_table_paramsµ   s
    rR   Ú__eq__Ú__ne__Ú__le__Ú__lt__Ú__ge__Ú__gt__c             C   s   | j S )zu
    Fixture for dunder names for common compare operations

    * >=
    * >
    * ==
    * !=
    * <
    * <=
    )r"   )r#   r   r   r   Úall_compare_operatorsÍ   s    rY   ZgzipÚbz2ÚzipZxz)Zmarksc             C   s   | j S )zJ
    Fixture for trying common compression types in compression tests
    )r"   )r#   r   r   r   ÚcompressionÝ   s    r\   c             C   s   | j S )zj
    Fixture for trying common compression types in compression tests excluding
    uncompressed case
    )r"   )r#   r   r   r   Úcompression_onlyæ   s    r]   c             C   s   | j S )z+
    Fixture that an array is writable
    )r"   )r#   r   r   r   Úwritableð   s    r^   Úmodule)Zscopec              C   s   ddl m}  | jS )Nr   )Útimezone)Údatetimer`   r
   )r`   r   r   r   Údatetime_tz_utcø   s    rb   r
   zdateutil/UTC)r`   c             C   s   | j S )zP
    Fixture to provide variants of UTC timezone strings and tzinfo objects
    )r"   )r#   r   r   r   Úutc_fixture  s    rc   ÚinnerZouterÚleftÚrightc             C   s   | j S )z9
    Fixture for trying all types of join operations
    )r"   )r#   r   r   r   Ú	join_type  s    rg   c             C   s
   |   d¡S )Nz--strict-data-files)r   )Zpytestconfigr   r   r   Ústrict_data_files  s    rh   c                s(   t j t j t¡d¡‰ ‡ ‡fdd„}|S )a?  Get the path to a data file.

    Parameters
    ----------
    path : str
        Path to the file, relative to ``pandas/tests/``

    Returns
    -------
    path : path including ``pandas/tests``.

    Raises
    ------
    ValueError
        If the path doesn't exist and the --strict-data-files option is set.
    Ztestsc                 sN   t jjˆ f| žŽ }t j |¡sJˆr6d}t| |¡ƒ‚nd}t | |¡¡ |S )Nz6Could not find file {} and --strict-data-files is set.zCould not find {}.)ÚosÚpathÚjoinÚexistsÚ
ValueErrorr(   r   r   )Úargsrj   Úmsg)Ú	BASE_PATHrh   r   r   Údeco-  s    zdatapath.<locals>.deco)ri   rj   rk   ÚdirnameÚ__file__)rh   rq   r   )rp   rh   r   Údatapath  s    
rt   c             C   s   t  | ddƒ¡S )z The iris dataset as a DataFrame.Údataziris.csv)r   Zread_csv)rt   r   r   r   Úiris:  s    rv   ÚnlargestÚ	nsmallestc             C   s   | j S )z0
    Fixture for trying all nselect methods
    )r"   )r#   r   r   r   Únselect_method@  s    ry   ZbothZneitherc             C   s   | j S )z;
    Fixture for trying all interval closed parameters
    )r"   )r#   r   r   r   ÚclosedH  s    rz   c             C   s   | j S )zR
    Secondary closed fixture to allow parametrizing over all pairs of closed
    )r"   )r#   r   r   r   Úother_closedP  s    r{   ÚnanZNaNc             C   s   | j S )z.
    Fixture for each null type in pandas
    )r"   )r#   r   r   r   Únulls_fixtureX  s    r}   c             C   s   | j S )zK
    Fixture for each null type in pandas, each null type exactly once
    )r"   )r#   r   r   r   Úunique_nulls_fixturec  s    r~   ZUTCz
US/Easternz
Asia/Tokyozdateutil/US/Pacificzdateutil/Asia/Singaporei,  iÔþÿÿc             C   s   | j S )zD
    Fixture for trying timezones including default (None): {0}
    )r"   )r#   r   r   r   Útz_naive_fixturet  s    r   c             C   s   | j S )z4
    Fixture for trying explicit timezones: {0}
    )r"   )r#   r   r   r   Útz_aware_fixture}  s    r€   Zuint8Zuint16Zuint32Zuint64ZUInt8ZUInt16ZUInt32ZUInt64Zint8Zint16Zint32Zint64ZInt8ZInt16ZInt32ZInt64Zfloat32Zfloat64Z	complex64Z
complex128ÚstrÚUzdatetime64[ns]zM8[ns]ztimedelta64[ns]zm8[ns]ÚboolÚbytesÚobjectc             C   s   | j S )zMParametrized fixture for string dtypes.

    * str
    * 'str'
    * 'U'
    )r"   )r#   r   r   r   Ústring_dtype   s    r†   c             C   s   | j S )z^
    Parameterized fixture for float dtypes.

    * float
    * 'float32'
    * 'float64'
    )r"   )r#   r   r   r   Úfloat_dtype«  s    
r‡   c             C   s   | j S )zg
    Parameterized fixture for complex dtypes.

    * complex
    * 'complex64'
    * 'complex128'
    )r"   )r#   r   r   r   Úcomplex_dtype¸  s    
rˆ   c             C   s   | j S )z|
    Parameterized fixture for signed integer dtypes.

    * int
    * 'int8'
    * 'int16'
    * 'int32'
    * 'int64'
    )r"   )r#   r   r   r   Ú
sint_dtypeÅ  s    r‰   c             C   s   | j S )zx
    Parameterized fixture for unsigned integer dtypes.

    * 'uint8'
    * 'uint16'
    * 'uint32'
    * 'uint64'
    )r"   )r#   r   r   r   Ú
uint_dtypeÔ  s    rŠ   c             C   s   | j S )z³
    Parameterized fixture for any integer dtype.

    * int
    * 'int8'
    * 'uint8'
    * 'int16'
    * 'uint16'
    * 'int32'
    * 'uint32'
    * 'int64'
    * 'uint64'
    )r"   )r#   r   r   r   Úany_int_dtypeâ  s    r‹   c             C   s   | j S )zí
    Parameterized fixture for any (purely) real numeric dtype.

    * int
    * 'int8'
    * 'uint8'
    * 'int16'
    * 'uint16'
    * 'int32'
    * 'uint32'
    * 'int64'
    * 'uint64'
    * float
    * 'float32'
    * 'float64'
    )r"   )r#   r   r   r   Úany_real_dtypeõ  s    rŒ   c             C   s   | j S )aÌ  
    Parameterized fixture for all numpy dtypes.

    * bool
    * 'bool'
    * int
    * 'int8'
    * 'uint8'
    * 'int16'
    * 'uint16'
    * 'int32'
    * 'uint32'
    * 'int64'
    * 'uint64'
    * float
    * 'float32'
    * 'float64'
    * complex
    * 'complex64'
    * 'complex128'
    * str
    * 'str'
    * 'U'
    * bytes
    * 'bytes'
    * 'datetime64[ns]'
    * 'M8[ns]'
    * 'timedelta64[ns]'
    * 'm8[ns]'
    * object
    * 'object'
    )r"   )r#   r   r   r   Úany_numpy_dtype  s    #r   ÚstringÚaÚcZunicodeó   aó   cÚemptyzmixed-integeré   Zmixedg       @Zfloatingg      ð?Zintegerzmixed-integer-floatÚdecimalZbooleanÚ
datetime64z
2013-01-01z
2018-01-01ra   Z20130101Z20180101r   iÝ  iâ  r   r   ZperiodZintervalc             C   s    | j \}}tj|td}||fS )a²  
    Fixture for all inferred dtypes from _libs.lib.infer_dtype

    The covered (inferred) types are:
    * 'string'
    * 'unicode' (if PY2)
    * 'empty'
    * 'bytes' (if PY3)
    * 'mixed'
    * 'mixed-integer'
    * 'mixed-integer-float'
    * 'floating'
    * 'integer'
    * 'decimal'
    * 'boolean'
    * 'datetime64'
    * 'datetime'
    * 'date'
    * 'timedelta'
    * 'time'
    * 'period'
    * 'interval'

    Returns
    -------
    inferred_dtype : str
        The string for the inferred dtype from _libs.lib.infer_dtype
    values : np.ndarray
        An array of object dtype that will be inferred to have
        `inferred_dtype`

    Examples
    --------
    >>> import pandas._libs.lib as lib
    >>>
    >>> def test_something(any_skipna_inferred_dtype):
    ...     inferred_dtype, values = any_skipna_inferred_dtype
    ...     # will pass
    ...     assert lib.infer_dtype(values, skipna=True) == inferred_dtype
    )Zdtype)r"   r   Zarrayr…   )r#   Zinferred_dtypeÚvaluesr   r   r   Úany_skipna_inferred_dtypeN  s    *
r˜   c             C   s.   g | ]&}t ttj|ƒtjjƒrttj|ƒ‘qS r   )Ú
issubclassr!   r   ÚoffsetsZTick)rI   Úor   r   r   rO     s    rO   c             C   s   | j S )zN
    Fixture for Tick based datetime offsets available for a time series.
    )r"   )r#   r   r   r   Útick_classes  s    rœ   z)MonthBegin MonthEnd BMonthBegin BMonthEndiÿÿÿéc   )ÚnÚ	normalizez%YearBegin YearEnd BYearBegin BYearEndéûÿÿÿé   é   )Z	min_valueZ	max_value)rž   rŸ   Zmonthz1QuarterBegin QuarterEnd BQuarterBegin BQuarterEndièÿÿÿé   )rž   rŸ   ZstartingMonth)Œra   r   r   r   r•   r   ri   Zdateutil.tzr   r   Z
hypothesisr   ÚstZnumpyr   r   Zpytzr	   r
   Zpandas.compatr   r   Zpandas.util._test_decoratorsÚutilZ_test_decoratorsZtdZpandasr   ZsettingsZregister_profileZ	unlimitedZHealthCheckZtoo_slowZload_profiler   r   Zfixturer   r   r$   r,   Z
axis_framer-   r/   r0   Z_all_arithmetic_operatorsÚextendr?   Z_all_numeric_reductionsrD   Z_all_boolean_reductionsrG   ZcoreÚbaseZSelectionMixinrQ   ÚitemsÚlistrH   rR   rY   r"   Zskip_if_no_lzmar\   r]   r^   rb   Zutc_objsr`   rP   rc   rg   rh   rt   rv   ry   rz   r{   r|   ZNaTÚfloatr}   Znulls_fixture2r~   Zunique_nulls_fixture2Z	TIMEZONESZparametrize_fixture_docr   r   r€   ZUNSIGNED_INT_DTYPESZUNSIGNED_EA_INT_DTYPESÚintZSIGNED_INT_DTYPESZSIGNED_EA_INT_DTYPESZALL_INT_DTYPESZALL_EA_INT_DTYPESZFLOAT_DTYPESÚcomplexZCOMPLEX_DTYPESZSTRING_DTYPESZDATETIME_DTYPESZTIMEDELTA_DTYPESrƒ   ZBOOL_DTYPESr„   ZBYTES_DTYPESr…   ZOBJECT_DTYPESZALL_REAL_DTYPESZALL_NUMPY_DTYPESr†   r‡   rˆ   r‰   rŠ   r‹   rŒ   r   r–   Z	TimestampZPeriodZIntervalZ_any_skipna_inferred_dtyper[   r+   Ú_r˜   rš   Ú__all__rœ   ÚsplitrK   r!   ZtseriesÚclsZregister_type_strategyZbuildsZintegersZbooleansr   r   r   r   Ú<module>   s"  "


	!,	




$( "1"





