U
    f/ep                     @   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 }|t jj| d }dd t||D S )Nd   )sizec                 S   s   g | ]\}}t ||qS  r   ).0leftrightr
   r
   H/tmp/pip-unpacked-wheel-tiezk1ph/pandas/tests/extension/test_interval.py
<listcomp>   s     zmake_data.<locals>.<listcomp>)nprandomuniformZcumsumzip)NZ
left_arrayZright_arrayr
   r
   r   	make_data   s    r   c                   C   s   t  S Nr   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 ddgS )zLength 2 array with [NA, Valid]Nr      r   from_tuplesr
   r
   r
   r   data_missing,   s    r   c                   C   s   t dddgS )Nr      r      r   r   r
   r
   r
   r   data_for_sorting2   s    r"   c                   C   s   t dd dgS )Nr   r   r   r
   r
   r
   r   data_missing_for_sorting7   s    r#   c                   C   s   t jS r   )r   nanr
   r
   r
   r   na_value<   s    r%   c               
   C   s&   d} d}d}t ||d d | | ||gS )Nr   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 )	TestDtypeNr+   r
   r
   r
   r   r/   M   s   r/   c                   @   s   e Zd ZdS )TestCastingNr+   r
   r
   r
   r   r0   Q   s   r0   c                   @   s   e Zd ZdS )TestConstructorsNr+   r
   r
   r
   r   r1   U   s   r1   c                   @   s   e Zd ZdS )TestGetitemNr+   r
   r
   r
   r   r2   Y   s   r2   c                   @   s   e Zd ZdS )TestGroupingNr+   r
   r
   r
   r   r3   ]   s   r3   c                   @   s   e Zd Zdd ZdS )TestInterfacec                 C   s   |   d S r   )view)selfr   r
   r
   r   	test_viewb   s    zTestInterface.test_viewN)r,   r-   r.   r7   r
   r
   r
   r   r4   a   s   r4   c                   @   s   e Zd ZdS )
TestReduceNr+   r
   r
   r
   r   r8   h   s   r8   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 r   r
   )r6   Zdata_repeatedr
   r
   r   test_combine_addm   s    zTestMethods.test_combine_addzNot Applicablec                 C   s   d S r   r
   )r6   r   r
   r
   r   test_fillna_length_mismatchq   s    z'TestMethods.test_fillna_length_mismatchN)r,   r-   r.   pytestmarkskipr<   r=   r
   r
   r
   r   r9   l   s   
r9   c                   @   s\   e Zd ZejdZed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 r   r
   r6   r
   r
   r   test_fillna_limit_pad{   s    z!TestMissing.test_fillna_limit_padc                 C   s   d S r   r
   rB   r
   r
   r   test_fillna_series_method   s    z%TestMissing.test_fillna_series_methodc                 C   s   d S r   r
   rB   r
   r
   r   test_fillna_limit_backfill   s    z&TestMissing.test_fillna_limit_backfillc                 C   s   d S r   r
   rB   r
   r
   r   test_fillna_no_op_returns_copy   s    z*TestMissing.test_fillna_no_op_returns_copyc                 C   s   d S r   r
   rB   r
   r
   r   test_fillna_series   s    zTestMissing.test_fillna_seriesc              	   C   s0   d}t jt|d |ddg W 5 Q R X d S )Nz=can only insert Interval objects and NA into an IntervalArraymatchr   )r>   raises	TypeErrorZfillna)r6   r   msgr
   r
   r   test_fillna_non_scalar_raises   s    z)TestMissing.test_fillna_non_scalar_raisesN)r,   r-   r.   r>   r?   r@   Zunsupported_fillrC   rD   rE   rF   rG   rM   r
   r
   r
   r   rA   v   s   




rA   c                   @   s   e Zd ZdS )TestReshapingNr+   r
   r
   r
   r   rN      s   rN   c                   @   s   e Zd ZdS )TestSetitemNr+   r
   r
   r
   r   rO      s   rO   c                   @   s"   e Zd Zejjdddd ZdS )TestPrintingzcustom reprr:   c                 C   s   d S r   r
   )r6   r   r	   r
   r
   r   test_array_repr   s    zTestPrinting.test_array_reprN)r,   r-   r.   r>   r?   r@   rQ   r
   r
   r
   r   rP      s   rP   c                       s.   e Zd Zejdddg fddZ  ZS )TestParsingenginer(   pythonc              	      s0   d}t jt|d t || W 5 Q R X d S )Nz,.*must implement _from_sequence_of_strings.*rH   )r>   rJ   NotImplementedErrorsupertest_EA_types)r6   rS   r   Zexpected_msg	__class__r
   r   rW      s    zTestParsing.test_EA_types)r,   r-   r.   r>   r?   ZparametrizerW   __classcell__r
   r
   rX   r   rR      s   rR   )0__doc__Znumpyr   r>   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BaseCastingTestsr0   ZBaseConstructorsTestsr1   ZBaseGetitemTestsr2   ZBaseGroupbyTestsr3   ZBaseInterfaceTestsr4   ZBaseNoReduceTestsr8   ZBaseMethodsTestsr9   ZBaseMissingTestsrA   ZBaseReshapingTestsrN   ZBaseSetitemTestsrO   ZBasePrintingTestsrP   ZBaseParsingTestsrR   r
   r
   r
   r   <module>   sF   







