U
    9%e͡                     @   s	  d dl Z d dlZd dlZd dlmZm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 d dlmZmZmZ d d	lmZmZmZ d d
lmZ d dlmZmZ ej deefdd Z!ej dddggidfdddgddggidfddgd ggidfgdd Z"ej dddgdd Z#dd Z$ej ddd ddgej d!dd"gd#d$ Z%ej d!e&dd%ej d&e&d"d%ej dd'd(gej dddgd)d* Z'ej d+d,gd-d.gd/d0 Z(ej dd&d1d2gd'd"de)d dgd"d3gd4d5ggfd'd"e)d d ddd d"dge)ddgd6d3gd4d5ggfd'd6de)d dgdd4gd6d7gd4d5ggfd(d"de)d dgd"d"gd4d5ggfd(d"e)d d ddd d"dge)ddgd%d3gd4d5ggfgd8d9 Z*ej d+d,gd-d.gd:d; Z+d<d= Z,d>d? Z-ej d!d"d%gd@dA Z.ej d+d,gd-d.gej d!ddd"d6d%gdBdC Z/dDdE Z0ejj1eedFk dGdHej d!e&dd"ej dd'd(gej ddIdd ddgej dJdKdLgdMdN Z2ejj1eedFkdGdHdOdP Z3ej d&d%d7gej dJdLdKgej d!d"d6gej ddIdd ddgej dQdKdLgdRdS Z4ej dd!dTidUfd!dVidUfd!dWidUfd!dXidYfgdZd[ Z5e6 d\d] Z7ej d^d"dLdKe8ddfd"dKdKe8ddfd"dLdLd dgfd"dKdLdgfd_dLdKd dd"gfd_dKdKdd"gfd_dLdLd gfd_dKdLg fgej d`dKej9ej:gdadb Z;e6 dcdd Z<ej d^ddLdKe8d d4fddKdKe8dd4fddLdLd ddd6gfddKdLddd6gfdedLdKd d"d6d%gfdedKdKd"d6d%gfdedLdLd d6gfdedKdLd6gfd"dLdKe8ddfd"dKdKe8ddfd"dLdLd ddd6gfd"dKdLddd6gfd_dLdKd d"d6d%d4dfd3dggfd_dKdKe8d"dfd_dLdLd d6gfd_dKdLd6gfdhdLdKd d4dfd3dggfdhdKdKd4dfd3dggfdhdLdLd gfdhdKdLg fgej d`dKej9ej:gdidj Z=dkdl Z>ej dmdJdndogddLdKe?fddLdKe?fddLdKej@fddLdKejAfd"dKdKejAfd"dKdLejAfd6dKdKejAfd6dKdLejAfgdpdq ZBej dmdJdndogddLdKe?fddLdKe?fddLdKej@fddLdKejAfd"dKdKejAfd"dKdLejAfgdrds ZCej dtdd6d%gej dudvdwdxdydzgej dndLdKgej dJdLdKgd{d| ZDej dmdJdndogddLdKej@fddLdKejAfd"dKdKejAfd"dKdLejAfgd}d~ ZEej ddmdngddddddddddddgdd ZFej dJdngdd-d.dgdd ZGej dmddngddddddddddg
dd ZHej dndLdKgej dJdLdKgdd ZIej dddde?eJeKejLjMd fdde?eJeKejLjMfgej dndLdKgej dJdLdKgdd ZNej dndLdKgej dJdLdKgdd ZOdd ZPdd ZQejjRe jSdkddLddd ZTdS )    N)assert_allcloseassert_array_equal)sparse)BSpline)random)LinearRegression)Pipeline)KBinsDiscretizerPolynomialFeaturesSplineTransformer)_calc_expanded_nnz_calc_total_nnz_get_sizeof_LARGEST_INT_t)assert_array_almost_equal)parse_version
sp_versionestc                 C   sd   t ddd}dd }||  |s.t|| dd|sFtt | dd|s`td	S )
z+Test that output array has the given order.
         c                 S   s   t | jS )N)np	isfortranT)a r   j/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sklearn/preprocessing/tests/test_polynomial.pyis_c_contiguous   s    z?test_polynomial_and_spline_array_order.<locals>.is_c_contiguousC)orderFN)r   arangereshapefit_transformAssertionErrorr   )r   Xr   r   r   r   &test_polynomial_and_spline_array_order   s
    r%   zparams, err_msgknots   z0Number of knots, knots.shape\[0\], must be >= 2.r   z*knots.shape\[1\] == n_features is violatedz(knots must be sorted without duplicates.c              	   C   s:   dgdgg}t jt|d tf | | W 5 Q R X dS )zATest that we raise errors for invalid input in SplineTransformer.r'   r   matchNpytestraises
ValueErrorr   fitparamserr_msgr$   r   r   r   (test_spline_transformer_input_validation'   s    
r2   extrapolationcontinueperiodicc                 C   sL   t ddd}ddgddgddgddgddgg}td	|| d
|}dS )zATest that SplineTransformer accepts integer value knot positions.   r   r   r   r'   r            )degreer&   r3   N)r   r    r!   r   r"   )r3   r$   r&   _r   r   r   %test_spline_transformer_integer_knots7   s    "  r<   c                  C   s   t ddd} tdddd| }| }t|ddd	d
ddddddg
 tdddd| }|ddg}t|ddddddddg dS )z<Test that SplineTransformer generates correct features name.r6   r   r   r9   T)n_knotsr:   include_biasZx0_sp_0Zx0_sp_1Zx0_sp_2Zx0_sp_3Zx0_sp_4Zx1_sp_0Zx1_sp_1Zx1_sp_2Zx1_sp_3Zx1_sp_4Fr   bZa_sp_0Za_sp_1Za_sp_2Za_sp_3Zb_sp_0Zb_sp_1Zb_sp_2Zb_sp_3N)r   r    r!   r   r.   get_feature_names_outr   )r$   spltfeature_namesr   r   r   %test_spline_transformer_feature_namesA   s>    rC   constantlinearr:   r9   c                 C   sh   t ddd}t|| d|}|ddg}t||jksDt|	|}|j
d t|ksdtdS )	zsTest feature names are correct for different extrapolations and degree.

    Non-regression test for gh-25292.
    r6   r   r   )r:   r3   r   r?   r'   N)r   r    r!   r   r.   r@   lenn_features_out_r#   	transformshape)r3   r:   r$   rA   rB   X_transr   r   r   7test_split_transform_feature_names_extrapolation_degreeg   s    

rK   r   r=   uniformquantilec                 C   s   t ddddddf }t jdgg|dddddf dggf }|dddddf }|dkrj||  }t|| |d|d}|| ||fD ]}tt j||dd	d qdS )
zTest that B-splines are indeed a decomposition of unity.

    Splines basis functions must sum up to 1 per row, if we stay in between boundaries.
    r   r'   d   Nr   r5   T)r=   r:   r&   r>   r3   Zaxis)r   linspacer_r   r.   r   sumrH   )r:   r=   r&   r3   r$   ZX_trainZX_testrA   r   r   r   +test_spline_transformer_unity_decompositionz   s    	*
rS   bias	intercept)TF)FTc                 C   s   t ddddddf }t |dddf d }tdtdd| d	d
fdt|dfgd}||| t|||dd dS )z7Test that B-splines fit a sinusodial curve pretty well.r   r   rN   Nr   spline   r9   rD   r=   r:   r>   r3   olsZfit_interceptZstepsMbP?rtol)	r   rP   sinr   r   r   r.   r   predict)rT   rU   r$   ypiper   r   r   )test_spline_transformer_linear_regression   s     	rc   sample_weightexpected_knots            r   c              
   C   sT   t ddgddgddgddgddgddgddgg}tj|| ||d	}t|| d
S )zJCheck the behaviour to find knot positions with and without sample_weight.r   r   r9   ri   rg   r   rf   rh   )r$   r&   r=   rd   N)r   arrayr   Z_get_base_knot_positionsr   )r&   r=   rd   re   r$   Z
base_knotsr   r   r   /test_spline_transformer_get_base_knot_positions   s    4   rk   c                 C   s   dd }t ddddddf }tdtdd	| d
dfdt|dfgd}||||dddf  t ddddddf }||}t|||dddf ddd t|dd |dd dd dS )z5Test that B-splines fit a periodic curve pretty well.c                 S   s,   t dt j |  t dt j |   d S )Nr   rf   r9   )r   r_   pi)xr   r   r   f   s    z=test_spline_transformer_periodic_linear_regression.<locals>.fr   r'   e   NrV   r6   r9   r5   rX   rY   rZ   r[   r   i-  g{Gz?)Zatolr^   rN      r\   r]   )r   rP   r   r   r   r.   r`   r   )rT   rU   rn   r$   rb   ZX_Zpredictionsr   r   r   2test_spline_transformer_periodic_linear_regression   s&    	
 rr   c                  C   s   t ddddddf } d}t|ddgdgd	ggd
}|| }t d	dgdd	gd	dgdd	gg}tt dd||d}|| dddf }t|| dS )z@Test that the backport of extrapolate="periodic" works correctlyg      @r   Nr   r5   g                    ?r:   r3   r&   ri   r   )r   rP   r   r"   rj   r   r    r   )r$   r:   transformerXtZcoefZsplZXsplr   r   r   0test_spline_transformer_periodic_spline_backport   s      
"rz   c               	   C   s   t ddddddf } tdddgdgd	gd
gdgdggd}tdddgd	gd
gdgdgdggd}|| }|| }t||dddddddgf  dS )zJTest if shifted knots result in the same transformation up to permutation.r   r   ro   Nr9   r5   rt   ru         @      @      @       @rv   g      "@ri   r'   r   )r   rP   r   r"   r   )r$   Ztransformer_1Ztransformer_2ZXt_1ZXt_2r   r   r   4test_spline_transformer_periodic_splines_periodicity   s    

