a
    Qe                     @   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   X/var/www/sunrise/env/lib/python3.9/site-packages/scipy/stats/tests/test_censored_data.py
test_basic   s    
zTestCensoredData.test_basicc                 C   sp   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   s    z$TestCensoredData.test_right_censoredc                 C   sp   t g d}t jg dtd}t||}t|j||   t|j||  t|jg  t|j	t 
d d S r   )r   r   r   r   left_censoredr   r   r   r   r   r   r    r   r   r   test_left_censored$   s    z#TestCensoredData.test_left_censoredc                 C   sn   g d}g d}t j||d}t|jttt|| |jj	dksJJ |j
j	dksZJ |jj	dksjJ 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   r1   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   r5   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s0J |jjdks@J |jjdksPJ t|dks`J d S )N)r   r
   r   r   r,   r   r   )r   r   r0   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 s40    Y  t jtdd  tg dgd W d    n1 sr0    Y  t jtdd  tg dgd W d    n1 s0    Y  t jtdd  tg dgd W d    n1 s0    Y  t jtd	d" td
tjdgd W d    n1 s00    Y  t jtd	d" td
tjdgd W d    n1 sr0    Y  t jtd	d" td
tjdgd W d    n1 s0    Y  t jtd	d( td
tjgddggd W d    n1 s0    Y  t jtdd0 td
dgddgtjtjggd W d    n1 sL0    Y  t jtdd& td
dgddggd W d    n1 s0    Y  d S )Nzmust be a one-dimensionalmatchr   r   r	   )r   )r
   )r   zmust be a two-dimensionalr9   zmust not contain nanr   r   r	   z both values must not be infiniter7   z$left value must not exceed the rightr   )pytestraises
ValueErrorr   r   nanr5   r   r   r   r   test_invalid_constructor_args]   s0    ....2228@z.TestCensoredData.test_invalid_constructor_argsfuncc                 C   s  t jtdd$ |g dgg d W d    n1 s80    Y  t jtdd$ |g dg dg W d    n1 sz0    Y  t jtdd& |ddtjgg d W d    n1 s0    Y  t jtd	d" |g dg d
 W d    n1 s0    Y  d S )Nz`x` must be one-dimensionalr=   r?   r   r   r   z"`censored` must be one-dimensionalz`x` must not containr   r   must have the same lengthr   r   r   r   )r@   rA   rB   r   rC   )r   rF   r   r   r   %test_invalid_left_right_censored_argsx   s    224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:0    Y  t jtdd& tjdgddggd W d    n1 s~0    Y  t jtdd( td	d
tjgg d W d    n1 s0    Y  t jtdd$ tg dg d W d    n1 s0    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   rG   rH   r?   rI   )r@   rA   rB   r   r-   r   rC   rD   r   r   r   test_invalid_censored_args   s    446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sHJ d S )Nr?   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$   r4   r6   r:   r<   rE   r@   markZparametrizer   r#   r   rJ   rL   rN   r   r   r   r   r   	   s   			
r   )	r@   numpyr   Znumpy.testingr   r   Zscipy.statsr   r   r   r   r   r   <module>   s   