B []P@sj ddlmZmZmZmZddlmZddlZddlZddl m Z m Z ddl Z ddl m ZddlZddlZddlmZmZddlmmZddlZddlmZddlmZddlmmZ e j!j"d d e j#j$fd e j!%d d d Z&ddZ'ej(ddddZ)ej(ddddZ*ej(dddddddgdddZ+ej(dd d!d"gd#d$d%d&d'Z,e,Z-ej(dd!gd(d$d%d)d*Z.ej(d+d,Z/ej(dd-dgdd.d/Z0ej(dd-dgdd0d1Z1d2d3d4d5d6d7d8d9d:d;dd?gZ2ej(e2dd@dAZ3ej(ej4ej5ej6ej7ej8ej9ej:ej;ejej?ej@ejAgddBdCZBdDdEdFdGdHdIdJdKdLdMg ZCej(eCddNdOZDdPdQgZEej(eEddRdSZFejGjHjIjJKZJej(eLeJddTdUZMdVdWZNej(dXdYdZd[d\d]gdd^d_ZOej(dZd[d\d]gdd`daZPej(ddbdcdddegddfdgZQej(dbdcdddegddhdiZRej(dd-gddjdkZSej(dldmdndoZTej(dpdqee ejgddrdsZUej(dtdudvdwgddxdyZVej(dzd{ZWej(d|d}ZXej(d~dZYej(ddgdddZZej(dvdwddgdddZ[ej(dvdwddgdddZ\ej(dej]ej^e_de_dgdddZ`e`Zaej(dej]ej^gdddZbebZcdddddde e edededejeed deeddddgZdddedDZeefegeeej(edeed%ddZhefegeed dej(edd deed dd%ddZieiZjddddgZkddddgZlemddddgZnddddgZoekenZpeleoZqe_ddgZresddgZtegddgZuddgZvddgZwexdgZyezdgZ{e|dgZ}erepZ~e~eteueveweye}e{Zej(eudddZej(e{dddZej(e}dddÄZej(evdddńZej(ewdddDŽZej(erdddɄZej(etddd˄Zej(enddd̈́Zej(ekdddτZej(epdddфZej(e~dddӄZej(edddՄZddej]dgfddej]dgfdej]ej]ej]gfdgfddej]dgfddej]dgfddej]dgfdd ej]dgfdd ej]dgfded ej]ed݃gfddej]d-gfdedej]edgfdedej]edgfdedd d ej]edd d gfded ej]ed݃gfded ej]ed݃gfdedej^edgfdedd ej]eddݡgfgZee\ZZej(eed%ddZej(ddejjDdddZxDdD]8ZeejjeZeeejeeddedqfWxTdD]HZeejjeZeeejeeddeejd dddqWxZdD]LZeejjeZeeejeeddeejd ddd qWej(ddZdS()datetime timedeltatimezone)DecimalN)tzlocaltzutc) strategies) FixedOffsetutc) DataFrame)opscii)deadlineZsuppress_health_checkcCsd|jdddd|jdddd|jdddd|jd dd d|jd dd d|jd ddddS)Nz --skip-slow store_truezskip slow tests)actionhelpz--skip-networkzskip network testsz --skip-dbz skip db testsz--run-high-memoryzrun high memory testsz --only-slowzrun only slow testsz--strict-data-filesz0Fail if a test is skipped for missing data file.)Z addoption)parserr3/tmp/pip-install-svzetoqp/pandas/pandas/conftest.pypytest_addoption!s rcCsd|jkr |jdr tdd|jkr@|jdr@tdd|jkr`|jdr`tdd |jkr|jd rtd d |jkr|jd stddS)NZslowz --skip-slowzskipping due to --skip-slowz --only-slowzskipping due to --only-slownetworkz--skip-networkzskipping due to --skip-networkdbz --skip-dbzskipping due to --skip-dbZ high_memoryz--run-high-memoryz=skipping high memory test since --run-high-memory was not set)keywordsconfig getoptionpytestskip)itemrrrpytest_runtest_setup0s    rT)ZautousecCstdddS)NZchained_assignmentraise)pdZ set_optionrrrrconfigure_testsFsr"cCst|d<t|d<dS)Nnpr!)r#r!)Zdoctest_namespacerrr add_importsNsr$ZbsrZcooZcscZcsrZdiaZdokZlil)paramscCsddlm}t||jdS)Nr)sparseZ_matrix)Zscipyr&getattrparam)requestr&rrrspmatrixTs r*indexcolumnscCs d|S)Nz axis {!r})format)xrrr[r0)r%idscCs|jS)zB Fixture for returning the axis numbers of a DataFrame. )r()r)rrraxis[sr3cCs d|S)Nz axis {!r})r.)r/rrrr0fr1cCs|jS)z? Fixture for returning the axis numbers of a Series. )r()r)rrr axis_seriesfsr4cCs tjdddddlm}|S)zj Get an instance of IPython.InteractiveShell. Will raise a skip if IPython is not installed. ZIPythonz6.0.0)Z minversionr)InteractiveShell)rZ importorskipZIPython.core.interactiveshellr5)r5rrripns r6FcCs|jS)a{ 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 compatibility if we decide to change the default (and would need to warn if this parameter is not passed))r()r)rrrobserved|sr7cCs|jS)z,Boolean 'ordered' parameter for Categorical.)r()r)rrrordered_fixturesr8__add____radd____sub____rsub____mul____rmul__ __floordiv__ __rfloordiv__ __truediv__ __rtruediv____pow____rpow____mod____rmod__cCs|jS)zC Fixture for dunder names for common arithmetic operations )r()r)rrrall_arithmetic_operatorssrGcCs|jS)z Fixture for operator and roperator arithmetic functions. Note: This includes divmod and rdivmod, whereas all_arithmetic_operators does not. )r()r)rrrall_arithmetic_functionssrHsummaxminZmeanprodZstdvarZmedianZkurtZskewcCs|jS)z- Fixture for numeric reduction names )r()r)rrrall_numeric_reductionssrNallanycCs|jS)z- Fixture for boolean reduction names )r()r)rrrall_boolean_reductionssrQcCs|jS)N)r()r)rrrcython_table_itemssrRcsDg}x:|D]2\|f|fddtD7}q W|S)acombine 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) cs"g|]\}}|kr|fqSrr).0funcname)expected func_namendframerr sz,_get_cython_table_params..)append _cython_table)rXZfunc_names_and_expectedresultsr)rVrWrXr_get_cython_table_paramssr]__eq____ne____le____lt____ge____gt__cCs|jS)zu Fixture for dunder names for common compare operations * >= * > * == * != * < * <= )r()r)rrrall_compare_operatorss rdcCs|jS)zm Fixture for dunder names for compare operations except == and != * >= * > * < * <= )r()r)rrrcompare_operators_no_eq_nes regzipbz2zipxzcCs|jS)zJ Fixture for trying common compression types in compression tests )r()r)rrr compression#srjcCs|jS)zj Fixture for trying common compression types in compression tests excluding uncompressed case )r()r)rrrcompression_only+srkcCs|jS)z+ Fixture that an array is writable )r()r)rrrwritable4srlmodule)scopecCstjS)N)rr rrrrdatetime_tz_utc<sror z dateutil/UTCcCs|jS)zP Fixture to provide variants of UTC timezone strings and tzinfo objects )r()r)rrr utc_fixtureAsrpinnerouterleftrightcCs|jS)z9 Fixture for trying all types of join operations )r()r)rrr join_typeIsrucCs |dS)Nz--strict-data-files)r)Z pytestconfigrrrstrict_data_filesQsrvcs(tjtjtdfdd}|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. testscsNtjjf|}tj|sJr6d}t||nd}t|||S)Nz6Could not find file {} and --strict-data-files is set.zCould not find {}.)ospathjoinexists ValueErrorr.rr)argsrymsg) BASE_PATHrvrrdecojs zdatapath..deco)rxryrzdirname__file__)rvrr)rrvrdatapathVs rcCst|ddS)z The iris dataset as a DataFrame.dataziris.csv)r!Zread_csv)rrrririsxsrnlargest nsmallestcCs|jS)z0 Fixture for trying all nselect methods )r()r)rrrnselect_method~srZbothZneithercCs|jS)z; Fixture for trying all interval closed parameters )r()r)rrrclosedsrcCs|jS)zR Secondary closed fixture to allow parametrizing over all pairs of closed )r()r)rrr other_closedsrnanNaNcCs|jS)z. Fixture for each null type in pandas )r()r)rrr nulls_fixturesrcCs|jS)zK Fixture for each null type in pandas, each null type exactly once )r()r)rrrunique_nulls_fixturesrUTCz US/Easternz Asia/Tokyozdateutil/US/Pacificzdateutil/Asia/Singaporei,i)hoursZfoo)rUcCsg|] }t|qSr)repr)rSirrrrYsrYcCs|jS)zD Fixture for trying timezones including default (None): {0} )r()r)rrrtz_naive_fixturesrcCs|jS)z4 Fixture for trying explicit timezones: {0} )r()r)rrrtz_aware_fixturesrZuint8Zuint16Zuint32Zuint64ZUInt8ZUInt16ZUInt32ZUInt64Zint8Zint16Zint32Zint64ZInt8ZInt16ZInt32ZInt64Zfloat32Zfloat64Z complex64Z complex128strUzdatetime64[ns]zM8[ns]ztimedelta64[ns]zm8[ns]boolbytesobjectcCs|jS)zMParametrized fixture for string dtypes. * str * 'str' * 'U' )r()r)rrr string_dtypesrcCs|jS)zFParametrized fixture for bytes dtypes. * bytes * 'bytes' )r()r)rrr bytes_dtypesrcCs|jS)zIParametrized fixture for object dtypes. * object * 'object' )r()r)rrr object_dtypesrcCs|jS)zWParametrized fixture for datetime64 dtypes. * 'datetime64[ns]' * 'M8[ns]' )r()r)rrrdatetime64_dtypesrcCs|jS)zYParametrized fixture for timedelta64 dtypes. * 'timedelta64[ns]' * 'm8[ns]' )r()r)rrrtimedelta64_dtype"srcCs|jS)z^ Parameterized fixture for float dtypes. * float * 'float32' * 'float64' )r()r)rrr float_dtype,s rcCs|jS)zg Parameterized fixture for complex dtypes. * complex * 'complex64' * 'complex128' )r()r)rrr complex_dtype9s rcCs|jS)z| Parameterized fixture for signed integer dtypes. * int * 'int8' * 'int16' * 'int32' * 'int64' )r()r)rrr sint_dtypeFs rcCs|jS)zx Parameterized fixture for unsigned integer dtypes. * 'uint8' * 'uint16' * 'uint32' * 'uint64' )r()r)rrr uint_dtypeUs rcCs|jS)z Parameterized fixture for any integer dtype. * int * 'int8' * 'uint8' * 'int16' * 'uint16' * 'int32' * 'uint32' * 'int64' * 'uint64' )r()r)rrr any_int_dtypecsrcCs|jS)z Parameterized fixture for any (purely) real numeric dtype. * int * 'int8' * 'uint8' * 'int16' * 'uint16' * 'int32' * 'uint32' * 'int64' * 'uint64' * float * 'float32' * 'float64' )r()r)rrrany_real_dtypevsrcCs|jS)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)rrrany_numpy_dtypes#rstringacacemptyz mixed-integermixedg@Zfloatingg?integerzmixed-integer-floatdecimalboolean datetime64z 2013-01-01z 2018-01-01datetimeZ20130101Z20180101riirrZperiodintervalcCs |j\}}tj|td}||fS)a Fixture for all inferred dtypes from _libs.lib.infer_dtype The covered (inferred) types are: * 'string' * 'empty' * 'bytes' * '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 )Zdtype)r(r#arrayr)r)Zinferred_dtypevaluesrrrany_skipna_inferred_dtypes) rcCs.g|]&}tttj|tjjrttj|qSr) issubclassr'r!offsetsZTick)rSorrrrYscCs|jS)zN Fixture for Tick based datetime offsets available for a time series. )r()r)rrr tick_classess rz)MonthBegin MonthEnd BMonthBegin BMonthEndic)n normalizez%YearBegin YearEnd BYearBegin BYearEnd )Z min_valueZ max_value)rrmonthz1QuarterBegin QuarterEnd BQuarterBegin BQuarterEndi)rrZ startingMonthcCs ttS)a Fixture for DataFrame of floats with index of unique strings Columns are ['A', 'B', 'C', 'D']. A B C D P7GACiRnxd -0.465578 -0.361863 0.886172 -0.053465 qZKh6afn8n -0.466693 -0.373773 0.266873 1.673901 tkp0r6Qble 0.148691 -0.059051 0.174817 1.598433 wP70WOCtv8 0.133045 -0.581994 -0.992240 0.261651 M2AeYQMnCz -1.207959 -0.185775 0.588206 0.563938 QEPzyGDYDo -0.381843 -0.758281 0.502575 -0.565053 r78Jwns6dn -0.653707 0.883127 0.682199 0.206159 ... ... ... ... ... IHEGx9NO0T -0.277360 0.113021 -1.018314 0.196316 lPMj8K27FA -1.313667 -0.604776 -1.305618 -0.863999 qa66YMWQa5 1.110525 0.475310 -0.747865 0.032121 yOa0ATsmcE -0.431457 0.067094 0.096567 -0.264962 65znX3uRNG 1.528446 0.160416 -0.109635 -0.032987 eCOBvKqf3e 0.235281 1.622222 0.781255 0.392871 xSucinXxuV -1.263557 0.252799 -0.552247 0.400426 [30 rows x 4 columns] )r tmZ getSeriesDatarrrr float_frame1sr)rrrrrrroperatorrxZ dateutil.tzrrZ hypothesisr stZnumpyr#rZpytzr r Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandasr!r Z pandas.corer Zpandas.util.testingZtestingrsettingsZregister_profileZ HealthCheckZtoo_slowZ load_profilerrZfixturer"r$r*r3Z axis_framer4r6r7r8Z_all_arithmetic_operatorsrGaddZraddsubZrsubmulZrmultruedivZrtruedivfloordivZ rfloordivmodZrmodpowZrpowrHZ_all_numeric_reductionsrNZ_all_boolean_reductionsrQcorebaseZSelectionMixinr[itemslistrRr]rdrerjrkrlrorprurvrrrrrrZNaTfloatrZnulls_fixture2rZunique_nulls_fixture2Z TIMEZONESZ TIMEZONE_IDSZparametrize_fixture_docrrrZtz_aware_fixture2ZUNSIGNED_INT_DTYPESZUNSIGNED_EA_INT_DTYPESintZSIGNED_INT_DTYPESZSIGNED_EA_INT_DTYPESZALL_INT_DTYPESZALL_EA_INT_DTYPESZ FLOAT_DTYPEScomplexZCOMPLEX_DTYPESZ STRING_DTYPESZDATETIME64_DTYPESZTIMEDELTA64_DTYPESrZ BOOL_DTYPESrZ BYTES_DTYPESrZ OBJECT_DTYPESZALL_REAL_DTYPESZALL_NUMPY_DTYPESrrrrrrrrrrrrrZ TimestampZPeriodZIntervalZ_any_skipna_inferred_dtyperhr2_rr__all__rsplitrUr'ZtseriesclsZregister_type_strategyZbuildsZintegersZbooleansrrrrrsx     ""    "",   (               (" 0&