o
    ip                  	   @   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mZmZ d dlmZ dd gd d	gd	d	gd	d	ggZg d
Zg dZejdejdeejg ejdddgejdddgejdddgdd Zd2ddZdd ZdZd d! Zejd"d#ed$fgd%d& Zejd'ded	 gd(d) Zejd*ed+fd,gd-d. Zejd/ded	 gd0d1 ZdS )3    N)stats)LogisticRegression)	LinearSVC)l1_min_c)bounded_rand_int_wrapset_seed_wrap)CSR_CONTAINERS   )r   r
   r
   r
   )   r
   r   r   zIignore:.*'liblinear' solver for multiclass classification is deprecated.*X_containerlosssquared_hingelogY_labeltwo-classesmulti-classintercept_labelno-interceptfit-interceptc           	      C   sN   t td}ddidddd}| t}|| }|| }t|||fi | d S )N)r   r   fit_interceptFT
   )r   intercept_scaling)r   r   )Y1Y2dense_Xcheck_l1_min_c)	r   r   r   r   ZYsZ
interceptsXYZintercept_params r   l/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/sklearn/svm/tests/test_bounds.pytest_l1_min_c   s   
r!   T      ?c                 C   s   t | ||||d}tdddtddddd| }||_||_||_|| | t|j	d	k
 s4J t|jd	k
 s@J |d
 |_|| | t|j	d	k sat|jd	k scJ d S d S )N)r   r   r   l1Z	liblinear)penaltyZsolverr   F)r   r$   Zdual)r   r   r   g)\(?)r   r   r   r   r   CfitnpZasarrayZcoef_allZ
intercept_any)r   yr   r   r   Zmin_cZclfr   r   r    r   '   s*   
	
4r   c                  C   sR   ddgddgg} ddg}t t t| | W d    d S 1 s"w   Y  d S )Nr   r
   )pytestraises
ValueErrorr   )r   r*   r   r   r    test_ill_posed_min_cB   s
   "r.   l    c                      sF   dd t dD  tdd  D sJ t fdd D r!J dS )a  Test that bounded_rand_int_wrap without seeding respects the range

    Note this test should pass either if executed alone, or in conjunctions
    with other tests that call set_seed explicit in any order: it checks
    invariants on the RNG instead of specific values.
    c                 S   s   g | ]}t d qS )d   r   .0_r   r   r    
<listcomp>S       z(test_newrand_default.<locals>.<listcomp>r   c                 s   s(    | ]}d |  kodk n  V  qdS )r   r/   Nr   r2   xr   r   r    	<genexpr>T   s   & z'test_newrand_default.<locals>.<genexpr>c                 3   s    | ]	}| d  kV  qdS )r   Nr   r6   	generatedr   r    r8   U   s    N)ranger(   r   r   r9   r    test_newrand_defaultL   s   r<   zseed, expected)r   6   	   c                 C   s    t |  td}||ksJ dS )z3Test that `set_seed` produces deterministic resultsr/   N)r   r   )seedexpectedr:   r   r   r    test_newrand_set_seedX   s   rA   r?   c                 C   8   t t t|  W d   dS 1 sw   Y  dS )z=Test that `set_seed_wrap` is defined for unsigned 32bits intsN)r+   r,   OverflowErrorr   )r?   r   r   r    test_newrand_set_seed_overflow`      
"rD   zrange_, n_ptsi'  )r/      c                    s   t d d}g }tjd d}t|D ]} fddt|D }t||j}||j qtjddd}t||j}	|	jdksJJ d	|	j d
tj	|dd}
|
dks]J d|
 ddS )z;Test that `bounded_rand_int` follows a uniform distribution*   r/   r   )locscalec                    s   g | ]}t  qS r   r0   r1   range_r   r    r4   s   r5   z1test_newrand_bounded_rand_int.<locals>.<listcomp>r
   g?zNull hypothesis rejected: generated random numbers are not uniform. Details: the (meta) p-value of the test of uniform distribution of p-values is z which is not > 0.05r   )qzlNull hypothesis rejected: generated random numbers are not uniform. Details: lower 10th quantile p-value of z not > 0.05.N)
r   r   uniformr;   ZkstestZcdfappendZpvaluer'   Z
percentile)rK   Zn_ptsZn_iterZks_pvalsZuniform_distr3   sampleresZuniform_p_vals_distZ	res_pvalsZmin_10pct_pvalr   rJ   r    test_newrand_bounded_rand_intg   s*   
rQ   rK   c                 C   rB   )zETest that `bounded_rand_int_wrap` is defined for unsigned 32bits intsN)r+   r,   rC   r   rJ   r   r   r    $test_newrand_bounded_rand_int_limits   rE   rR   )Tr"   ) numpyr'   r+   Zscipyr   Zsklearn.linear_modelr   Zsklearn.svmr   Zsklearn.svm._boundsr   Zsklearn.svm._newrandr   r   Zsklearn.utils.fixesr   r   r   r   markfilterwarningsZparametrizearrayr!   r   r.   Z_MAX_UNSIGNED_INTr<   rA   rD   rQ   rR   r   r   r   r    <module>   s>    



'