U
    >vf                     @   s:  d Z ddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlZddlmZ ddlmZ ddlmZ ejd	d
gddd Zejdd Zejdd Zejdd Zejdd Zejdd Zejdd Zejdd ZG dd dZG dd deejZ G d d! d!eej!Z"G d"d# d#eej#Z$G d$d% d%ej%Z&G d&d' d'eej'Z(G d(d) d)eej)Z*G d*d+ d+eej+Z,G d,d- d-eej-Z.G d.d/ d/eej/Z0G d0d1 d1eej1Z2G d2d3 d3eej3Z4G d4d5 d5eej5Z6G d6d7 d7eej7Z8G d8d9 d9eej9Z:G d:d; d;eej;Z<G d<d= d=eej=Z>dS )>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DZ2D)paramsc                 C   s   t | jdS )Nfreq)r   param)request r   F/tmp/pip-unpacked-wheel-vdrwu74i/pandas/tests/extension/test_period.pydtype   s    r   c                 C   s   t tdd| jdS )Ni  i  r
   )r   npZaranger   r   r   r   r   data$   s    r   c                 C   s   t tdd | jdS )Nd      r
   )r   r   Zonesr   r   r   r   r   data_for_twos)   s    r   c                 C   s   t dddg| jdS )N      r
   )r   r   r   r   r   r   data_for_sorting.   s    r   c                 C   s   t tdg| jdS )Nr   r
   r   r   r   r   r   r   r   data_missing3   s    r   c                 C   s   t dtdg| jdS )Nr   r   r
   r   r   r   r   r   data_missing_for_sorting8   s    r   c              	   C   s.   d}t }d}d}t||||||||g| jdS )Nr   r   r   r
   )r   r   r   )r   BZNAACr   r   r   data_for_grouping=   s
    r!   c                   C   s   t jS N)pdZNaTr   r   r   r   na_valueF   s    r$   c                   @   s   e Zd ZdS )BasePeriodTestsN__name__
__module____qualname__r   r   r   r   r%   K   s   r%   c                   @   s   e Zd ZdS )TestPeriodDtypeNr&   r   r   r   r   r*   O   s   r*   c                   @   s   e Zd ZdS )TestConstructorsNr&   r   r   r   r   r+   S   s   r+   c                   @   s   e Zd ZdS )TestGetitemNr&   r   r   r   r   r,   W   s   r,   c                   @   s   e Zd ZdS )	TestIndexNr&   r   r   r   r   r-   [   s   r-   c                       s6   e Zd Zdd Zejdddg fddZ  ZS )TestMethodsc                 C   s   d S r"   r   )selfZdata_repeatedr   r   r   test_combine_add`   s    zTestMethods.test_combine_addperiods   c              	      sF   t  r4tr4tjtdd t || W 5 Q R X nt || d S )NF)Zcheck_stacklevel)r   r   tmZassert_produces_warningRuntimeWarningsuper	test_diff)r/   r   r1   	__class__r   r   r7   d   s    
zTestMethods.test_diff)	r'   r(   r)   r0   pytestmarkparametrizer7   __classcell__r   r   r8   r   r.   _   s   r.   c                   @   s   e Zd ZdS )TestInterfaceNr&   r   r   r   r   r>   m   s   r>   c                       s\   e Zd ZddhZ fddZ fddZ fddZef fd	d
	Zdd Z	dd Z
  ZS )TestArithmeticOps__sub____rsub__c                    sB   || j kr0td|i}| j|||d d d nt || d S )Nr   r   exc)
implementsr#   	DataFramecheck_opnamer6   test_arith_frame_with_scalar)r/   r   all_arithmetic_operatorsZdfr8   r   r   rG   t   s    
z.TestArithmeticOps.test_arith_frame_with_scalarc                    s@   || j kr.t|}| j|||jd d d nt || d S Nr   rB   rD   r#   SeriesrF   Zilocr6   test_arith_series_with_scalarr/   r   rH   sr8   r   r   rL   }   s    

z/TestArithmeticOps.test_arith_series_with_scalarc                    s@   || j kr.t|}| j|||jd d d nt || d S rI   rJ   rM   r8   r   r   test_arith_series_with_array   s    

z.TestArithmeticOps.test_arith_series_with_arrayc                    s   t  j|||td d S )NrB   )r6   _check_divmod_op	TypeError)r/   rN   opotherrC   r8   r   r   rP      s    z"TestArithmeticOps._check_divmod_opc              	   C   s4   t |}d}tjt|d ||  W 5 Q R X d S )NzIunsupported operand type\(s\) for \+: \'PeriodArray\' and \'PeriodArray\')match)r#   rK   r:   ZraisesrQ   )r/   r   rN   msgr   r   r   $test_add_series_with_extension_array   s
    
z6TestArithmeticOps.test_add_series_with_extension_arrayc                 C   s6   t |}|t jkr| }||}|tks2td S r"   )r#   rK   rE   Zto_framer@   NotImplementedAssertionError)r/   r   Zframe_or_seriesrS   resultr   r   r   6test_direct_arith_with_ndframe_returns_not_implemented   s
    


zHTestArithmeticOps.test_direct_arith_with_ndframe_returns_not_implemented)r'   r(   r)   rD   rG   rL   rO   NotImplementedErrorrP   rV   rZ   r=   r   r   r8   r   r?   q   s   		
r?   c                   @   s   e Zd ZdS )TestCastingNr&   r   r   r   r   r\      s   r\   c                   @   s   e Zd ZdS )TestComparisonOpsNr&   r   r   r   r   r]      s   r]   c                   @   s   e Zd ZdS )TestMissingNr&   r   r   r   r   r^      s   r^   c                   @   s   e Zd ZdS )TestReshapingNr&   r   r   r   r   r_      s   r_   c                   @   s   e Zd ZdS )TestSetitemNr&   r   r   r   r   r`      s   r`   c                   @   s   e Zd ZdS )TestGroupbyNr&   r   r   r   r   ra      s   ra   c                   @   s   e Zd ZdS )TestPrintingNr&   r   r   r   r   rb      s   rb   c                       s.   e Zd Zejdddg fddZ  ZS )TestParsingenginecpythonc                    s   t  || d S r"   )r6   test_EA_types)r/   rd   r   r8   r   r   rg      s    zTestParsing.test_EA_types)r'   r(   r)   r:   r;   r<   rg   r=   r   r   r8   r   rc      s   rc   c                   @   s   e Zd ZdS )Test2DCompatNr&   r   r   r   r   rh      s   rh   )?__doc__Znumpyr   r:   Zpandas._libsr   Zpandas.compatr   Zpandas.compat.numpyr   Zpandas.core.dtypes.dtypesr   Zpandasr#   Zpandas._testingZ_testingr4   Zpandas.core.arraysr   Zpandas.tests.extensionr   Zfixturer   r   r   r   r   r   r!   r$   r%   ZBaseDtypeTestsr*   ZBaseConstructorsTestsr+   ZBaseGetitemTestsr,   ZBaseIndexTestsr-   ZBaseMethodsTestsr.   ZBaseInterfaceTestsr>   ZBaseArithmeticOpsTestsr?   ZBaseCastingTestsr\   ZBaseComparisonOpsTestsr]   ZBaseMissingTestsr^   ZBaseReshapingTestsr_   ZBaseSetitemTestsr`   ZBaseGroupbyTestsra   ZBasePrintingTestsrb   ZBaseParsingTestsrc   ZNDArrayBacked2DTestsrh   r   r   r   r   <module>   sV   







6