o
    i                     @   s>   d dl Z d dlZd dlmZmZ d dlmZ G dd dZdS )    N)assert_equalassert_array_equal)CensoredDatac                   @   sz   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
ejdejejgdd Zdd Zdd ZdS )TestCensoredDatac                 C   s   dg}dg}ddg}ddgg}t ||||d}t|j| t|j| t|j| t|j| | }t|t|||tj	|ddf d S )N   r            )leftrightinterval)Zaxis)
r   r   _uncensored_left_right	_intervalZ	_uncensornpZconcatenatemean)self
uncensoredr
   r   r   dataZudata r   ^/home/kim/smarthome/.venv/lib/python3.10/site-packages/scipy/stats/tests/test_censored_data.py
test_basic   s   
zTestCensoredData.test_basicc                 C   p   t g d}t jg dtd}t||}t|j||   t|j||  t|jg  t|j	t 
d d S N)r   r	         @)r   r   r   )Zdtyper   r   )r   arrayboolr   right_censoredr   r   r   r   r   emptyr   xZis_censoredr   r   r   r   test_right_censored      z$TestCensoredData.test_right_censoredc                 C   r   r   )r   r   r   r   left_censoredr   r   r   r   r   r    r!   r   r   r   test_left_censored$   r$   z#TestCensoredData.test_left_censoredc                 C   sn   g d}g d}t j||d}t|jttt|| |jj	dks%J |j
j	dks-J |jj	dks5J d S )N)      ?       @      @g      @)      ?r   g      @g      @lowhighr   )r   interval_censoredr   r   r   r   listzipr   shaper   r   r   abr   r   r   r   test_interval_censored_basic-   s   z-TestCensoredData.test_interval_censored_basicc                 C   s   dt j dddddg}ddt jddd	t jg}tj||d
}t|jddgdd	gg t|jddg t|jdg t|jddg d S )Nr'   g      *r(   r*   g      $@g      g     @r)   g      &@r+   )	r   infr   r/   r   r   r   r   r   r3   r   r   r   test_interval_censored_mixed6   s   z-TestCensoredData.test_interval_censored_mixedc              
   C   s   t ddgddgddgdt jgdt jgt j dgddgg}t|d}t|jddg t|jdg t|jddg t|jddgddgg d S )Nr   r   r   r	   	      r   )	r   r   r7   r   r   r   r   r   r   )r   r   r   r   r   r   test_interval_to_other_typesC   s   


z-TestCensoredData.test_interval_to_other_typesc                 C   sd   t g g g g d}|jjdksJ |jjdksJ |jjdks J |jjdks(J t|dks0J d S )N)r   r
   r   r   r.   r   r   )r   r   r2   r   r   r   len)r   r   r   r   r   test_empty_arraysU   s   z"TestCensoredData.test_empty_arraysc                 C   s  t jtdd tg dgd W d    n1 sw   Y  t jtdd tg dgd W d    n1 s9w   Y  t jtdd tg dgd W d    n1 sXw   Y  t jtdd tg dgd W d    n1 sww   Y  t jtd	d td
tjdgd W d    n1 sw   Y  t jtd	d td
tjdgd W d    n1 sw   Y  t jtd	d td
tjdgd W d    n1 sw   Y  t jtd	d td
tjgddggd W d    n1 sw   Y  t jtdd td
dgddgtjtjggd W d    n	1 s"w   Y  t jtdd td
dgddggd W d    d S 1 sFw   Y  d S )Nzmust be a one-dimensionalmatchr   r   r	   )r   )r
   )r   zmust be a two-dimensionalr;   zmust not contain nanr   r   r	   z both values must not be infiniter9   z$left value must not exceed the rightr   )pytestraises
ValueErrorr   r   nanr7   r   r   r   r   test_invalid_constructor_args]   sD   "$z.TestCensoredData.test_invalid_constructor_argsfuncc                 C   s  t jtdd |g dgg d W d    n1 sw   Y  t jtdd |g dg dg W d    n1 s=w   Y  t jtdd |ddtjgg d W d    n1 s_w   Y  t jtd	d |g dg d
 W d    d S 1 sw   Y  d S )Nz`x` must be one-dimensionalr?   rA   r   r   r   z"`censored` must be one-dimensionalz`x` must not containr   r   must have the same lengthr   r   r   r   )rB   rC   rD   r   rE   )r   rH   r   r   r   %test_invalid_left_right_censored_argsx   s    "z6TestCensoredData.test_invalid_left_right_censored_argsc                 C   s  t jtdd tjdggddgd W d    n1 sw   Y  t jtdd tjdgddggd W d    n1 s?w   Y  t jtdd td	d
tjgg d W d    n1 sbw   Y  t jtdd tg dg d W d    d S 1 sw   Y  d S )Nz`low` must be a one-dimensionalr?   r	      r   r+   z `high` must be a one-dimensionalz`low` must not containr   r   rI   rJ   rA   rK   )rB   rC   rD   r   r/   r   rE   rF   r   r   r   test_invalid_censored_args   s    "z+TestCensoredData.test_invalid_censored_argsc                 C   sL   g d}t |}| dksJ t dgdgddggd}| dks$J d S )NrA   r   r   
   r   )r   r
   r   r   )r   Znum_censored)r   r"   Zdata1Zdata2r   r   r   test_count_censored   s
   z$TestCensoredData.test_count_censoredN)__name__
__module____qualname__r   r#   r&   r6   r8   r<   r>   rG   rB   markZparametrizer   r%   r   rL   rN   rP   r   r   r   r   r   	   s    			
r   )	rB   numpyr   Znumpy.testingr   r   Zscipy.statsr   r   r   r   r   r   <module>   s
   