r   c           	   	   C   s   t ddddddf }t| ddgdgdgd	gd
gdggd}||}| |  t| }d| }|}td| d D ]0}t j|dd}t 	| |k st
|| }q|t j|dd}t 	| dkst
dS )z?Test that spline transformation is smooth at first / last knot.rs   r   i'  Nr5   rt   ru   r{   r|   r}   r~   rv   r'   r   rO   )r   rP   r   r"   maxminrF   rangediffabsr#   )	r:   r$   rx   ry   deltaZtolZdXtdr   r   r   r   3test_spline_transformer_periodic_splines_smoothness  s     


r   c              	   C   s0  t ddddddf }| }tdtd|| ddgd	t|d
gg}||| t|dgdggddg tdtd|| ddgd	t|d
gg}||| t|dgdggddg td|| dd}|| d}t	j
t|d |dgg W 5 Q R X t	j
t|d |dgg W 5 Q R X dS )z1Test that B-spline extrapolation works correctly.rp   r'   rN   NrV   ri   rD   rX   rY   rZ   ir   rE   error0X contains values beyond the limits of the knotsr(   )r   rP   Zsqueezer   r   r   r.   r   r`   r+   r,   r-   rH   )rT   rU   r:   r$   ra   rb   rA   msgr   r   r   %test_spline_transformer_extrapolation<  sT    		   
r   c                  C   sn   t jd} | ddd}d}|d }t|dddd}||}t|d	dd
}||}t||dd dS )zCTest that a B-spline of degree=0 is equivalent to KBinsDiscretizer.i| rq   r'   r   r   rM   T)r=   r:   r&   r>   zonehot-dense)n_binsencodeZstrategygvIh%<=r]   N)	r   r   RandomStaterandnr!   r   r"   r	   r   )rngr$   r   r=   rA   ZsplinesZkbdZkbinsr   r   r   'test_spline_transformer_kbindiscretizert  s       

