zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
U
­ý°dºã@s:dZddlZddlZddlmZddlmZddlm    Z    ddl
m Z ddl Z ddlmZddlmZddlmZejd    d
gd d d „ƒZejdd„ƒZejdd„ƒZejdd„ƒZejdd„ƒZejdd„ƒZejdd„ƒZejdd„ƒZGdd„dƒZGdd„deejƒZ Gd d!„d!eej!ƒZ"Gd"d#„d#eej#ƒZ$Gd$d%„d%ej%ƒZ&Gd&d'„d'eej'ƒZ(Gd(d)„d)eej)ƒZ*Gd*d+„d+eej+ƒZ,Gd,d-„d-eej-ƒZ.Gd.d/„d/eej/ƒZ0Gd0d1„d1eej1ƒZ2Gd2d3„d3eej3ƒZ4Gd4d5„d5eej5ƒZ6Gd6d7„d7eej7ƒZ8Gd8d9„d9eej9ƒZ:Gd:d;„d;eej;ƒZ<Gd<d=„d=eej=ƒZ>dS)>aj
This file contains a minimal set of tests for compliance with the extension
array interface test suite, and should contain no other tests.
The test suite for the full functionality of the array is located in
`pandas/tests/arrays/`.
 
The tests in this file are inherited from the BaseExtensionTests, and only
minimal tweaks should be applied to get the tests passing (by overwriting a
parent method).
 
Additional tests should either be added to one of the BaseExtensionTests
classes (if they are relevant for the extension interface for all dtypes), or
be added to the array-specific tests in `pandas/tests/arrays/`.
 
éN)ÚiNaT)Úis_platform_windows)Únp_version_gte1p24)Ú PeriodDtype)Ú PeriodArray)ÚbaseÚDZ2D)ÚparamscCs t|jdS)N©Úfreq)rÚparam)Úrequest©rúYd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/extension/test_period.pyÚdtypesrcCstt dd¡|jdS)Ni²ir
)rÚnpZaranger ©rrrrÚdata$srcCstt d¡d|jdS)Nédér
)rrZonesr rrrrÚ data_for_twos)srcCstdddg|jdS)Néâéãéár
)rr rrrrÚdata_for_sorting.srcCsttdg|jdS)Nrr
©rrr rrrrÚ data_missing3srcCstdtdg|jdS)Nrrr
rrrrrÚdata_missing_for_sorting8src    Cs.d}t}d}d}t||||||||g|jdS)Nrrrr
)rrr )rÚBZNAÚAÚCrrrÚdata_for_grouping=s
r!cCstjS©N)ÚpdZNaTrrrrÚna_valueFsr$c@s eZdZdS)ÚBasePeriodTestsN©Ú__name__Ú
__module__Ú __qualname__rrrrr%Ksr%c@s eZdZdS)ÚTestPeriodDtypeNr&rrrrr*Osr*c@s eZdZdS)ÚTestConstructorsNr&rrrrr+Ssr+c@s eZdZdS)Ú TestGetitemNr&rrrrr,Wsr,c@s eZdZdS)Ú    TestIndexNr&rrrrr-[sr-cs6eZdZdd„Zej dddg¡‡fdd„ƒZ‡ZS)Ú TestMethodscCsdSr"r)ÚselfZ data_repeatedrrrÚtest_combine_add`szTestMethods.test_combine_addÚperiodsééþÿÿÿc    sFtƒr4tr4tjtddtƒ ||¡W5QRXntƒ ||¡dS)NF)Zcheck_stacklevel)rrÚtmZassert_produces_warningÚRuntimeWarningÚsuperÚ    test_diff)r/rr1©Ú    __class__rrr7ds
zTestMethods.test_diff)    r'r(r)r0ÚpytestÚmarkÚ parametrizer7Ú __classcell__rrr8rr._sr.c@s eZdZdS)Ú TestInterfaceNr&rrrrr>msr>cs\eZdZddhZ‡fdd„Z‡fdd„Z‡fdd„Zef‡fd    d
„    Zd d „Z    d d„Z
‡Z S)ÚTestArithmeticOpsÚ__sub__Ú__rsub__csB||jkr0t d|i¡}|j|||dddntƒ ||¡dS)Nrr©Úexc)Ú
implementsr#Ú    DataFrameÚ check_opnamer6Útest_arith_frame_with_scalar)r/rÚall_arithmetic_operatorsZdfr8rrrGts
z.TestArithmeticOps.test_arith_frame_with_scalarcs@||jkr.t |¡}|j|||jdddntƒ ||¡dS©NrrB©rDr#ÚSeriesrFZilocr6Útest_arith_series_with_scalar©r/rrHÚsr8rrrL}s
 
