o
    `^hj                     @   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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g d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!"g d1d&d!de+d dgd!d2gd3d4ggfd&d!e+g d5e+ddgd6d2gd3d4ggfd&d6de+d dgdd3gd6d7gd3d4ggfd'd!de+d dgd!d!gd3d4ggfd'd!e+g d5e+ddgd$d2gd3d4g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 Z0ej!"d+d,gd-d.gej!"d g dBdCdD Z1dEdF Z2ej!j3e edGk dHdIej!"d e(dd!ej!"dd&d'gej!"dg dJej!"dKdLdMgdNdO Z4ej!j3e edGkdHdIdPdQ Z5ej!"d%d$d7gej!"dKdMdLgej!"d d!d6gej!"dg dJej!"dRdLdMgdSdT Z6ej!"dd dUidVfd dWidVfd dXidVfd dYidZfgd[d\ Z7e8 d]d^ Z9ej!"d_d!dMdLe:ddfd!dLdLe:ddfd!dMdMd dgfd!dLdMdgfd`dMdLg dafd`dLdLdd!gfd`dMdMd gfd`dLdMg fgej!"dbdge e dcdd Z;e8 dedf Z<ej!"d_ddMdLe:d d3fddLdLe:dd3fddMdMg dgfddLdMg dhfdidMdLg djfdidLdLg dkfdidMdMd d6gfdidLdMd6gfd!dMdLe:ddfd!dLdLe:ddfd!dMdMg dgfd!dLdMg dhfd`dMdLg dlfd`dLdLe:d!dfd`dMdMd d6gfd`dLdMd6gfdmdMdLg dnfdmdLdLg dofdmdMdMd gfdmdLdMg fgej!"dbdge e dpdq Z=drds Z>ej!"g dtddMdLe?fddMdLe?fddMdLej@fddMdLejAfd!dLdLejAfd!dLdMejAfd6dLdLejAfd6dLdMejAfgej!"duedvdw ZBej!"g dtddMdLe?fddMdLe?fddMdLej@fddMdLejAfd!dLdLejAfd!dLdMejAfgej!"dxedydz ZCej!"d{g d|ej!"d}g d~ej!"ddMdLgej!"dKdMdLgej!"dxedd ZDej!"g dtddMdLej@fddMdLejAfd!dLdLejAfd!dLdMejAfgej!"dxedd ZEej!"g dg dej!"dxedd ZFej!"dKdgg dej!"dxedd ZGej!"g dg dej!"dxedd ZHej!"ddMdLgej!"dKdMdLgej!"dxedd ZIej!"dddde?eJeKejLjMd fdde?eJeKejLjMfgej!"ddMdLgej!"dKdMdLgej!"dxedd ZNej!"ddMdLgej!"dKdMdLgej!"dxedd ZOej!"dee dd ZPdd ZQej!jRe jSdkddMdej!"dxe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)CSC_CONTAINERSCSR_CONTAINERSparse_version
sp_versionestc                 C   sd   t ddd}dd }||  |sJ || dd|s#J t | dd|s0J d	S )
z+Test that output array has the given order.
         c                 S   s   t | jS )N)np	isfortranT)a r   i/home/air/shanriGPT/back/venv/lib/python3.10/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_transformr   )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   T   dgdgg}t jt|d tdi | | W d   dS 1 s#w   Y  dS )zATest that we raise errors for invalid input in SplineTransformer.r(   r   matchNr   pytestraises
ValueErrorr   fitparamserr_msgr%   r   r   r   (test_spline_transformer_input_validation,   s   
"r4   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'   r5   N)r   r"   r#   r   r$   )r5   r%   r'   _r   r   r   %test_spline_transformer_integer_knots<   s   "r>   c                  C   sp   t ddd} tdddd| }| }t|g d tdddd| }|d	d
g}t|g d dS )z<Test that SplineTransformer generates correct features name.r8   r   r   r;   T)n_knotsr<   include_bias)
x0_sp_0x0_sp_1x0_sp_2x0_sp_3x0_sp_4x1_sp_0x1_sp_1x1_sp_2x1_sp_3x1_sp_4Fr   b)a_sp_0a_sp_1a_sp_2a_sp_3b_sp_0b_sp_1b_sp_2b_sp_3N)r   r"   r#   r   r0   get_feature_names_outr   )r%   spltfeature_namesr   r   r   %test_spline_transformer_feature_namesF   s   rW   )constantlinearr6   r7   r<   r;   c                 C   sh   t ddd}t|| d|}|ddg}t||jks"J ||}|j	d t|ks2J dS )	zsTest feature names are correct for different extrapolations and degree.

    Non-regression test for gh-25292.
    r8   r   r   )r<   r5   r   rK   r(   N)
r   r"   r#   r   r0   rT   lenn_features_out_	transformshape)r5   r<   r%   rU   rV   X_transr   r   r   7test_split_transform_feature_names_extrapolation_degreel   s   

r_   r   r?   uniformquantilerX   c                 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r5||  }t|| |d|d}|| ||fD ]}tt j||dd	d qGd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   r7   T)r?   r<   r'   r@   r5   axis)r   linspacer_r   r0   r   sumr\   )r<   r?   r'   r5   r%   X_trainX_testrU   r   r   r   +test_spline_transformer_unity_decomposition   s    	*
rj   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   rb   Nr   spline   r;   rX   r?   r<   r@   r5   olsfit_interceptstepsMbP?rtol)	r   re   sinr   r   r   r0   r   predict)rk   rl   r%   ypiper   r   r   )test_spline_transformer_linear_regression   s    	r~   )r'   r?   sample_weightexpected_knots         )r   r   r(   r(   r   r;   r(      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   r;   r   r   r   r   r   )r%   r'   r?   r   N)r   arrayr   _get_base_knot_positionsr   )r'   r?   r   r   r%   
base_knotsr   r   r   /test_spline_transformer_get_base_knot_positions   s
   4r   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   r   r;   )r   rz   pi)xr   r   r   f   s   ,z=test_spline_transformer_periodic_linear_regression.<locals>.fr   r(   e   Nro   r8   r;   r7   rq   rr   rs   ru   r   i-  g{Gz?)atolry   rb      rw   rx   )r   re   r   r   r   r0   r{   r   )rk   rl   r   r%   r}   X_predictionsr   r   r   2test_spline_transformer_periodic_linear_regression   s&   	
 "r   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   r7   g                    ?r<   r5   r'   r   r   )r   re   r   r$   r   r   r"   r   )r%   r<   transformerXtcoefsplXsplr   r   r   0test_spline_transformer_periodic_spline_backport   s   
"r   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g df  dS )zJTest if shifted knots result in the same transformation up to permutation.r   r   r   Nr;   r7   r   r         @      @      @       @r   g      "@)r   r   r(   r   r;   )r   re   r   r$   r   )r%   transformer_1transformer_2Xt_1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 ]}t j|dd}t 	| |k sRJ || }q>t j|dd}t 	| dksiJ dS )z?Test that spline transformation is smooth at first / last knot.r   r   i'  Nr7   r   r   r   r   r   r   r   r(   r   rc   )
r   re   r   r$   maxminrZ   rangediffabs)	r<   r%   r   r   deltatoldXtdr   r   r   r   3test_spline_transformer_periodic_splines_smoothness  s    


r   )r(   r   r;   r   r   c                 C   sZ  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 d   n1 sw   Y  t	j
t|d |dgg W d   dS 1 sw   Y  dS )z1Test that B-spline extrapolation works correctly.r   r(   rb   Nro   r   rX   rq   rr   rs   ir   rY   error0X contains values beyond the limits of the knotsr*   )r   re   squeezer   r   r   r0   r   r{   r-   r.   r/   r\   )rk   rl   r<   r%   r|   r}   rU   msgr   r   r   %test_spline_transformer_extrapolationA  sR   		
"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| r   r(   r   r   ra   T)r?   r<   r'   r@   zonehot-dense)n_binsencodestrategygvIh%<=rx   N)	r   r   RandomStaterandnr#   r   r$   r	   r   )rngr%   r   r?   rU   splineskbdkbinsr   r   r   'test_spline_transformer_kbindiscretizery  s   

r   1.8.09The option `sparse_output` is available as of scipy 1.8.0)reason)r   rX   rY   r6   r7   r@   FTc                 C   sz  t j|}|ddd}t| |||dd}t| |||dd}|| || ||}	||}
t	|	r?|	j
dksAJ t|
|	  t j|dd	}t j|dd	}t jt |d |d
t ||d d
f }|dkrd}tjt|d || W d    n1 sw   Y  d}tjt|d || W d    d S 1 sw   Y  d S t||||  d S )Nr   (   r   F)r<   r'   r5   r@   sparse_outputTcsrr   rc   r   r   r   r*   zOut of bounds)r   r   r   r   r#   r   r0   r\   r   issparseformatr   toarrayaminamaxrf   re   r-   r.   r/   )r<   r'   r5   r@   global_random_seedr   r%   
splt_densesplt_sparseX_trans_sparseX_trans_denseX_minX_maxX_extrar   r   r   r   %test_spline_transformer_sparse_output  sN   



""r   c                  C   sP   dgdgg} t jtdd tdd|  W d   dS 1 s!w   Y  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s5J dS )z8Test that transform results in n_features_out_ features.r   r   )r?   r<   r@   r5   r   r   r(   r   N)r   r   r-   skipr   r   re   r0   r\   r]   r[   )r?   r@   r<   r5   r   rU   r%   r   r   r   &test_spline_transformer_n_features_out  s   

r   )r   r   z&degree=\(min_degree, max_degree\) must)r   g      ?r;   r   )r(   r   r;   z'int or tuple \(min_degree, max_degree\)c                 C   r)   )zBTest that we raise errors for invalid input in PolynomialFeatures.r(   r   r*   Nr   )r-   r.   r/   r
   r0   r1   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 )Nr   r   r;   )r   r"   newaxishstack	ones_like)r%   Pr   r   r   single_feature_degree3  s    r   z/degree, include_bias, interaction_only, indicesr   r;   )r   r   r;   X_containerc           
      C      | \}}|dur||}t |||d|}||}	|dur#|	 }	t|	|dd|f  |jdkr?|jj|j|jfksAJ dS dS )z9Test PolynomialFeatures on single feature up to degree 3.Nr<   r@   interaction_onlyr   	r
   r0   r\   r   r   n_output_features_powers_r]   n_features_in_)
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 )Nr   r   r(   r   r   r;   )r   r"   r#   r   )r%   x1x2r   r   r   r   two_features_degree3*  s"   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   )r   r   r   r   c           
      C   r   )z5Test PolynomialFeatures on 2 features up to degree 3.Nr   r   r   )
r   r<   r@   r   r   r   r%   r   r   r   r   r   r   %test_polynomial_features_two_features@  s    #

r   c                  C   sh  t ddd} tddd| }| }tg d| t||| j	d ks+J tdd	d| }|g d
}tg d| t||| j	d ksPJ tdd	d| }|g d
}tg d| t||| j	d ksuJ tdddd| }|g d
}tddg| t||| j	d ksJ tddd| }|g d}tg d| d S )N   r   r;   r   Tr<   r@   )
1x0r   r   zx0^2zx0 x1zx0 x2zx1^2zx1 x2zx2^2r(   F)r   rK   c)r   rK   r   a^2a ba cb^2b cc^2a^3a^2 ba^2 ca b^2a b ca c^2b^3b^2 cb c^2c^3r   )r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r   r   r   r  )F40D   ☮   א)r   r  r	  r
  )
r   r"   r#   r
   r0   rT   r   rZ   r\   r]   )r%   polyrV   r   r   r   test_polynomial_feature_namesq  sB   r  )degr@   r   dtypecsc_containerc                 C   s   t jd}|ddd}||}t| ||d}|||}	|||}
t|	r2|	j	dks4J |	j
|
j
ks<J t|	 |
 d S )Nr   r   rb   r   r@   r   cscr   r   r   randintr
   r$   astyper   r   r   r  r   r   )r  r@   r   r  r  r   r%   X_cscr   Xt_cscXt_denser   r   r   test_polynomial_features_csc_X  s   r  csr_containerc                 C   s   t jd}|ddd}||}t| ||d}|||}	||j|dd}
t|	r4|	j	dks6J |	j
|
j
ks>J t|	 |
 d S )Nr   r   r  r  F)copyr   r  )r  r@   r   r  r  r   r%   X_csrr   Xt_csrr  r   r   r   test_polynomial_features_csr_X  s   r  
n_features)r(   r   r   zmin_degree, max_degree))r   r(   )r   r   )r(   r;   )r   r   )r;   r   r   c           
      C   sj   |dgdg| d gff}t |||d}|| |j}t j| d|||d}	|tdd |	D ks3J 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
   r0   r   _combinationsrg   )
r  r!  r"  r   r@   r  r   r   
num_comboscombosr   r   r   test_num_combinations  s    
r(  c           
      C   s   |t ddddd}| }t| ||d}|||}|||}	t|r/|jdks1J |j|	jks9J t	| |	 d S )N  r         ?r   random_stater  r   )
sparse_randomr   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_indexr  r   ))r   r   T)r(   r   Tr   r   T)r   r;   T)r(   r;   T)r   r;   T)r   r   F)r(   r   Fr   r   F)r   r;   F)r(   r;   F)r   r;   Fc           	      C   s   |t ddddd}d|| d d f< | }t|d|d}||}||}t|r1|jd	ks3J |j|jks;J t| | d S )
Nr;   r   r   r   r+  r   Fr  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_row6  s   

r3  ))TTrm   rn   )FFc                 C   sx   |t ddddd}| }td| |d}||}||}t|r)|jdks+J |j|jks3J t| | d S )	Nr)  r   r*  r   r+  r   r  r   r2  )r@   r   r  r  r%   r   r  r  r   r   r   'test_polynomial_features_csr_X_degree_4Z  s   

r4  )r  dimr   )
)r   r(   Tr0  )r;   r(   T)r;   r   T)r;   r;   T)r   r(   Fr1  )r;   r(   F)r;   r   F)r;   r;   Fc           	      C   sv   |t d|ddd}| }t| |d}||}||}t|r(|jdks*J |j|jks2J t| | d S )Nr)  r*  r   r+  r   r   r2  )	r  r5  r   r  r  r%   r   r  r  r   r   r   (test_polynomial_features_csr_X_dim_edgesp  s   

r7  c              	      sx   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}	||||	ff||f|d	}
t |dd
}|j|dd|j|jd}|t 	t j
jkrd}tjt|d ||
 W d   dS 1 s~w   Y  dS ||
}| \}}|| }|||	t   |	d | }|rdg|d  ng }|rdg|d  ng }tdD ]}|d|  }|d| d  }|	d|  }|	d| d  }|r|d |d |||g ||t| |t| g  s)||| || || g |||||| ||||| ||||| g q||| g ||||||  qt|d dt    }|j|d ksTJ |j|ks\J |j||d fkshJ |jj|jj  krzt jks}J  J |j t 	t jjksJ |rt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                    sD    r| | |d d|  d  d | S | | |d | d  | S )Nr   r;   r(   r   )r   ijr6  r   r   degree_2_calc  s   $zRtest_csr_polynomial_expansion_index_overflow_non_regression.<locals>.degree_2_calc   i r(   r   r  r   )r]   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*   Nr;   ) r   float32r"   int64r   r
   _num_combinationsr   r@   iinfointpr   r-   r.   r/   r0   r$   nonzerointr   appendextendr   r  r]   indptrr   int32listr   datar   )r   r@   r  r:  	n_samplesr  
data_dtyperK  rowcolr%   pfnum_combinationsr   r^   row_nonzerocol_nonzeron_degree_1_features_outmax_degree_2_idxdata_targetcol_nonzero_targetr8  r   r|   x_idxy_idxnnz_per_rowrow_nonzero_targetr   r6  r   ;test_csr_polynomial_expansion_index_overflow_non_regression  s   "




*
r\  zdegree, n_features)r     )r;   i(	  )r;   r]  c                 C   s  dg}|d t t jjkrt jnt j}t jdg|d}t j|d g|d}|d t| g}	|	||d  d |	d   |	||d  |d  d |	d   ||||ff}
t||| d}|j	|d| |j
|jd}|t t jjkrd	}tjt|d
 ||
 W d   dS 1 sw   Y  dS ttdk rd}t t jj}|| }td| d D ]'}t|
j||}t|||d }||d 7 }t|||k}|| o||kO }q|rd}tjt|d
 ||
}W d   dS 1 sw   Y  dS ttdk r1|dkr1| dkr1|s1d}tjt|d
 ||
}W d   dS 1 s*w   Y  dS ||
}|t t jjkrCt jnt j}d| d t|   }t|| }|j|
jks`J |jd|jfkskJ |jj|jj  kr||ksJ  J |j|ksJ |r|d tdksJ t|D ]}|d|	| f tdksJ q|| }| dkr|d| 9 }|j|	| d  d | ksJ 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`.
    r   r(   r   r<  r   r   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   r;   )r   rB  rI  r   r@  r   rE  rF  r
   rA  r   r@   rC  r-   r.   r/   r0   r   r   r   r   rH  r   r$   r  r]   r   r   nnzapprox)r<   r  r   r@   r  rK  indices_dtyperN  rO  expected_indicesr%   rP  rQ  r   has_bug	max_int32cumulative_sizer  
max_indptrmax_indicesneeds_int64r^   expected_dtypenon_bias_termsexpected_nnzidxoffsetr   r   r   ,test_csr_polynomial_expansion_index_overflow  s   "





 ($
$rn  c           
      C   s   t t jjd }dg}dg}|d g}||||ff}t| |dd}d}	tjt|	d || W d    n1 s<w   Y  tjt|	d |	| W d    d S 1 sYw   Y  d S )	Nr   r   r   r(   r   r=  r>  r*   )
r   rB  r@  r   r
   r-   r.   r/   r0   r$   )
r   r@   r  r  rK  rN  rO  r%   rP  r   r   r   r   0test_csr_polynomial_expansion_too_large_to_index|  s    
"ro  sparse_containerc                 C   s   t d}tddd}d}tjt|d || W d   n1 s$w   Y  tddd}d	}tjt|d || W d   n1 sHw   Y  || |fD ]#}tdd
d}||}t|ri|	 }t
|t |jd df qSd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*   Nr^  zoSetting both min_degree and max_degree to zero and include_bias to False would result in an empty output array.Tr(   )r   onesr
   r-   r.   r/   r$   r   r   r   r   r]   )rp  r%   r  r3   _Xoutputr   r   r   1test_polynomial_features_behaviour_on_zero_degree  s(   


rt  c                  C   s:   t jdkst jdkrt jdkrd} nd} t | ksJ d S )Nwin32        
emscriptenr      )sysplatformmaxsizer   )expected_sizer   r   r   test_sizeof_LARGEST_INT_t  s
   
r}  ru  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   | |||ff}tdddd	}tjd
krxd}t	j
t|d || W d    d S 1 sqw   Y  d S ||}	tdD ]}
|	d||
 f t	dksJ qd S )NgUUUUUU?r;   r   r   r(   r   r   Fr=  rv  r>  r*   )rE  r   rB  r@  r   rF  r
   ry  r{  r-   r.   r/   r$   r   r`  )r  r  rK  rN  rO  rb  r%   rP  r   r^   rl  r   r   r   *test_csr_polynomial_expansion_windows_fail  s0   
"
"
 r  )Ury  numpyr   r-   numpy.testingr   r   scipyr   scipy.interpolater   scipy.sparser   r-  sklearn.linear_modelr   sklearn.pipeliner   sklearn.preprocessingr	   r
   r   /sklearn.preprocessing._csr_polynomial_expansionr   r   r   sklearn.utils._testingr   sklearn.utils.fixesr   r   r   r   markparametrizer&   r4   r>   rW   r_   r   rj   r~   r   r   r   r   r   r   r   r   skipifr   r   r   r   fixturer   slicer   r   r   r  rE  r?  float64r  r  r(  r.  r3  r4  r7  r\  sqrtrB  r@  r   rn  ro  rt  r}  xfailrz  r  r   r   r   r   <module>   s   


	&
"("


&6
0






	



L



	rg
