o
    ŀg<"                     @   s  d Z ddlZddlZddlmZ ddlZddlm	Z
 ddlmZ ejejddgedejddgedejddgedejdd	gedejd
dgedejddgddejddgddgddd Zejdg ddd Zejdg d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(d) Z!d*d+ Z"d,d- Z#d.d/ Z$d0d1 Z%d2d3 Z&d4d5 Z'd6d7 Z(ejd8ej)ej*ej+gd9d: Z,d;d< Z-d=d> Z.ejd?degd@dA Z/dBdC Z0dDdE Z1ejd?ej2ej3gdFdG Z4dHdI Z5dS )JzV
Additional tests for NumpyExtensionArray that aren't covered by
the interface tests.
    NNumpyEADtype)NumpyExtensionArrayabdtype   y      ?       @TFdatetime64[ns]ztimedelta64[ns])paramsc                 C   s   | j S )zk
    Parametrized fixture for NumPy arrays with different dtypes.

    This excludes string and bytes.
    )param)request r   Y/var/www/html/myenv/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/test_numpy.pyany_numpy_array   s   r   zdtype, expected)
boolT)intT)uintT)floatT)complexTstrFbytesFr
   FobjectFvoidFc                 C      t | } | j|u sJ d S N)r   _is_numericr   expectedr   r   r   test_is_numeric'      r%   )
r   )r   F)r   F)r   F)r   Fr   r   r   r   r   c                 C   r    r!   )r   _is_booleanr#   r   r   r   test_is_boolean;   r&   r(   c                  C   s"   t td} t| dksJ d S )Nint64zNumpyEADtype('int64'))r   npr   reprr   r   r   r   	test_reprO   s   r,   c                  C   s(   t d} t td}| |ksJ d S )Nr)   )r   construct_from_stringr*   r   )resultr$   r   r   r   test_constructor_from_stringT   s   
r/   c                 C   s    t | }t |}||ksJ d S r!   r   )any_numpy_dtyper   r.   r   r   r   test_dtype_idempotentZ   s   r1   c                   C   s@   t jtdd tg d W d    d S 1 sw   Y  d S )NzNumPy arraymatchr	         )pytestraises
ValueErrorr   r   r   r   r   test_constructor_no_coercione   s   "r:   c                  C   s2   t g d} tjt| dd}|j| usJ d S )Nr4   Tcopy)r*   arraypdSeriesr   values)ndarrayserr   r   r   !test_series_constructor_with_copyj   s   rC   c                  C   sB   t g d} tjt| dd}tjg ddd}t|| d S )Nr4   float64r   )      ?g       @g      @)r*   r=   r>   r?   r   tmassert_series_equal)rA   r.   r$   r   r   r   #test_series_constructor_with_astypeq   s   rH   c                  C   sF   t jg ddd} tj| dd}tt jg ddd}t|| d S )Nr4   r)   r   uint64)r*   r=   r   _from_sequencerF   assert_extension_array_equalarrr.   r$   r   r   r   test_from_sequence_dtypex   s   rN   c                  C   s.   t ddg} t| dd}t|| rJ d S )Nr   r	   Tr;   )r*   r=   r   rF   shares_memory)rM   r.   r   r   r   test_constructor_copy   s   rP   c                 C   s"   | }t |}|jj|jksJ d S r!   )r   r   numpy_dtyper   nparrrM   r   r   r   test_constructor_with_data   s   rT   c                  C   sp   t tg d} |  }|| ju sJ | jdd}|| jus!J | jdd}tjg ddd}t|| d S )Nr4   Tr;   f8r   )r   r*   r=   to_numpy_ndarrayrF   assert_numpy_array_equalrL   r   r   r   test_to_numpy   s   rY   c                  C   s6   t g d} d| jd< t g d}t| | d S )Nr4   
   r   )rZ   r5   r6   )r>   r?   r=   rF   rG   )rB   r$   r   r   r   test_setitem_series   s   