z/TestArithmeticOps.test_arith_series_with_scalarcs@||jkr.t |¡}|j|||jdddntƒ ||¡dSrIrJrMr8rrÚtest_arith_series_with_array†s
 
z.TestArithmeticOps.test_arith_series_with_arraycstƒj|||tddS)NrB)r6Ú_check_divmod_opÚ    TypeError)r/rNÚopÚotherrCr8rrrPŽsz"TestArithmeticOps._check_divmod_opc    Cs4t |¡}d}tjt|d||W5QRXdS)NzIunsupported operand type\(s\) for \+: \'PeriodArray\' and \'PeriodArray\')Úmatch)r#rKr:ZraisesrQ)r/rrNÚmsgrrrÚ$test_add_series_with_extension_array‘s
 
ÿz6TestArithmeticOps.test_add_series_with_extension_arraycCs6t |¡}|tjkr| ¡}| |¡}|tks2t‚dSr")r#rKrEZto_framer@ÚNotImplementedÚAssertionError)r/rZframe_or_seriesrSÚresultrrrÚ6test_direct_arith_with_ndframe_returns_not_implemented›s
 
 
 
zHTestArithmeticOps.test_direct_arith_with_ndframe_returns_not_implemented) r'r(r)rDrGrLrOÚNotImplementedErrorrPrVrZr=rrr8rr?qs           
r?c@s eZdZdS)Ú TestCastingNr&rrrrr\§sr\c@s eZdZdS)ÚTestComparisonOpsNr&rrrrr]«sr]c@s eZdZdS)Ú TestMissingNr&rrrrr^¯sr^c@s eZdZdS)Ú TestReshapingNr&rrrrr_³sr_c@s eZdZdS)Ú TestSetitemNr&rrrrr`·sr`c@s eZdZdS)Ú TestGroupbyNr&rrrrra»srac@s eZdZdS)Ú TestPrintingNr&rrrrrb¿srbcs.eZdZej dddg¡‡fdd„ƒZ‡ZS)Ú TestParsingÚengineÚcÚpythoncstƒ ||¡dSr")r6Ú test_EA_types)r/rdrr8rrrgÄszTestParsing.test_EA_types)r'r(r)r:r;r<rgr=rrr8rrcÃsrcc@s eZdZdS)Ú Test2DCompatNr&rrrrrhÉsrh)?Ú__doc__Únumpyrr:Z pandas._libsrZ pandas.compatrZpandas.compat.numpyrZpandas.core.dtypes.dtypesrZpandasr#Zpandas._testingZ_testingr4Zpandas.core.arraysrZpandas.tests.extensionrZfixturerrrrrrr!r$r%ZBaseDtypeTestsr*ZBaseConstructorsTestsr+ZBaseGetitemTestsr,ZBaseIndexTestsr-ZBaseMethodsTestsr.ZBaseInterfaceTestsr>ZBaseArithmeticOpsTestsr?ZBaseCastingTestsr\ZBaseComparisonOpsTestsr]ZBaseMissingTestsr^ZBaseReshapingTestsr_ZBaseSetitemTestsr`ZBaseGroupbyTestsraZBasePrintingTestsrbZBaseParsingTestsrcZNDArrayBacked2DTestsrhrrrrÚ<module>sV       
 
 
 
 
 
 
 
6