o
    Ti                     @   sv   d dl mZ d dlZd dlZd dlmZ d dlm	Z	 G dd dZ
G dd de
ZG dd	 d	e
ZG d
d de
ZdS )    )finalN)is_numeric_dtypec                   @   s   e Zd ZdZdedefddZdd Zdefdd	Ze	d
e
jdedefddZejdddgdd Zejdejdddgdd Zejdddgdd ZdS )BaseReduceTestszg
    Reduction specific tests. Generally these only
    make sense for numeric/boolean operations.
    op_namereturnc                 C   s   dS )NF selfobjr   r   r   b/var/www/html/evchargy.com/venv/lib/python3.10/site-packages/pandas/tests/extension/base/reduce.py_supports_reduction   s   z#BaseReduceTests._supports_reductionc           	   	   C   s~   t ||}z|d}W n ttfy   |t}Y nw t ||}|dkr-| }| }n
||d}||d}t|| d S )NZfloat64countskipna)getattrZastype	TypeError
ValueErrorobjecttmZassert_almost_equal)	r	   sr   r   Zres_opZaltZexp_opresultexpectedr   r   r   check_reduce   s   



zBaseReduceTests.check_reducec                 C   s   |j S )Ndtype)r	   arrr   r   r   r   _get_expected_reduction_dtype*   s   z-BaseReduceTests._get_expected_reduction_dtypeserr   c                 C   s   |j }td|i}|dv rddini }| ||}|j|f|dd|}t||d	d|i|j }	t||	 |sK| 	 rKtj tj
g|d}
nt| | }tj |g|d}
t||
 d S )
Na)varZstdZddof   T)r   Zkeepdimsr   r   r   )arraypdZ	DataFramer   Z_reducer   r   Zassert_extension_array_equalZisnaanyZNAZdropna)r	   r   r   r   r   ZdfkwargsZ	cmp_dtypeZresult1Zresult2r   Z	exp_valuer   r   r   check_reduce_frame4   s   z"BaseReduceTests.check_reduce_frameTFc                 C   t   |}t |}| ||s1d}tjt|d t|||d W d    d S 1 s*w   Y  d S | ||| d S NzV[Cc]annot perform|Categorical is not ordered for operation|does not support reduction|)matchr   r"   Seriesr   pytestZraisesr   r   r   )r	   dataZall_boolean_reductionsr   r   r   msgr   r   r   test_reduce_series_booleanO   s   
"z*BaseReduceTests.test_reduce_series_booleanzignore::RuntimeWarningc                 C   r&   r'   r)   )r	   r,   all_numeric_reductionsr   r   r   r-   r   r   r   test_reduce_series_numeric`   s   
"z*BaseReduceTests.test_reduce_series_numericc                 C   sj   |}t |}t|jstd |dv rt| d | ||s,td| d | ||| d S )Nznot numeric dtype)r   ZkurtZsemz not an array methodz
Reduction z not supported for this dtype)r"   r*   r   r   r+   skipr   r%   )r	   r,   r/   r   r   r   r   r   r   test_reduce_frames   s   


z!BaseReduceTests.test_reduce_frameN)__name__
__module____qualname____doc__strboolr   r   r   r   r"   r*   r%   r+   markZparametrizer.   filterwarningsr0   r2   r   r   r   r   r   
   s    


r   c                   @   s   e Zd ZdZdS )BaseNoReduceTestszwe don't define any reductionsN)r3   r4   r5   r6   r   r   r   r   r;      s    r;   c                   @      e Zd ZdedefddZdS )BaseNumericReduceTestsr   r   c                 C   s   |dv r	t d dS )Nr#   allz*These are tested in BaseBooleanReduceTestsTr+   r1   r   r   r   r   r         
z*BaseNumericReduceTests._supports_reductionNr3   r4   r5   r7   r8   r   r   r   r   r   r=          r=   c                   @   r<   )BaseBooleanReduceTestsr   r   c                 C   s   |dvr	t d dS )Nr>   z*These are tested in BaseNumericReduceTestsTr@   r   r   r   r   r      rA   z*BaseBooleanReduceTests._supports_reductionNrB   r   r   r   r   rD      rC   rD   )typingr   r+   Zpandasr"   Zpandas._testingZ_testingr   Zpandas.api.typesr   r   r;   r=   rD   r   r   r   r   <module>   s    z