r   1.8.09The option `sparse_output` is available as of scipy 1.8.0)reasonr   r>   FTc              	   C   sP  t j|}|ddd}t| |||dd}t| |||dd}|| || ||}	||}
t	|	r~|	j
dkstt|
|	  t j|dd	}t j|dd	}t jt |d |d
t ||d d
f }|dkr2d}tjt|d || W 5 Q R X d}tjt|d || W 5 Q R X nt||||  d S )Nrq   (   r   F)r:   r&   r3   r>   sparse_outputTcsrr   rO   r   r   r   r(   zOut of bounds)r   r   r   r   r!   r   r.   rH   r   issparseformatr#   r   toarrayZaminZamaxrQ   rP   r+   r,   r-   )r:   r&   r3   r>   Zglobal_random_seedr   r$   Z
splt_denseZsplt_sparseZX_trans_sparseZX_trans_denseZX_minZX_maxZX_extrar   r   r   r   %test_spline_transformer_sparse_output  sL    



"
 r   c               	   C   s:   dgdgg} t jtdd tdd|  W 5 Q R X dS )zDTest that SplineTransformer with sparse=True raises for scipy<1.8.0.r'   r   zscipy>=1.8.0r(   T)r   Nr*   )r$   r   r   r   ?test_spline_transformer_sparse_output_raise_error_for_old_scipy  s    r   r   c                 C   sn   |rt tdk rtd t| ||||d}tddddddf }|| ||j	d |j
