3
สb_j  ใ               @   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 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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/d0 d0eej,Z-G d1d2 d2eej.Z/dS )3aj  
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)ฺIntervalDtype)ฺInterval)ฺIntervalArray)ฺbasec              C   s<   d} t jj| dj }|t jj| d }dd t||D S )N้d   )ฺsizec             S   s   g | ]\}}t ||qS ฉ )r   )ฺ.0ฺlฺrr   r   ๚F/tmp/pip-build-jkwsxyiy/pandas/pandas/tests/extension/test_interval.py๚
<listcomp>   s    zmake_data.<locals>.<listcomp>)ฺnpฺrandomฺuniformZcumsumฺzip)ฺNฺleftฺrightr   r   r   ฺ	make_data   s    r   c               C   s   t  S )N)r   r   r   r   r   ฺdtype!   s    r   c               C   s
   t t S )z*Length-100 PeriodArray for semantics test.)r   r   r   r   r   r   ฺdata&   s    r   c               C   s   t jddgS )zLength 2 array with [NA, Valid]Nr   ้   )r   r   )r   ฺfrom_tuplesr   r   r   r   ฺdata_missing,   s    r   c               C   s   t jdddgS )Nr   ้   ้   r   )r   r   )r   r   )r   r   )r   r   r   r   r   r   ฺdata_for_sorting2   s    r   c               C   s   t jdd dgS )Nr   r   r   )r   r   )r   r   )r   r   r   r   r   r   ฺdata_missing_for_sorting7   s    r   c               C   s   t jS )N)r   ฺnanr   r   r   r   ฺna_value<   s    r    c           	   C   s&   d} d}d}t j||d d | | ||gS )Nr   r   r   r   )r   r   )r   r   )r   r   )r   r   )ฺaฺbฺcr   r   r   ฺdata_for_groupingA   s    r$   c               @   s   e Zd ZdS )ฺBaseIntervalN)ฺ__name__ฺ
__module__ฺ__qualname__r   r   r   r   r%   I   s   r%   c               @   s   e Zd ZdS )ฺ	TestDtypeN)r&   r'   r(   r   r   r   r   r)   M   s   r)   c               @   s   e Zd ZdS )ฺTestCastingN)r&   r'   r(   r   r   r   r   r*   Q   s   r*   c               @   s   e Zd ZdS )ฺTestConstructorsN)r&   r'   r(   r   r   r   r   r+   U   s   r+   c               @   s   e Zd ZdS )ฺTestGetitemN)r&   r'   r(   r   r   r   r   r,   Y   s   r,   c               @   s   e Zd ZdS )ฺTestGroupingN)r&   r'   r(   r   r   r   r   r-   ]   s   r-   c               @   s   e Zd Zdd ZdS )ฺTestInterfacec             C   s   |j   d S )N)ฺview)ฺselfr   r   r   r   ฺ	test_viewb   s    zTestInterface.test_viewN)r&   r'   r(   r1   r   r   r   r   r.   a   s   r.   c               @   s   e Zd ZdS )ฺ
TestReduceN)r&   r'   r(   r   r   r   r   r2   h   s   r2   c               @   s8   e Zd Zejjdddd Zejjdddd ZdS )	ฺTestMethodsz%addition is not defined for intervals)ฺreasonc             C   s   d S )Nr   )r0   Zdata_repeatedr   r   r   ฺtest_combine_addm   s    zTestMethods.test_combine_addzNot Applicablec             C   s   d S )Nr   )r0   r   r   r   r   ฺtest_fillna_length_mismatchq   s    z'TestMethods.test_fillna_length_mismatchN)r&   r'   r(   ฺpytestฺmarkฺskipr5   r6   r   r   r   r   r3   l   s   r3   c               @   sP   e Zd ZejjdZedd Zedd Zedd Z	edd	 Z
d
d ZdS )ฺTestMissingzUnsupported fillna option.c             C   s   d S )Nr   )r0   r   r   r   ฺtest_fillna_limit_pad{   s    z!TestMissing.test_fillna_limit_padc             C   s   d S )Nr   )r0   r   r   r   ฺtest_fillna_series_method   s    z%TestMissing.test_fillna_series_methodc             C   s   d S )Nr   )r0   r   r   r   ฺtest_fillna_limit_backfill   s    z&TestMissing.test_fillna_limit_backfillc             C   s   d S )Nr   )r0   r   r   r   ฺtest_fillna_series   s    zTestMissing.test_fillna_seriesc          
   C   s0   d}t jt|d |jddg W d Q R X d S )NzGot a 'list' instead.)ฺmatchr   )r7   ฺraisesฺ	TypeErrorZfillna)r0   r   ฺmsgr   r   r   ฺtest_non_scalar_raises   s    z"TestMissing.test_non_scalar_raisesN)r&   r'   r(   r7   r8   r9   Zunsupported_fillr;   r<   r=   r>   rC   r   r   r   r   r:   v   s   r:   c               @   s   e Zd ZdS )ฺTestReshapingN)r&   r'   r(   r   r   r   r   rD      s   rD   c                   s*   e Zd Zejjdd fddZ  ZS )ฺTestSetitemz)GH#27147 setitem changes underlying index)r4   c                s   t  j| d S )N)ฺsuperฺtest_setitem_preserves_views)r0   r   )ฺ	__class__r   r   rG      s    z(TestSetitem.test_setitem_preserves_views)r&   r'   r(   r7   r8   ZxfailrG   ฺ__classcell__r   r   )rH   r   rE      s   rE   c               @   s"   e Zd Zejjdddd ZdS )ฺTestPrintingzcustom repr)r4   c             C   s   d S )Nr   )r0   r   r   r   r   r   ฺtest_array_repr   s    zTestPrinting.test_array_reprN)r&   r'   r(   r7   r8   r9   rK   r   r   r   r   rJ      s   rJ   c                   s.   e Zd Zejjdddg fddZ  ZS )ฺTestParsingฺenginer#   ฺpythonc          
      s0   d}t jt|d t j|| W d Q R X d S )Nz,.*must implement _from_sequence_of_strings.*)r?   )r7   r@   ฺNotImplementedErrorrF   ฺtest_EA_types)r0   rM   r   Zexpected_msg)rH   r   r   rP   ข   s    zTestParsing.test_EA_types)r&   r'   r(   r7   r8   ZparametrizerP   rI   r   r   )rH   r   rL   ก   s   rL   )0ฺ__doc__Znumpyr   r7   Zpandas.core.dtypes.dtypesr   Zpandasr   Zpandas.core.arraysr   Zpandas.tests.extensionr   r   Zfixturer   r   r   r   r   r    r$   r%   ZBaseDtypeTestsr)   ZBaseCastingTestsr*   ZBaseConstructorsTestsr+   ZBaseGetitemTestsr,   ZBaseGroupbyTestsr-   ZBaseInterfaceTestsr.   ZBaseNoReduceTestsr2   ZBaseMethodsTestsr3   ZBaseMissingTestsr:   ZBaseReshapingTestsrD   ZBaseSetitemTestsrE   ZBasePrintingTestsrJ   ZBaseParsingTestsrL   r   r   r   r   ฺ<module>   s8   