r[   c                 C   s<   | }t |dd}|d |d< |d |d< t| | d S )NTr;   r	   r   )r   rF   rX   rV   rR   r   r   r   test_setitem   s
   r\   c                  C   s\   t jg ddd} t| } d}tjt|d | | W d    d S 1 s'w   Y  d S )Nr4   r)   r   z)cannot perform not_a_method with type intr2   )r*   r=   r   r7   r8   	TypeError_reducerM   msgr   r   r   test_bad_reduce_raises   s   "ra   c                  C   sV   t tg d} d}tjt|d | jdd W d    d S 1 s$w   Y  d S )Nr4   z/the 'keepdims' parameter is not supported .*allr2   T)keepdims)r   r*   r=   r7   r8   r9   allr_   r   r   r   $test_validate_reduction_keyword_args   s
   "rd   c                  C   s|   g d} t | }|j}| |d u sJ | |d u s J tj|}||d ks.J tj|}||d ks<J d S )N))jklm)rh   op)rk   re   r5   )r>   r?   r=   maxr*   maximumreduce)valsrB   rM   r.   r   r   r   test_np_max_nested_tuples   s   
rr   c                  C   sZ   t ddd} t| }t jj|dd}t||d  |jdd}t||d  d S )N      r6   r   )axis)	r*   arangereshaper   ro   rp   rF   rK   rn   )rawrM   resaltr   r   r   test_np_reduce_2d   s   r|   ufuncc                 C   sb   t tg d}| |}t | |j}t|| t tg d}| ||d t|| d S )Ng              rE   )      "r   r   )out)r   r*   r=   rW   rF   rK   )r}   rM   r.   r$   r   r   r   r   test_ufunc_unary   s   r   c                  C   sr   t tg d} t| t| d\}}t| jt| jd\}}t |}t |}t|| t|| d S )Nr~   r5   )r   r*   r=   divmodaddrW   rF   rK   )rM   r1r2e1e2r   r   r   
test_ufunc   s   r   c                  C   s<   t tg d} | |  }t tg d}t|| d S )Nr4   )r5   rt      r   r*   r=   rF   rK   )xr.   r$   r   r   r   test_basic_binop  s   r   r   c                 C   sD   t tjg d| d}d|d< t tjg d| d}t|| d S )N)r   r   cr   tr   )r   r   r   r   )r   rM   r$   r   r   r   test_setitem_object_typecode
  s   r   c                  C   sx   t tg d} tjtdd d| d< W d    n1 sw   Y  d| d< t| d ttjfs:J t	| d d S )Nr4   r   r2   r   r         @)
r   r*   r=   r7   r8   r9   
isinstancer   integertype)rM   r   r   r   test_setitem_no_coercion  s   
(r   c                  C   s   t tg d} |  }| d d  }t| }d| d< |d dks$J |d dks,J |d dks4J d| d< d|d< | d dksDJ d S )Nr4   	   r   r   rv      )r   r*   r=   viewasarray)rM   view1view2view3r   r   r   test_setitem_preserves_views  s   
r   c                 C   sT   t tjg | d}tddg}|j|dd}t ttjtjg}t|| d S )Nr   r   g      ?linear)interpolation)	r   r*   r=   r>   Index	_quantilenanrF   rK   )r   rM   idxr.   r$   r   r   r   test_quantile_empty/  s
   r   c                  C   sV   t jg dt jd} t| }| \}}t| \}}t|| t|t| d S )Nr4   r   )	r*   r=   rI   r   	factorizer>   rF   rX   rK   )rM   obj	res_codes
res_unique	exp_codes
exp_uniquer   r   r   test_factorize_unsigned:  s   r   )6__doc__numpyr*   r7   pandas.core.dtypes.dtypesr   pandasr>   pandas._testing_testingrF   pandas.arraysr   fixturer=   r   r   r   r   r   r   markparametrizer%   r(   r,   r/   r1   r:   rC   rH   rN   rP   rT   rY   r[   r\   ra   rd   rr   r|   absnegativepositiver   r   r   r   r   r   r)   rI   r   r   r   r   r   r   <module>   sn    




	


