o
    h                     @   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)axis)
r   r   _uncensored_left_right	_interval	_uncensornpconcatenatemean)self
uncensoredr
   r   r   dataudata r   X/var/www/vscode/kcb/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   )dtyper   r   )r   arrayboolr   right_censoredr   r   r   r   r   emptyr   x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.   r0   g      $@g      g     @r/   g      &@r1   )	r   infr   r5   r   r   r   r   r   r9   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"   r=   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   r4   r!   r   )r   r   r8   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-dimensionalrA   zmust not contain nanr   r   r	   z both values must not be infiniter?   z$left value must not exceed the rightr   )pytestraises
ValueErrorr   r   nanr=   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-dimensionalrE   rG   r   r   r   z"`censored` must be one-dimensionalz`x` must not containr   r   must have the same lengthr   r   r   r   )rH   rI   rJ   r   rK   )r   rN   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-dimensionalrE   r	      r   r1   z `high` must be a one-dimensionalz`low` must not containr   r   rO   rP   rG   rQ   )rH   rI   rJ   r   r5   r   rK   rL   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 )NrG   r   r   
   r   )r   r
   r   r   )r   num_censored)r   r'   data1data2r   r   r   test_count_censored   s
   z$TestCensoredData.test_count_censoredN)__name__
__module____qualname__r   r)   r,   r<   r>   rB   rD   rM   rH   markparametrizer   r+   r$   rR   rT   rY   r   r   r   r   r   	   s    			
r   )	rH   numpyr   numpy.testingr   r   scipy.statsr   r   r   r   r   r   <module>   s
   