3
Ud2                 @   s  d dl Zd dlZd dlZd dljZd dlm	Z	 d dl
mZ ejdd Zdd Zdd	 Zd
d Zdd Zejjddddejejgdddddgfdejgddgfdejgddgfejejgddgfejejejgedddgfgdd Zejjdddgddgddgddgejdddejdgejddgejddgejddigg	d d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Z d.d/ Z!d0d1 Z"ejjd2ddgd3d4gd5d6d7 Z#d8d9 Z$dS ):    N)BooleanArray)coerce_to_arrayc               C   s:   t jddgd tjg ddgd  tjg ddg ddS )NTF   ,   boolean)dtype)pdarraynpnan r   r   a/var/www/html/virt/lib64/python3.6/site-packages/pandas/tests/arrays/boolean/test_construction.pydata
   s    .r   c           /   C   sR  t jddddgdd} t jddddgdd}t| |}tjdddd gdd}tj|| tjtdd t| j	 | W d Q R X tjtdd t| |j	  W d Q R X tjtdd t| j
t| W d Q R X tjtdd t| d  W d Q R X tjtd	d t| jd
d| W d Q R X tjtdd t| |jd
d W d Q R X d S )NTFbool)r   r   z$values should be boolean numpy array)matchz"mask should be boolean numpy arrayzvalues must be a 1D array   zmask must be a 1D arrayr   )r
   r	   r   r   tmassert_extension_array_equalpytestraises	TypeErrortolistZastypeint
ValueErrorreshape)valuesmaskresultexpectedr   r   r   test_boolean_array_constructor   s"    
r    c              C   s   t jddddgdd} t jddddgdd}t| |}|j| ksDt|j|ksRtt| |dd}|j| k	snt|j|k	s|td S )NTFr   )r   )copy)r
   r	   r   _dataAssertionError_mask)r   r   r   r   r   r   #test_boolean_array_constructor_copy-   s    
r%   c              C   s  t tjdddgtjdddg} tjdddgdd}tj||  tjtjdddgdd}tj||  tjtjdddgtddd}tj||  t tjdddgtjdddg} tjddd gdd}tj||  tjtjddd gtddd}tj||  d S )NTFr   )r   )r   r
   r	   r   r   r   object)r   r   r   r   r   test_to_boolean_array:   s      r'   c              C   sp   t tjdddgtjdddg} tjd d d gdd}tj||  tjtjd d d gtddd}tj||  d S )NTr   )r   )r   r
   r	   r   r   r   r&   )r   r   r   r   r   test_to_boolean_array_all_noneQ   s
    "r(   za, bTF)r   c             C   s,   t j| dd}t j|dd}tj|| d S )Nr   )r   )r   r	   r   r   )abr   r   r   r   r   (test_to_boolean_array_missing_indicatorsZ   s    r+   r   Zfoobar12r      g      ?g       @Z20130101)Zperiodsr)   c             C   s0   d}t jt|d tj| dd W d Q R X d S )NzNeed to pass bool-like value)r   r   )r   )r   r   r   r   r	   )r   msgr   r   r   test_to_boolean_array_errorj   s    r1   c              C   s   t jtjddddgdd} t jddddgdd}tj| | t jtjdddd gdd} t jdddd gdd}tj| | d S )Nr   r   r   )r   TF)r   r	   r
   r   r   )r   r   r   r   r   (test_to_boolean_array_from_integer_array   s    r2   c              C   s   t jtjddddgdd} t jddddgdd}tj| | t jtjdddtjgdd} t jdddd gdd}tj| | d S )Ng      ?g        r   )r   TF)r   r	   r
   r   r   r   )r   r   r   r   r   &test_to_boolean_array_from_float_array   s    r3   c              C   st   t jddddgdd} t jddddgdd}tj| | t jdddd gdd} t jdddd gdd}tj| | d S )Nr   r   r   )r   TF)r   r	   r   r   )r   r   r   r   r   "test_to_boolean_array_integer_like   s    r4   c              C   s  t jddddgdd} t jddddgdd}tt| |d }t| |}tj|| |j| ks`t|j|ksnttt| |dd }t| |}tj|| |j| k	st|j|k	stddd dg} t jddddgdd}tt| |d }tt jddddgt jddddg}tj|| ttt j| t	d|d }tj|| tt| |j
 d }tj|| t jddddgdd} t jddddgdd}tjtdd t| jd	d W d Q R X tjtd