ksjtdS )z8Test that transform results in n_features_out_ features.r   r   )r=   r:   r>   r3   r   r   r'   r   N)r   r   r+   skipr   r   rP   r.   rH   rI   rG   r#   )r=   r>   r:   r3   r   rA   r$   r   r   r   &test_spline_transformer_n_features_out  s    

r   )rp   r   z&degree=\(min_degree, max_degree\) must)r   g      ?r9   r   )r'   r   r9   z'int or tuple \(min_degree, max_degree\)c              	   C   s:   dgdgg}t jt|d tf | | W 5 Q R X dS )zBTest that we raise errors for invalid input in PolynomialFeatures.r'   r   r(   N)r+   r,   r-   r
   r.   r/   r   r   r   )test_polynomial_features_input_validation  s    r   c                  C   s@   t dd d t jf } t t | | | d | d g}| |fS )Nrg   r   r9   )r   r    ZnewaxishstackZ	ones_like)r$   Pr   r   r   single_feature_degree3  s     r   z/degree, include_bias, interaction_only, indicesr   r9   sparse_Xc           
      C   sz   | \}}|r||}t |||d|}||}	|r>|	 }	t|	|dd|f  |jdkrv|jj|j|jfksvt	dS )z9Test PolynomialFeatures on single feature up to degree 3.r:   r>   interaction_onlyNr   
r
   r.   rH   r   r   n_output_features_Zpowers_rI   Zn_features_in_r#   )
r   r:   r>   r   indicesr   r$   r   tfoutr   r   r   $test_polynomial_features_one_feature   s       

r   c                  C   s   t dd} | d d d df }| d d dd f }t |d |d  |d |d  |d |d  |d |d  |d |d  |d |d  |d |d  |d |d  |d |d  |d |d  g
}| |fS )Nrg   r   r'   r   r   r9   )r   r    r!   r   )r$   x1x2r   r   r   r   two_features_degree3(  s"    r   r   r      	   r9   r9   c           
      C   sz   | \}}|r||}t |||d|}||}	|r>|	 }	t|	|dd|f  |jdkrv|jj|j|jfksvt	dS )z5Test PolynomialFeatures on 2 features up to degree 3.r   Nr   r   )
r   r:   r>   r   r   r   r$   r   r   r   r   r   r   %test_polynomial_features_two_features>  s     &  

