o
    _~#g                     @   s  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lZd dlmZ d dlmZ dd Zd	d
 Zdd Zdd Zdd Zejdd geddg dfd gdeddgfd gejeddgfg dedddgd fg deddeddeddgg dfgdd Zdd  Zd!d" Zd#d$ Zd%d& Z d'd( Z!ejd)ejdd*d+ej"g d,d-d.gd/d0 Z#d1d2 Z$d3d4 Z%dS )5    N)iNaT)IncompatibleFrequency)	_registry)PeriodDtype)PeriodArrayc                  C   s0   t tjv sJ td} t d}| |ksJ d S )Nz	Period[D]D)r   registrydtypesfindresultexpected r   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pandas/tests/arrays/test_period.pytest_registered   s   
r   c                  C   s4   t jg dddj} tddtg}t| | d S )N)20002001N	period[D]dtype*  ;,  )r   _from_sequenceasi8nparrayr   tmassert_numpy_array_equalr   r   r   r   	test_asi8   s   r   c                  C   s   t jddgdd} tjtdd | jddgd	tjdd
dd W d    n1 s*w   Y  d}tjt|d | jddgd	dd W d    d S 1 sNw   Y  d S )Nr   r   r   r   freqmatchr   TWr   )
allow_fill
fill_valuez6value should be a 'Period' or 'NaT'. Got 'str' insteadfoo)	r   r   pytestraisesr   takepdPeriod	TypeError)arrmsgr   r   r   test_take_raises#   s    "r0   c                  C   sX   t jg ddd} tjtdd | | d d  W d    d S 1 s%w   Y  d S )Nr   r   2002r   r   Lengthr       )r   r   r(   r)   
ValueErrorfillnar.   r   r   r   test_fillna_raises-   s   "r8   c                  C   s4   t jg ddd} | tdd}|| usJ d S )Nr1   r   r   r   r   )r   r   r6   r+   r,   )r.   r   r   r   r   test_fillna_copies3   s   r9   zkey, value, expectedr   r   )r      r4   r:   r4   )r   r:   r4   r      r   r2   )r   r   i-  c                 C   s6   t tddd}t |dd}||| < t|| d S )Nr;   r   r   )r   r   aranger   assert_period_array_equal)keyvaluer   r.   r   r   r   test_setitem=   s   r@   c                  C   s   t tddd} tjtdd tjddd| d	< W d    n1 s$w   Y  t jdd
gdd}tjtdd || d	dg< W d    d S 1 sKw   Y  d S )Nr;   r   r   r   r    r   Yr$   r   r   z	period[Y]r:   )	r   r   r<   r(   r)   r   r+   r,   r   r.   otherr   r   r   %test_setitem_raises_incompatible_freqR   s   "rD   c                  C   s^   t tddd} tjtdd tjdddg| d	d
g< W d    d S 1 s(w   Y  d S )Nr;   r   r   lengthr    r   r   r$   r   r:   )r   r   r<   r(   r)   r5   r+   r,   r7   r   r   r   test_setitem_raises_length\   s   "rF   c                  C   sN   t tddd} tjtdd d| d< W d    d S 1 s w   Y  d S )Nr;   r   r   intr    r:   r   )r   r   r<   r(   r)   r-   r7   r   r   r   test_setitem_raises_typeb   s   
"rH   c                  C   s\   t jddgdd} tjddd}tjtdd | |  W d    d S 1 s'w   Y  d S )	Nr   r   r   r   Mr$   r   r    )r   r   r+   r,   r(   r)   r   rB   r   r   r   test_sub_periodl   s
   
"rJ   c                  C   s   t jdddd} | d}t jd|j}tjtdd ||  W d    n1 s+w   Y  tjtdd ||  W d    d S 1 sGw   Y  d S )	Nz
1677-09-22r4   r   )periodsr   nsl    @ k zOverflow in int64 additionr    )	r+   
date_range	to_periodr,   _from_ordinalr   r(   r)   OverflowError)dtipiperr   r   r   test_sub_period_overflows   s   


"rT   rC   hr$   )r   r   r   z	period[h]r   c                 C   s   t tjg ddd}tg d}tjtdd |j	||  W d    n1 s,w   Y  |
|| }|t
|| }t|| d S )Nr1   r   r   )TFTr   r    )r+   Seriesr   r   r   r   r(   r)   r   _wherewhereastypeobjectr   assert_series_equal)rC   sercondresr   r   r   r    test_where_different_freq_raises   s   	r_   c                  C   s.   t jddgdd} t| }d}||ksJ d S )Nr   r   r   r   zF<PeriodArray>
['2000-01-01', '2001-01-01']
Length: 2, dtype: period[D]r   r   strr.   r   r   r   r   r   test_repr_small   s
   rc   c                  C   s2   t jddgd dd} t| }d}||ksJ d S )Nr   r   i  r   r   aM  <PeriodArray>
['2000-01-01', '2001-01-01', '2000-01-01', '2001-01-01', '2000-01-01',
 '2001-01-01', '2000-01-01', '2001-01-01', '2000-01-01', '2001-01-01',
 ...
 '2000-01-01', '2001-01-01', '2000-01-01', '2001-01-01', '2000-01-01',
 '2001-01-01', '2000-01-01', '2001-01-01', '2000-01-01', '2001-01-01']
Length: 1000, dtype: period[D]r`   rb   r   r   r   test_repr_large   s
   rd   )&numpyr   r(   pandas._libs.tslibsr   pandas._libs.tslibs.periodr   pandas.core.dtypes.baser   r   pandas.core.dtypes.dtypesr   pandasr+   pandas._testing_testingr   pandas.core.arraysr   r   r   r0   r8   r9   markparametrizer,   nanr@   rD   rF   rH   rJ   rT   r   r_   rc   rd   r   r   r   r   <module>   sR    

 



	