d t| |jd	dd W d Q R X d S )NTFr   )r   )r   )r   r!   zvalues must be a 1D list-like)r   r   zmask must be a 1D list-liker   r   )r
   r	   r   r   r   r   r"   r#   r$   r&   r   r   r   r   r   )r   r   r   r   r   r   r   test_coerce_to_array   s8    

$r5   c              C   s   t jddddgdd} t jddddgdd}t| |}tt| }tj|| |j|jks^t|j|jksnttt|ddi}tj|| |j|jk	st|j|jk	stt	j
tdd t||d W d Q R X d S )	NTFr   )r   r!   z'cannot pass mask for BooleanArray input)r   )r   )r
   r	   r   r   r   r   r"   r#   r$   r   r   r   )r   r   arrr   r   r   r   'test_coerce_to_array_from_boolean_array   s    
r7   c              C   s   t jddd gdd} tj| }tjddt jgdd}tj|| t jdddgdd} tj| }tjdddgdd}tj|| tj| dd}tjdddgdd}tj|| t jddd gdd} d}tjt|d tj| dd W d Q R X d S )	NTFr   )r   r&   r   zqcannot convert to 'bool'-dtype NumPy array with missing values. Specify an appropriate 'na_value' for this dtype.)r   )	r   r	   r
   NAr   assert_numpy_array_equalr   r   r   )r6   r   r   r0   r   r   r   test_coerce_to_numpy_array   s    

r:   c           
   C   sf   t jtjddddddtjgtd} t tjdd	ddd	d	d	gtjd	d	d	d	d	d	dg}tj| | d S )
NTrueFalser-   z1.00z0.0)r   TF)r   _from_sequence_of_stringsr
   r	   r   r&   r   r   )r   r   r   r   r   "test_to_boolean_array_from_strings   s     r?   c            	   C   s*   t jtdd tjdg W d Q R X d S )Nzcannot be cast)r   Zdonkey)r   r   r   r   r>   r   r   r   r   1test_to_boolean_array_from_strings_invalid_string  s    r@   boxZseriesr	   )idsc             C   sZ  | r
t jnt j}|dddgdd}|j }tjdddgdd}tj|| |ddd gdd}|j }tjddt jgdd}tj|| |ddd gdd}|jdd}tjddt jgdd}tj|| |dddgdd}|jdd}tjdddgdd}tj|| |ddd gdd}tj	t
d	d
 |jdd}W d Q R X |ddd gdd}|jtd d}tjddd gdd}tj|| |jtdd}tjdddgdd}tj|| |jddd}tjdddgdd}tj|| |jdtjd}tjddtjgdd}tj|| tj	t
dd
 |jdd W d Q R X tj	t
dd
 |jdd W d Q R X d S )NTFr   )r   r&   strz<U5r   zcannot convert to 'bool'-dtype)r   )r   Zna_valueZint64c   r   r   Zfloat64zcannot convert to 'int64'-dtypez!cannot convert to 'float64'-dtypeii)r   ZSeriesr	   to_numpyr
   r   r9   r8   r   r   r   r&   r   r   )rA   conr6   r   r   r   r   r   test_to_numpy	  sJ    rG   c              C   s   t jdddgdd} | jtd}d|d< tj| t jdddgdd t jdddgdd} | jtdd}d|d< tj| t jdddgdd d S )NTFr   )r   r   )r   r!   )r   r	   rE   r   r   r   )r6   r   r   r   r   test_to_numpy_copy?  s    rH   )%Znumpyr
   r   Zpandasr   Zpandas._testingZ_testingr   Zpandas.arraysr   Zpandas.core.arrays.booleanr   Zfixturer   r    r%   r'   r(   markZparametrizer   r8   r	   floatr+   Z
date_ranger1   r2   r3   r4   r5   r7   r:   r?   r@   rG   rH   r   r   r   r   <module>   sL   
	*	

'"6