r   c                  C   s  t ddd} tddd| }| }tddd	d
ddddddg
| t||| j	d ksft
tddd| }|dddg}tdddddddddddddd d!d"d#d$d%g| t||| j	d kst
td&dd| }|dddg}tddddddddddd d!d"d#d$d%g| t||| j	d ks>t
td'ddd(| }|dddg}tdd g| t||| j	d kst
tddd| }|d)d*d+g}tdd)d*d+g| d S ),N   r   r9   r   Tr:   r>   1Zx0r   r   zx0^2zx0 x1zx0 x2zx1^2zx1 x2zx2^2r'   Fr   r?   cza^2za bza czb^2zb czc^2za^3za^2 bza^2 cza b^2za b cza c^2zb^3zb^2 czb c^2zc^3r   r   r   zF40Du   ☮u   א)r   r    r!   r
   r.   r@   r   rF   rH   rI   r#   )r$   polyrB   r   r   r   test_polynomial_feature_namesr  s      r   degr   dtypec           
      C   s   t jd}|ddd}t|}t| ||d}|||}|||}	t	|rf|j
dksjt|j|	jksztt| |	 d S )Nr   r   rN   r   r>   r   Zcsc)r   r   r   randintr   
csc_matrixr
   r"   astyper   r   r#   r   r   r   )
r   r>   r   r   r   r$   ZX_cscr   ZXt_cscXt_denser   r   r   test_polynomial_features_csc_X  s    
  r   c           
      C   s   t jd}|ddd}t|}t| ||d}|||}||j|dd}	t	|rj|j
dksnt|j|	jks~tt| |	 d S )Nr   r   r   r   F)copyr   )r   r   r   r   r   
csr_matrixr
   r"   r   r   r   r#   r   r   r   )
r   r>   r   r   r   r$   X_csrr   Xt_csrr   r   r   r   test_polynomial_features_csr_X  s    
  r   
n_featureszmin_degree, max_degree)r   r'   )r   r   )r'   r9   )r   ri   )r9   ri   c           	      C   sl   t dgdg| d gff}t|||d}|| |j}tj| d|||d}|tdd |D kshtdS )z?
    Test that n_output_features_ is calculated correctly.
    r'   r   )r:   r   r>   r   
min_degree
max_degreer   r>   c                 S   s   g | ]}d qS )r'   r   ).0r;   r   r   r   
<listcomp>  s     z)test_num_combinations.<locals>.<listcomp>N)r   r   r
   r.   r   Z_combinationsrR   r#   )	r   r   r   r   r>   rm   r   Z
num_combosZcombosr   r   r   test_num_combinations  s     
r   c           	      C   s   t ddddd }| }t| ||d}|||}|||}t|r^|jdksbt	|j
|j
ksrt	t| | d S )N  r         ?r   Zrandom_stater   r   )sparse_randomtocsrr   r
   r"   r   r   r   r   r#   r   r   )	r   r>   r   r   r   r$   r   r   r   r   r   r   %test_polynomial_features_csr_X_floats  s    
  r   zero_row_index)r   r   T)r'   r   T)r   r   T)r   r9   T)r'   r9   T)r   r9   T)r   r   F)r'   r   F)r   r   F)r   r9   F)r'   r9   F)r   r9   Fc                 C   s   t ddddd }d|| d d f< | }t|d|d}||}||}t|rb|jd	ksft|j	|j	ksvtt
| | d S )
Nr9   r   ru   r   r   rt   Fr   r   r   r   r   r
   r"   r   r   r   r#   r   r   )r   r   r   r   r$   r   r   r   r   r   r   'test_polynomial_features_csr_X_zero_row1  s    

r   )TT)FFc                 C   sx   t ddddd }| }td| |d}||}||}t|rR|jdksVt|j	|j	ksftt
| | d S )	Nr   r   r   r   r   ri   r   r   r   )r>   r   r   r$   r   r   r   r   r   r   'test_polynomial_features_csr_X_degree_4R  s      

