o
    _~#g*                     @   sJ   d dl Zd dlZd dlZd dlmZmZmZ d dlm	Z
 G dd dZdS )    N)	DataFrameSeries
date_rangec                   @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )TestDataFrameRoundc                 C   s>  t  }t||  t g dg dd}t g dg dd}t| | d}t g dg dd}t||| tt||| ddg}d	}tjt|d
 || W d    n1 sfw   Y  t g dg dd}ddd}t||| t g dg dd}ddi}t||| ddd}	t||	| ddd}
d}tjt|d
 ||
 W d    n1 sw   Y  ddd}
tjt|d
 ||
 W d    n1 sw   Y  t|
}tjt|d
 || W d    n	1 s
w   Y  dddgd}
tjt|d
 ||
 W d    n	1 s.w   Y  t|
}tjt|d
 || W d    n	1 sOw   Y  t|
}tjt|d
 || W d    n	1 spw   Y  t|
}tjt|d
 || W d    n	1 sw   Y  ddd}|d }t g dg dd}t||| ttj	dd}tjt|d
 || W d    n	1 sw   Y  t
|d d|d  d}t g dg dd}d|j_d|j_t||| t
|d ||d  t
||d |d  d S )Ng+?gCl @gCl@gX9v?gZd;@gZd;	@col1col2      ?       @      @   )gQ?g(\ @g(\@)gGz?gףp=
@gףp=
	@   z4decimals must be an integer, a dict-like or a Seriesmatch)皙?g @g@)g333333?皙@g	@r
   )col3r
   g      ?z#Values in decimals must be integersfood   )g     [@   i6  )g      Y@   i,  r	   cols)r   tmassert_frame_equalroundnppytestraises	TypeErrorr   nanassert_series_equalcolumnsname)selfdfexpected_roundeddecimals
round_listmsg
round_dictexpected_partially_roundedpartial_round_dictwrong_round_dictnon_int_round_dictnon_int_round_Seriesnegative_round_dictbig_dfexpected_neg_roundednan_round_Series r8   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pandas/tests/frame/methods/test_round.py
test_round   s   




zTestDataFrameRound.test_roundc                 C   s   t ddgddgg}tj|dd}t ddgd	d
gg}t|| d}tjt|d tj|d|d W d    d S 1 s>w   Y  d S )N{Gz?g(\?Q?g
ףp=
@r   )r+   r   r           g      @z$the 'out' parameter is not supportedr   )r+   out)r   r    r   r   r   r!   r"   
ValueError)r(   r)   r>   expectedr-   r8   r8   r9   test_round_numpy   s   "z#TestDataFrameRound.test_round_numpyc                 C   sj   t dtjdg }td  | }W d    n1 sw   Y  t dtjdg }t|| d S )Nr;   r<   r   r=   )r   r    r$   to_framer   assert_produces_warningr   r   )r(   r)   resultr@   r8   r8   r9   test_round_numpy_with_nan   s   
z,TestDataFrameRound.test_round_numpy_with_nanc                 C   s   t g dg dtdddd}t g dg dtdddd}t| | t|d| t|d	di| t|d	d
i| t|d
dd| t|ddi| d S )N)r   r   gffffff
@g@)1acf20111111   )periods)r	   r
   r   )r   r   r   g      @r   r	   r   r   r   )r   r   r   r   r   )r(   r)   round_0r8   r8   r9   test_round_mixed_type   s$   

z(TestDataFrameRound.test_round_mixed_typec                 C   s   t tjdddgg dg dd}tj||fdd}| }t|j	|j	 t
g dg d	d
}d}tjt|d || W d    d S 1 sMw   Y  d S )Nr      )ABC)firstsecondthird)r&   indexr   )axis)r   r   r   )rP   rQ   rP   )rV   z Index of decimals must be uniquer   )r   r    randomdefault_rngpdconcatr   r   assert_index_equalrV   r   r!   r"   r?   )r(   r)   dfsroundedr+   r-   r8   r8   r9   !test_round_with_duplicate_columns   s   "z4TestDataFrameRound.test_round_with_duplicate_columnsc                 C   s@   t g dg dd}t g dg dd}tt|| d S )Nr   r   r   r   )r   r   r   r   )r(   r)   r*   r8   r8   r9   test_round_builtin   s   z%TestDataFrameRound.test_round_builtinc                 C   s   t dgd dgd  }ttjddtdd}|d}||_|	 
|}|jdks2J |d}|jdks>J t|| d S )NlowrO   hir   )   rO   abcr&   )rZ   CategoricalIndexr   r    rX   rY   listr   rV   copy	set_indexshaper   r   )r(   idxr)   r@   df_categoricalrD   r8   r8   r9    test_round_nonunique_categorical   s   

z3TestDataFrameRound.test_round_nonunique_categoricalc                 C   sZ   t t dd}tddgddgg|d}| }tddgd	d	gg|d}t|| d S )
Nr   r   gQ?r   g333333?g      ?re   r   r=   )rZ   rf   interval_ranger   r   r   r   )r(   r&   r)   rD   r@   r8   r8   r9   $test_round_interval_category_columns   s
   z7TestDataFrameRound.test_round_interval_category_columnsc                 C   s*   t  }| }t|| ||usJ d S )N)r   r   r   r   )r(   r)   rD   r8   r8   r9   test_round_empty_not_input   s   z-TestDataFrameRound.test_round_empty_not_inputN)__name__
__module____qualname__r:   rA   rE   rN   r_   r`   rm   ro   rp   r8   r8   r8   r9   r      s    q		r   )numpyr    r!   pandasrZ   r   r   r   pandas._testing_testingr   r   r8   r8   r8   r9   <module>   s    