a
    hp                     @   sv  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ejg ejdddgejdddgejdddgdd Zd1d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d/d0 ZdS )2    N)stats)LogisticRegression)	LinearSVC)l1_min_c)bounded_rand_int_wrapset_seed_wrap)CSR_CONTAINERS   )r   r
   r
   r
   )   r
   r   r   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   Y/var/www/html/assistant/venv/lib/python3.9/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
 shJ t|jd	k
 sJ |d
 |_|| | t|j	d	k st|jd	k sJ 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*    	

r   c                  C   sP   ddgddgg} ddg}t t t| | W d    n1 sB0    Y  d S )Nr   r
   )pytestraises
ValueErrorr   )r   r*   r   r   r    test_ill_posed_min_c=   s    r.   l    c                      sF   dd t dD  tdd  D s(J t fdd D rBJ 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>N       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>O   r5   z'test_newrand_default.<locals>.<genexpr>c                 3   s   | ]}| d  kV  qdS )r   Nr   r6   	generatedr   r    r8   P   r5   N)ranger(   r   r   r9   r    test_newrand_defaultG   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_seedS   s    rA   r?   c                 C   s6   t t t|  W d   n1 s(0    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[   s    rC   zrange_, n_ptsi'  )r/      c                    s   t d d}g }tjd d}t|D ]4} fddt|D }t||j}||j q&tjddd}t||j}	|	jdksJ d	|	j d
tj	|dd}
|
dksJ 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   n   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)rI   Zn_ptsZn_iterZks_pvalsZuniform_distr3   sampleresZuniform_p_vals_distZ	res_pvalsZmin_10pct_pvalr   rH   r    test_newrand_bounded_rand_intb   s*    
rO   rI   c                 C   s6   t t t|  W d   n1 s(0    Y  dS )zETest that `bounded_rand_int_wrap` is defined for unsigned 32bits intsN)r+   r,   rB   r   rH   r   r   r    $test_newrand_bounded_rand_int_limits   s    rP   )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   markZparametrizearrayr!   r   r.   Z_MAX_UNSIGNED_INTr<   rA   rC   rO   rP   r   r   r   r    <module>   s6   



'