r   dim)r   r'   T)r9   r'   T)r9   r   T)r9   r9   T)r   r'   F)r9   r'   F)r9   r   F)r9   r9   Fc                 C   sv   t d|ddd }| }t| |d}||}||}t|rP|jdksTt|j	|j	ksdtt
| | d S )Nr   r   r   r   r   r   r   )r   r   r   r   r$   r   r   r   r   r   r   (test_polynomial_features_csr_X_dim_edgese  s    

r   c              	      sl   fdd}d}d}t j}t jddt jd}t |d |d |d |d g}t j|d |d |d |d gt jd}tj|||ff||f|d	}	t |dd
}
|
j|dd|
j	|
j
d}|t t jjkrd}tjt|d |
|	 W 5 Q R X dS |
|	}| \}}|| }|||t   |d | }|rFdg|d  ng }|r^dg|d  ng }tdD ]}|d|  }|d| d  }|d|  }|d| d  }|r|d |d |||g ||t| |t| g  sF||| || || g |||||| ||||| ||||| g n&||| g ||||||  qjt|d dt    }|
j|d kst|j|kst|j||d fkst|jj|jj  krt jksn t|j t t jjkst|r"tt|d ng }||d g| |d g|   t |j!| t"|| t"|| dS )a  Check the automatic index dtype promotion to `np.int64` when needed.

    This ensures that sufficiently large input configurations get
    properly promoted to use `np.int64` for index and indptr representation
    while preserving data integrity. Non-regression test for gh-16803.

    Note that this is only possible for Python runtimes with a 64 bit address
    space. On 32 bit platforms, a `ValueError` is raised instead.
    c                    sH    r(| | |d d|  d  d | S | | |d | d  | S d S )Nr   r9   r'   r   )r   ijr   r   r   degree_2_calc  s    $zRtest_csr_polynomial_expansion_index_overflow_non_regression.<locals>.degree_2_calc   i r'   r   )r   r   )rI   r   r   r>   r:   r   r   tThe output that would result from the current configuration would have \d* features which is too large to be indexedr(   Nr9   )#r   float32r    int64rj   r   r   r
   _num_combinationsr   r>   iinfointpr   r+   r,   r-   r.   r"   Znonzerointr   appendextendr   r#   r   rI   indptrr   int32listr   datar   )r   r>   r   Z	n_samplesr   Z
data_dtyper   rowcolr$   pfnum_combinationsr   rJ   Zrow_nonzeroZcol_nonzeroZn_degree_1_features_outZmax_degree_2_idxZdata_targetZcol_nonzero_targetr   rm   ra   Zx_idxZy_idxZnnz_per_rowZrow_nonzero_targetr   r   r   ;test_csr_polynomial_expansion_index_overflow_non_regression  s    " 
  


(
r   zdegree, n_features)r     )r9   i(	  )r9   r   c              	   C   s,  dg}dg}|d g}|d t | g}|||d  d |d   |||d  |d  d |d   t|||ff}t||| d}	|	j|d| |	j|	jd}
|
t	tj
jkrd}tjt|d	 |	| W 5 Q R X d
S ttdk rd}t	tjj}|| }td| d D ]R}t|j||}t|||d }||d 7 }t|||k}|| od||kO }q|rd}tjt|d	 |	|}W 5 Q R X d
S ttdk r|dkr| dkr|sd}tjt|d	 |	|}W 5 Q R X d
S |	|}|
t	tjjkrtjntj}d| d t |   }t || }|j|jksPt|jd|	jfksft|jj|jj  kr|ksn t|j|kst|r|d tdkstt|D ]&}|d|| f tdkstq|| }| dkr|d| 9 }|	j|| d  d | ks(td
S )zTests known edge-cases to the dtype promotion strategy and custom
    Cython code, including a current bug in the upstream
    `scipy.sparse.hstack`.
    ru   r   r'   r   rg   r   r   r   r(   Nr   Fz>In scipy versions `<1.8.0`, the function `scipy.sparse.hstack`z1.9.2r   z>In scipy versions `<1.9.2`, the function `scipy.sparse.hstack`r   r   r9   ) r   r   r   r   r
   r   r   r>   r   r   r   r   r+   r,   r-   r.   r   r   r   r   r   r   r   r"   r   r   r#   rI   r   r   Znnzapprox)r:   r   r   r>   r   r   r   expected_indicesr$   r   r   r   Zhas_bugZ	max_int32Zcumulative_sizer   Z
