o
    ôT·j  ã                   @   s°  d dl Z d dlZd dlmZ d dlmZ e j dddg d¢dfddg d	¢dfddg d
¢dfddg d
¢dfdgdg d¢dfddgdg d¢dfddgdg d¢dfddg d¢dfddg d
¢dfdgdgg d¢dfddgddgg d¢dfg d
¢g d¢g d¢dfddg d¢dfdej	g d¢dfddg d¢dfg d¢dg d¢dfg¡e j 
d¡dd„ ƒƒZe j dd d!d"d!gd#fd!d$d"d gdfd"d"d"d gdfd dd"dgd%fg¡d&d'„ ƒZd(d)„ Zd*d+„ ZdS ),é    N)ÚCategoricalz)to_replace,value,expected,flip_categoriesé   é   )r   r   é   Fé   )r   r   r   ©r   r   r   é   é   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r	   )r   r   r   )r   r   r   )Nr   r   Ú4)r   r   r
   )r   r   Ú3Ú5)r   r   r   Tz:ignore:.*with CategoricalDtype is deprecated:FutureWarningc                 C   s~   t jg d¢dd�}| | |¡}t j|dd�}|j| |dd� |r-|j |jjd d d… ¡}tj||dd� tj||dd� d S )	Nr   Úcategory©ÚdtypeT©ÚinplaceéÿÿÿÿF©Úcheck_category_order)ÚpdÚSeriesÚreplaceÚcatÚset_categoriesÚ
categoriesÚtmÚassert_series_equal)Ú
to_replaceÚvalueÚexpectedÚflip_categoriesÚserÚresult© r#   úo/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/pandas/tests/arrays/categorical/test_replace.pyÚtest_replace_categorical_series   s    r%   z-to_replace, value, result, expected_error_msgÚbÚcÚaz$Categorical.categories are differentÚdz+Categorical.categories length are differentc           	      C   s  t ddgƒ}t |ƒ}d}|d urtnd }tj||d�� tj|dd� | |¡j}W d   ƒ n1 s2w   Y  t ||¡ | dkr^t	j
t|d�� t ||¡ W d   ƒ n1 sYw   Y  tj|dd�}tj||d�� |j| |dd� W d   ƒ n1 sw   Y  t ||¡ d S )	Nr(   r&   úOThe behavior of Series\.replace \(and DataFrame.replace\) with CategoricalDtype©ÚmatchF)ÚcopyTr   )r   ÚFutureWarningr   Úassert_produces_warningr   r   r   Ú_valuesÚassert_categorical_equalÚpytestÚraisesÚAssertionError)	r   r   r"   Úexpected_error_msgr   r   ÚmsgÚwarnr!   r#   r#   r$   Útest_replace_categorical4   s$   ÿÿþÿr8   c                  C   sŽ   t tjddgdd�ƒ} d}tjt|d�� t | ¡ ddgdtjg¡j	}W d   ƒ n1 s.w   Y  t tjdtjgdd�ƒ}t 
||¡ d S )Nr(   r&   Ústringr   r*   r+   r'   )r   r   Úarrayr   r/   r.   r   r   ÚNAr0   r1   )r   r6   r"   r   r#   r#   r$   Ú!test_replace_categorical_ea_dtypeV   s   ÿ ÿr<   c                  C   sš   t jg d¢dd�} t jg d¢| d�}d}tjt|d�� | dd¡}W d   ƒ n1 s,w   Y  t jd	dgdd�}t jg d
¢|d�}tj||dd� d S )N)r   r   r   T)Úorderedr   r*   r+   r   r   r   )r   r   r   r   )r   ÚCategoricalDtyper   r   r/   r.   r   r   )r   r!   r6   r"   Úexpected_dtyper   r#   r#   r$   Útest_replace_maintain_orderingc   s   ÿÿr@   )r2   Úpandasr   r   Úpandas._testingÚ_testingr   ÚmarkÚparametrizer;   Úfilterwarningsr%   r8   r<   r@   r#   r#   r#   r$   Ú<module>   sN    ëþÿûþ