max_indptrZmax_indicesZneeds_int64rJ   Zexpected_dtypeZnon_bias_termsZexpected_nnzidxoffsetr   r   r   ,test_csr_polynomial_expansion_index_overflow  s    
  

 &$
r   c           	   	   C   s   t t jjd }dg}dg}|d g}t|||ff}t| |dd}d}tjt	|d |
| W 5 Q R X tjt	|d || W 5 Q R X d S )	Nr   ru   r   r'   r   r   r   r(   )r   r   r   r   r   r   r
   r+   r,   r-   r.   r"   )	r   r>   r   r   r   r   r$   r   r   r   r   r   0test_csr_polynomial_expansion_too_large_to_indexl  s     
  r   c               	   C   s   t d} tddd}d}tjt|d ||  W 5 Q R X tddd}d}tjt|d ||  W 5 Q R X | t| t	| fD ]F}tdd	d}||}t
|r| }t|t | jd d
f qdS )zCheck that PolynomialFeatures raises error when degree=0 and include_bias=False,
    and output a single constant column when include_bias=True
    )r   r   r   Fr   zWSetting degree to zero and include_bias to False would result in an empty output array.r(   r   zoSetting both min_degree and max_degree to zero and include_bias to False would result in an empty output array.Tr'   N)r   Zonesr
   r+   r,   r-   r"   r   r   r   r   r   r   rI   )r$   r   r1   Z_Xoutputr   r   r   1test_polynomial_features_behaviour_on_zero_degree  s"    


r   c                  C   s:   t jdkst jdkr$t jdkr$d} nd} t | ks6td S )Nwin32        Z
emscriptenrf      )sysplatformmaxsizer   r#   )Zexpected_sizer   r   r   test_sizeof_LARGEST_INT_t  s    
r  r   zyOn Windows, scikit-learn is typically compiled with MSVC that does not support int128 arithmetic (at the time of writing))r   runc            
   	   C   s  t ttjjd d } dg}dg}| d g}| d g}|t | | d  d |d   |t | | d  | d  d |d   t|||ff}tdddd	}t	j
d
krd}tjt|d || W 5 Q R X n6||}tdD ]"}	|d||	 f tdkstqd S )NgUUUUUU?r9   ru   r   r'   r   rg   Fr   r   r   r(   )r   r   r   r   r   r   r   r   r
   r  r  r+   r,   r-   r"   r   r   r#   )
r   r   r   r   r   r$   r   r   rJ   r   r   r   r   *test_csr_polynomial_expansion_windows_fail  s,    
"

r  )Ur  numpyr   r+   Znumpy.testingr   r   Zscipyr   Zscipy.interpolater   Zscipy.sparser   r   Zsklearn.linear_modelr   Zsklearn.pipeliner   Zsklearn.preprocessingr	   r
   r   Z/sklearn.preprocessing._csr_polynomial_expansionr   r   r   Zsklearn.utils._testingr   Zsklearn.utils.fixesr   r   markZparametrizer%   r2   r<   rC   rK   r   rS   rc   rj   rk   rr   rz   r   r   r   r   Zskipifr   r   r   r   Zfixturer   slicer   r   r   r   r   r   r   r   Zfloat64r   r   r   r   r   r   r   r   sqrtr   r   r   r   r   r   r  Zxfailr  r  r   r   r   r   <module>   s   


	&


"("


&6
 0

 



	




L







 
	




re