
    -io                        S SK r S SKrS SKrS SKrS SKJrJr  S SKJr  S SK	J
r
  S SKJrJr  S SKrS SKJrJr  SSKJrJr  S	S
KJr   " S S\\5      rS rS rS r " S S\5      r\R?                  \ 5        S r! " S S\5      r" " S S\"5      r# " S S\"5      r$ " S S\"5      r% " S S\"5      r& " S S\"5      r' " S S \'5      r( " S! S"\"5      r) " S# S$\"5      r* " S% S&\"5      r+ " S' S(\"5      r, " S) S*\"5      r- " S+ S,\"5      r. " S- S.\"5      r/ " S/ S0\"5      r0 " S1 S2\"5      r1 " S3 S4\"5      r2 " S5 S6\"5      r3 " S7 S85      r4S9 r5S: r6g);    N)ABCabstractmethod)Iterable)	signature)IntegralReal)
csr_matrixissparse   )config_context
get_config   _is_arraylike_not_scalarc                       \ rS rSrSrSrg)InvalidParameterError   zqCustom exception to be raised when the parameter of a class/method/function
does not have a valid type or value.
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r       R/var/www/html/venv/lib/python3.13/site-packages/sklearn/utils/_param_validation.pyr   r      s    r   r   c                    UR                  5        H  u  p4X0;  a  M  X   nUS:X  a  M  U Vs/ s H  n[        U5      PM     nnU H  nUR                  U5      (       d  M    MS     U Vs/ s H  ofR                  (       a  M  UPM     nn[	        U5      S:X  a  US    nO6SR                  USS  Vs/ s H  n[        U5      PM     sn5       SUS    3n[        SU< S	U S
U SU< S3	5      e   gs  snf s  snf s  snf )aL  Validate types and values of given parameters.

Parameters
----------
parameter_constraints : dict or {"no_validation"}
    If "no_validation", validation is skipped for this parameter.

    If a dict, it must be a dictionary `param_name: list of constraints`.
    A parameter is valid if it satisfies one of the constraints from the list.
    Constraints can be:
    - an Interval object, representing a continuous or discrete range of numbers
    - the string "array-like"
    - the string "sparse matrix"
    - the string "random_state"
    - callable
    - None, meaning that None is a valid value for the parameter
    - any type, meaning that any instance of this type is valid
    - an Options object, representing a set of elements of a given type
    - a StrOptions object, representing a set of strings
    - the string "boolean"
    - the string "verbose"
    - the string "cv_object"
    - the string "nan"
    - a MissingValues object representing markers for missing values
    - a HasMethods object, representing method(s) an object must have
    - a Hidden object, representing a constraint not meant to be exposed to the user

params : dict
    A dictionary `param_name: param_value`. The parameters to validate against the
    constraints.

caller_name : str
    The name of the estimator or function or method that called this function.
no_validationr   r   , N or zThe z parameter of z	 must be z. Got 	 instead.)itemsmake_constraintis_satisfied_byhiddenlenjoinstrr   )	parameter_constraintsparamscaller_name
param_name	param_valconstraints
constraintconstraints_strcs	            r   validate_parameter_constraintsr4      s;   F "(
 2+7/)EPQ[zz2[Q%J)))44 & .9-8z@Q@Q
[   ;1$%0^$4 yy+cr2B!C2BQ#a&2B!CDE F#B(*  
 (znN;- @#$F9-yB G "0 R "Ds   C3*C8C82C=
c                    [        U [        5      (       a  U S:X  a
  [        5       $ [        U [        5      (       a  U S:X  a
  [        5       $ [        U [        5      (       a  U S:X  a
  [	        5       $ U [
        L a
  [        5       $ U c
  [        5       $ [        U [        5      (       a  [        U 5      $ [        U [        [        [        [        [        45      (       a  U $ [        U [        5      (       a  U S:X  a
  [        5       $ [        U [        5      (       a  U S:X  a
  [!        5       $ [        U [        5      (       a  U S:X  a
  [#        5       $ [        U [$        5      (       a  ['        U R(                  5      n SU l        U $ [        U [        5      (       a  U S:X  d0  [        U [,        5      (       a%  [.        R0                  " U 5      (       a
  [3        5       $ [5        S	U  35      e)
zConvert the constraint into the appropriate Constraint object.

Parameters
----------
constraint : object
    The constraint to convert.

Returns
-------
constraint : instance of _Constraint
    The converted constraint.
z
array-likezsparse matrixrandom_statebooleanverbose	cv_objectTnanUnknown constraint type: )
isinstancer*   _ArrayLikes_SparseMatrices_RandomStatescallable
_Callables_NoneConstrainttype_InstancesOfInterval
StrOptionsOptions
HasMethodsMissingValues	_Booleans_VerboseHelper
_CVObjectsHiddenr%   r1   r'   floatnpisnan_NanConstraint
ValueErrorr1   s    r   r%   r%   h   s    *c""z\'A}*c""z_'D  *c""z^'CX|  *d##J''Xz7JN  *c""zY'>{*c""zY'>*c""z['@|*f%%$Z%:%:;
 
:s##
e(;:u%%"((:*>*>
0=
>>r   c                   ^ ^ U U4S jnU$ )av  Decorator to validate types and values of functions and methods.

Parameters
----------
parameter_constraints : dict
    A dictionary `param_name: list of constraints`. See the docstring of
    `validate_parameter_constraints` for a description of the accepted constraints.

    Note that the *args and **kwargs parameters are not validated and must not be
    present in the parameter_constraints dictionary.

prefer_skip_nested_validation : bool
    If True, the validation of parameters of inner estimators or functions
    called by the decorated function will be skipped.

    This is useful to avoid validating many times the parameters passed by the
    user from the public facing API. It's also useful to avoid validating
    parameters that we pass internally to inner functions that are guaranteed to
    be valid by the test suite.

    It should be set to True for most functions, except for those that receive
    non-validated objects as parameters or that are just wrappers around classes
    because they only perform a partial validation.

Returns
-------
decorated_function : function or method
    The decorated function.
c                 f   >^  [        T ST5        [        R                  " T 5      U UU4S j5       nU$ )N_skl_parameter_constraintsc                    > [        5       S   nU(       a  T" U 0 UD6$ [        T5      nUR                  " U 0 UD6nUR                  5         UR                  R                  5        Vs/ s H7  nUR                  UR                  UR                  4;   d  M+  UR                  PM9     nnUSS/-  nUR                  R                  5        VVs0 s H  u  pxXv;  d  M  Xx_M     nnn[        TUTR                  S9   [        T=(       d    US9   T" U 0 UD6sS S S 5        $ s  snf s  snnf ! , (       d  f       g = f! [         a@  n	[         R"                  " SSTR                   S3[%        U	5      5      n
[        U
5      U	eS n	A	ff = f)	Nskip_parameter_validationselfcls)r-   )rX   zparameter of \w+ must bezparameter of z must be)r   r   bindapply_defaults
parametersvalueskindVAR_POSITIONALVAR_KEYWORDname	argumentsr$   r4   r   r   r   resubr*   )argskwargsglobal_skip_validationfunc_sigr,   p	to_ignorekvemsgfuncr+   prefer_skip_nested_validations              r   wrapper3validate_params.<locals>.decorator.<locals>.wrapper   s   %/\2M%N"%T,V,, H ]]D3F3F!!#
 ",,3355A66a..>> 5  
 &%(I'-'7'7'='='?V'?tq1CUdad'?FV*%v4;L;L8#5O9O
  00  W  ) 
8
 ff/#D$5$5#6h?F
 ,C0a7
8sN   '*DDD"D"9D9 D(	D9 (
D62D9 6D9 9
F;E>>F)setattr	functoolswraps)rp   rr   r+   rq   s   ` r   	decorator"validate_params.<locals>.decorator   s6     	24IJ		)	8 
)	8V r   r   )r+   rq   rw   s   `` r   validate_paramsry      s    >2h r   c                       \ rS rSrSrSrg)
RealNotInt   zA type that represents reals that are not instances of int.

Behaves like float, but also works with values extracted from numpy arrays.
isintance(1, RealNotInt) -> False
isinstance(1.0, RealNotInt) -> True
r   Nr   r   r   r   r{   r{      s    r   r{   c                 |    U R                   nU R                  nUS:X  a  U$ U [        :X  a  gU [        :X  a  gU SU 3$ )z(Convert type into human readable string.builtinsrN   int.)r   r   r   r   )tmodulequalnames      r   
_type_namer      sF    \\F~~H	
d	
hXQxj!!r   c                   >    \ rS rSrSrS r\S 5       r\S 5       rSr	g)_Constrainti  z&Base class for the constraint objects.c                     SU l         g NFr'   rY   s    r   __init___Constraint.__init__  s	    r   c                     g)zWhether or not a value satisfies the constraint.

Parameters
----------
val : object
    The value to check.

Returns
-------
is_satisfied : bool
    Whether or not the constraint is satisfied by this value.
Nr   rY   vals     r   r&   _Constraint.is_satisfied_by      r   c                     g)z;A human readable representational string of the constraint.Nr   r   s    r   __str___Constraint.__str__  r   r   r   N)
r   r   r   r   r   r   r   r&   r   r   r   r   r   r   r     s4    0   J Jr   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )rD   i  zjConstraint representing instances of a given type.

Parameters
----------
type : type
    The valid type.
c                 .   > [         TU ]  5         Xl        g N)superr   rC   )rY   rC   	__class__s     r   r   _InstancesOf.__init__(  s    	r   c                 ,    [        XR                  5      $ r   r<   rC   r   s     r   r&   _InstancesOf.is_satisfied_by,  s    #yy))r   c                 4    S[        U R                  5      < 3$ )Nzan instance of )r   rC   r   s    r   r   _InstancesOf.__str__/  s     DII!6 9::r   )rC   
r   r   r   r   r   r   r&   r   r   __classcell__r   s   @r   rD   rD     s    *; ;r   rD   c                   $    \ rS rSrSrS rS rSrg)rB   i3  z+Constraint representing the None singleton.c                 
    US L $ r   r   r   s     r   r&   _NoneConstraint.is_satisfied_by6  s    d{r   c                     g)NNoner   r   s    r   r   _NoneConstraint.__str__9  s    r   r   Nr   r   r   r   r   r&   r   r   r   r   r   rB   rB   3  s    5r   rB   c                   $    \ rS rSrSrS rS rSrg)rQ   i=  z/Constraint representing the indicator `np.nan`.c                     [        U[        5      (       + =(       a-    [        U[        5      =(       a    [        R                  " U5      $ r   )r<   r   r   mathrP   r   s     r   r&   _NanConstraint.is_satisfied_by@  s.    3))Wjd.CW

SV	
r   c                     g)Nz	numpy.nanr   r   s    r   r   _NanConstraint.__str__E      r   r   Nr   r   r   r   rQ   rQ   =  s    9

r   rQ   c                   $    \ rS rSrSrS rS rSrg)_PandasNAConstraintiI  z.Constraint representing the indicator `pd.NA`.c                      SS K n[        U[        UR                  5      5      =(       a    UR	                  U5      $ ! [
         a     gf = f)Nr   F)pandasr<   rC   NAisnaImportError)rY   r   pds      r   r&   #_PandasNAConstraint.is_satisfied_byL  s>    	c4;/@BGGCL@ 		s   := 
A
	A
c                     g)Nz	pandas.NAr   r   s    r   r   _PandasNAConstraint.__str__T  r   r   r   Nr   r   r   r   r   r   I  s    8r   r   c                   F   ^  \ rS rSrSrSS.U 4S jjrS rS rS rS	r	U =r
$ )
rG   iX  a#  Constraint representing a finite set of instances of a given type.

Parameters
----------
type : type

options : set
    The set of valid scalars.

deprecated : set or None, default=None
    A subset of the `options` to mark as deprecated in the string
    representation of the constraint.
N
deprecatedc                   > [         TU ]  5         Xl        X l        U=(       d
    [	        5       U l        U R
                  U R                  -
  (       a  [        S5      eg )Nz7The deprecated options must be a subset of the options.)r   r   rC   optionssetr   rR   )rY   rC   r   r   r   s       r   r   Options.__init__g  sG    	$-??T\\)VWW *r   c                 V    [        XR                  5      =(       a    XR                  ;   $ r   )r<   rC   r   r   s     r   r&   Options.is_satisfied_byp  s    #yy)Ac\\.AAr   c                 6    U< nXR                   ;   a  U S3nU$ )z-Add a deprecated mark to an option if needed.z (deprecated)r   )rY   option
option_strs      r   _mark_if_deprecatedOptions._mark_if_deprecateds  s%    z
__$&<}5Jr   c                     SR                  U R                   Vs/ s H  oR                  U5      PM     sn5       nS[        U R                  5       SU S3$ s  snf )Nr    za z among {})r)   r   r   r   rC   )rY   ooptions_strs      r   r   Options.__str__z  sY    yyt||L|!2215|LMN 	 Jtyy)*)K=CC Ms   A)r   r   rC   )r   r   r   r   r   r   r&   r   r   r   r   r   s   @r   rG   rG   X  s0     59 X XBD Dr   rG   c                   4   ^  \ rS rSrSrSS.U 4S jjrSrU =r$ )rF   i  a  Constraint representing a finite set of strings.

Parameters
----------
options : set of str
    The set of valid strings.

deprecated : set of str or None, default=None
    A subset of the `options` to mark as deprecated in the string
    representation of the constraint.
Nr   c                *   > [         TU ]  [        XS9  g )N)rC   r   r   )r   r   r*   )rY   r   r   r   s      r   r   StrOptions.__init__  s    c7Jr   r   )r   r   r   r   r   r   r   r   r   s   @r   rF   rF     s    
 /3 K Kr   rF   c                   D   ^  \ rS rSrSrU 4S jrS rS rS rS r	Sr
U =r$ )	rE   i  u  Constraint representing a typed interval.

Parameters
----------
type : {numbers.Integral, numbers.Real, RealNotInt}
    The set of numbers in which to set the interval.

    If RealNotInt, only reals that don't have the integer type
    are allowed. For example 1.0 is allowed but 1 is not.

left : float or int or None
    The left bound of the interval. None means left bound is -∞.

right : float, int or None
    The right bound of the interval. None means right bound is +∞.

closed : {"left", "right", "both", "neither"}
    Whether the interval is open or closed. Possible choices are:

    - `"left"`: the interval is closed on the left and open on the right.
      It is equivalent to the interval `[ left, right )`.
    - `"right"`: the interval is closed on the right and open on the left.
      It is equivalent to the interval `( left, right ]`.
    - `"both"`: the interval is closed.
      It is equivalent to the interval `[ left, right ]`.
    - `"neither"`: the interval is open.
      It is equivalent to the interval `( left, right )`.

Notes
-----
Setting a bound to `None` and setting the interval closed is valid. For instance,
strictly speaking, `Interval(Real, 0, None, closed="both")` corresponds to
`[0, +∞) U {+∞}`.
c                r   > [         TU ]  5         Xl        X l        X0l        X@l        U R                  5         g r   )r   r   rC   leftrightclosed_check_params)rY   rC   r   r   r   r   s        r   r   Interval.__init__  s.    		
r   c                 L   U R                   [        [        [        4;  a  [	        SU R                    S35      eU R
                  S;  a  [	        SU R
                   S35      eU R                   [        L a  SnU R                  b-  [        U R                  [        5      (       d  [        SU 35      eU R                  b-  [        U R                  [        5      (       d  [        SU 35      eU R                  c+  U R
                  S;   a  [	        S	U R
                   S
U 35      eU R                  c+  U R
                  S;   a  [	        SU R
                   S
U 35      eOnU R                  b*  [        U R                  [        5      (       d  [        S5      eU R                  b*  [        U R                  [        5      (       d  [        S5      eU R                  bN  U R                  b@  U R                  U R                  ::  a%  [	        SU R                   SU R                   35      eg g g )NzFtype must be either numbers.Integral, numbers.Real or RealNotInt. Got r#   )r   r   bothneitherz@closed must be either 'left', 'right', 'both' or 'neither'. Got z"for an interval over the integers.zExpecting left to be an int zExpecting right to be an int r   r   z"left can't be None when closed ==  r   r   z#right can't be None when closed == z#Expecting left to be a real number.z$Expecting right to be a real number.z(right can't be less than left. Got left=z and right=)
rC   r   r   r{   rR   r   r   r<   	TypeErrorr   )rY   suffixs     r   r   Interval._check_params  s   99XtZ88		{)- 
 ;;BB{{m9. 
 99 9Fyy$Z		8-L-L">vh GHHzz%jX.N.N"?x HIIyy T[[4D%D 8QvhO  zz!dkk5F&F 9$++axP  yy$Z		4-H-H EFFzz%jT.J.J FGG::!dii&;

dii@W:499+ F&  AX&;!r   c                    [        U[        5      (       d  [        R                  " U5      (       a  gU R                  S;   a  [
        R                  O[
        R                  nU R                  S;   a  [
        R                  O[
        R                  nU R                  c  [        R                  * OU R                  nU R                  c  [        R                  OU R                  nU" X5      (       a  gU" X5      (       a  gg)NFr   r   T)r<   r   rO   rP   r   operatorltlegtger   infr   )rY   r   left_cmp	right_cmpr   r   s         r   __contains__Interval.__contains__  s    #x((RXXc]]"&++1A"A8;;x{{#';;2C#CHKK	))+w**,$**CS  r   c                 @    [        XR                  5      (       d  gX;   $ r   r   r   s     r   r&   Interval.is_satisfied_by  s    #yy)){r   c                     U R                   [        L a  SOSnU R                  S;   a  SOSnU R                  c  SOU R                  nU R                  c  SOU R                  nU R                  S;   a  S	OS
nU R                   [        :X  d*  [        U R                  [        5      (       a  [        U5      nU R                   [        :X  d*  [        U R                  [        5      (       a  [        U5      nU SU U SU U 3$ )Nzan intza floatr   [(z-infr   r   ])z in the range r    )rC   r   r   r   r   r<   r   rN   )rY   type_strleft_bracket
left_boundright_boundright_brackets         r   r   Interval.__str__  s    #yyH48)"kk-==s3#yy0Vdii
#zz1etzz#{{.??S yyH$DIIt)D)Dz*JyyH$DJJ)E)E,K jnZL;-H	
r   )r   r   r   rC   )r   r   r   r   r   r   r   r   r&   r   r   r   r   s   @r   rE   rE     s(    !F%N 
 
r   rE   c                   $    \ rS rSrSrS rS rSrg)r=   i  z#Constraint representing array-likesc                     [        U5      $ r   r   r   s     r   r&   _ArrayLikes.is_satisfied_by  s    ',,r   c                     g)Nzan array-liker   r   s    r   r   _ArrayLikes.__str__  s    r   r   Nr   r   r   r   r=   r=     s    --r   r=   c                   $    \ rS rSrSrS rS rSrg)r>   i  z(Constraint representing sparse matrices.c                     [        U5      $ r   )r
   r   s     r   r&   _SparseMatrices.is_satisfied_by      }r   c                     g)Nza sparse matrixr   r   s    r   r   _SparseMatrices.__str__  s     r   r   Nr   r   r   r   r>   r>     s    2!r   r>   c                   $    \ rS rSrSrS rS rSrg)rA   i#  z"Constraint representing callables.c                     [        U5      $ r   )r@   r   s     r   r&   _Callables.is_satisfied_by&  r  r   c                     g)Nz
a callabler   r   s    r   r   _Callables.__str__)  s    r   r   Nr   r   r   r   rA   rA   #  s    ,r   rA   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )r?   i-  zConstraint representing random states.

Convenience class for
[Interval(Integral, 0, 2**32 - 1, closed="both"), np.random.RandomState, None]
c                    > [         TU ]  5         [        [        SSSS9[	        [
        R                  R                  5      [        5       /U l	        g )Nr   l    r   r   )
r   r   rE   r   rD   rO   randomRandomStaterB   _constraintsrY   r   s    r   r   _RandomStates.__init__4  s>    Xq)F;../
r   c                 B   ^ [        U4S jU R                   5       5      $ )Nc              3   D   >#    U  H  oR                  T5      v   M     g 7fr   r&   .0r3   r   s     r   	<genexpr>0_RandomStates.is_satisfied_by.<locals>.<genexpr>=       E3Da$$S))3D    anyr  r   s    `r   r&   _RandomStates.is_satisfied_by<      E43D3DEEEr   c                     SR                  U R                  S S  Vs/ s H  n[        U5      PM     sn5       SU R                  S    3$ s  snf Nr    r!   r"   r)   r  r*   rY   r3   s     r   r   _RandomStates.__str__?  W    yy$*;*;CR*@A*@Q#a&*@ABC D!!"%&(	
A   Ar  r   r   s   @r   r?   r?   -      
F
 
r   r?   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )rJ   iF  zOConstraint representing boolean likes.

Convenience class for
[bool, np.bool_]
c                 |   > [         TU ]  5         [        [        5      [        [        R
                  5      /U l        g r   )r   r   rD   boolrO   bool_r  r  s    r   r   _Booleans.__init__M  s,    "
r   c                 B   ^ [        U4S jU R                   5       5      $ )Nc              3   D   >#    U  H  oR                  T5      v   M     g 7fr   r  r  s     r   r  ,_Booleans.is_satisfied_by.<locals>.<genexpr>U  r  r  r  r   s    `r   r&   _Booleans.is_satisfied_byT  r  r   c                     SR                  U R                  S S  Vs/ s H  n[        U5      PM     sn5       SU R                  S    3$ s  snf r   r!  r"  s     r   r   _Booleans.__str__W  r$  r%  r&  r   r   s   @r   rJ   rJ   F  s    
F
 
r   rJ   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )rK   i^  zHelper constraint for the verbose parameter.

Convenience class for
[Interval(Integral, 0, None, closed="left"), bool, numpy.bool_]
c                    > [         TU ]  5         [        [        SS SS9[	        [
        5      [	        [        R                  5      /U l        g )Nr   r   r  )	r   r   rE   r   rD   r*  rO   r+  r  r  s    r   r   _VerboseHelper.__init__e  s:    Xq$v6"
r   c                 B   ^ [        U4S jU R                   5       5      $ )Nc              3   D   >#    U  H  oR                  T5      v   M     g 7fr   r  r  s     r   r  1_VerboseHelper.is_satisfied_by.<locals>.<genexpr>n  r  r  r  r   s    `r   r&   _VerboseHelper.is_satisfied_bym  r  r   c                     SR                  U R                  S S  Vs/ s H  n[        U5      PM     sn5       SU R                  S    3$ s  snf r   r!  r"  s     r   r   _VerboseHelper.__str__p  r$  r%  r&  r   r   s   @r   rK   rK   ^  r'  r   rK   c                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )rI   iw  a  Helper constraint for the `missing_values` parameters.

Convenience for
[
    Integral,
    Interval(Real, None, None, closed="both"),
    str,   # when numeric_only is False
    None,  # when numeric_only is False
    _NanConstraint(),
    _PandasNAConstraint(),
]

Parameters
----------
numeric_only : bool, default=False
    Whether to consider only numeric missing value markers.

c                 "  > [         TU ]  5         Xl        [        [        5      [        [        S S SS9[        5       [        5       /U l	        U R                  (       d3  U R                  R                  [        [        5      [        5       /5        g g )Nr   r  )r   r   numeric_onlyrD   r   rE   r   rQ   r   r  extendr*   rB   )rY   r>  r   s     r   r   MissingValues.__init__  ss    ( "T4f5!
   $$l3&79J%KL !r   c                 B   ^ [        U4S jU R                   5       5      $ )Nc              3   D   >#    U  H  oR                  T5      v   M     g 7fr   r  r  s     r   r  0MissingValues.is_satisfied_by.<locals>.<genexpr>  r  r  r  r   s    `r   r&   MissingValues.is_satisfied_by  r  r   c                     SR                  U R                  S S  Vs/ s H  n[        U5      PM     sn5       SU R                  S    3$ s  snf r   r!  r"  s     r   r   MissingValues.__str__  r$  r%  )r  r>  )Fr   r   s   @r   rI   rI   w  s    &MF
 
r   rI   c                   T   ^  \ rS rSrSr\" S\\/0SS9U 4S j5       rS r	S r
S	rU =r$ )
rH   i  a-  Constraint representing objects that expose specific methods.

It is useful for parameters following a protocol and where we don't want to impose
an affiliation to a specific module or class.

Parameters
----------
methods : str or list of str
    The method(s) that the object is expected to expose.
methodsT)rq   c                 ^   > [         TU ]  5         [        U[        5      (       a  U/nXl        g r   )r   r   r<   r*   rH  )rY   rH  r   s     r   r   HasMethods.__init__  s)    
 	gs##iGr   c                 B   ^ [        U4S jU R                   5       5      $ )Nc              3   P   >#    U  H  n[        [        TUS 5      5      v   M     g 7fr   )r@   getattr)r  methodr   s     r   r  -HasMethods.is_satisfied_by.<locals>.<genexpr>  s"     SlF8GC677ls   #&)allrH  r   s    `r   r&   HasMethods.is_satisfied_by  s    SdllSSSr   c                    [        U R                  5      S:X  a  U R                  S   < nOKSR                  U R                  S S  Vs/ s H  n[        U5      PM     sn5       SU R                  S   < 3nSU 3$ s  snf )Nr   r   r    r!   z and zan object implementing )r(   rH  r)   repr)rY   rH  ms      r   r   HasMethods.__str__  s    t||!a+G 99t||CR/@A/@!d1g/@ABC DLL$')  )	22 Bs   A<)rH  )r   r   r   r   r   ry   r*   listr   r&   r   r   r   r   s   @r   rH   rH     s@    	 	S$K &*	T3 3r   rH   c                   $    \ rS rSrSrS rS rSrg)_IterablesNotStringi  z7Constraint representing iterables that are not strings.c                 Z    [        U[        5      =(       a    [        U[        5      (       + $ r   )r<   r   r*   r   s     r   r&   #_IterablesNotString.is_satisfied_by  s    #x(EC1E-EEr   c                     g)Nzan iterabler   r   s    r   r   _IterablesNotString.__str__  s    r   r   Nr   r   r   r   rX  rX    s    AFr   rX  c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )rL   i  zConstraint representing cv objects.

Convenient class for
[
    Interval(Integral, 2, None, closed="left"),
    HasMethods(["split", "get_n_splits"]),
    _IterablesNotString(),
    None,
]
c                    > [         TU ]  5         [        [        SS SS9[	        SS/5      [        5       [        5       /U l        g )Nr   r   r  splitget_n_splits)r   r   rE   r   rH   rX  rB   r  r  s    r   r   _CVObjects.__init__  s?    Xq$v601!	
r   c                 B   ^ [        U4S jU R                   5       5      $ )Nc              3   D   >#    U  H  oR                  T5      v   M     g 7fr   r  r  s     r   r  -_CVObjects.is_satisfied_by.<locals>.<genexpr>  r  r  r  r   s    `r   r&   _CVObjects.is_satisfied_by  r  r   c                     SR                  U R                  S S  Vs/ s H  n[        U5      PM     sn5       SU R                  S    3$ s  snf r   r!  r"  s     r   r   _CVObjects.__str__  r$  r%  r&  r   r   s   @r   rL   rL     s    	
F
 
r   rL   c                       \ rS rSrSrS rSrg)rM   i  zClass encapsulating a constraint not meant to be exposed to the user.

Parameters
----------
constraint : str or _Constraint instance
    The constraint to be used internally.
c                     Xl         g r   rS   )rY   r1   s     r   r   Hidden.__init__  s    $r   rS   N)r   r   r   r   r   r   r   r   r   r   rM   rM     s    %r   rM   c                    [        U [        5      (       a  SSR                  U R                  5       3$ [        U [        5      (       a  [
        R                  " / SQ5      $ [        U [        5      (       a  g[        U [        5      (       a  [        SS0 5      " 5       $ [        U [        5      (       a  g[        U [        5      (       a  g[        U [        5      (       aQ  U R                  [        L a>  U R                  b  U R                  S	-
  $ U R                  b  U R                  S	-   $ [         e[        U [        5      (       a  U R                  ["        [$        4;   a  U R                  b  U R                  S
-
  $ U R                  b  U R                  S
-   $ U R&                  S;   a  [
        R(                  * $ U R&                  S;   a  [
        R(                  $ [
        R*                  $ [         e)ah  Return a value that does not satisfy the constraint.

Raises a NotImplementedError if there exists no invalid value for this constraint.

This is only useful for testing purpose.

Parameters
----------
constraint : _Constraint instance
    The constraint to generate a value for.

Returns
-------
val : object
    A value that does not satisfy the constraint.
znot r"   r   r      r!   HasNotMethodsr   za stringznot a cv objectr   gư>)r   r   )r   r   )r<   rF   r)   r   rI   rO   arrayrK   rH   rC   rX  rL   rE   r   r   r   NotImplementedErrorr   r{   r   r   r:   rS   s    r   generate_invalid_param_valrq    s   " *j))fkk*"4"45677*m,,xx	""*n--*j))OR,..*122*j)) *h''JOOx,G??&??Q&&'##a'' "!*h''JOOj?Q,Q??&??T))'##d**  44FF7N 3366M vv
r   c           	         [        U [        5      (       a  [        R                  " / SQ5      $ [        U [        5      (       a  [        SS/SS//5      $ [        U [        5      (       a  [        R                  R                  S5      $ [        U [        5      (       a  S $ [        U [        5      (       a  g[        U [        5      (       a`  U R                  [        R                  L a  [        R                  " / SQ5      $ U R                  [        [        4;   a  gU R                  5       $ [        U [         5      (       a  g[        U ["        5      (       a  g[        U [$        5      (       a!  U R&                  (       a  [        R(                  $ [        U [$        5      (       a  U R&                  (       d  g[        U [*        5      (       a.  [        S	S
U R,                   Vs0 s H  oS _M     sn5      " 5       $ [        U [.        5      (       a  / SQ$ [        U [0        5      (       a  g[        U [2        5      (       a  U R4                   H  nUs  $    [        U [6        5      (       a  U nUR8                  c  UR:                  c  gUR8                  c  UR:                  S-
  $ UR:                  c  UR8                  S-   $ UR                  [        L a  UR8                  UR:                  -   S-  $ UR8                  S-   $ [=        SU  35      es  snf )a	  Return a value that does satisfy a constraint.

This is only useful for testing purpose.

Parameters
----------
constraint : Constraint instance
    The constraint to generate a value for.

Returns
-------
val : object
    A value that does satisfy the constraint.
rl  r   r   *   c                     U $ r   r   )xs    r   <lambda>&generate_valid_param.<locals>.<lambda>U  s    r   NTmissingValidHasMethodsr   c                     g r   r   r   s    r   rv  rw  s  s    Dr      r   r;   )r<   r=   rO   ro  r>   r	   r?   r  r  rA   rB   rD   rC   ndarrayr   r   rJ   rK   rI   r>  r:   rH   rH  rX  rL   rG   r   rE   r   r   rR   )r1   rT  r   intervals       r   generate_valid_paramr~  <  s^    *k**xx	""*o..Aq6Aq6*++*m,,yy$$R((*j))*o..*l++??bjj(88I&&??x..  *i((*n--*m,,1H1Hvv*m,,Z5L5L*j))r*BTBT#UBTQ'8$8BT#U
  	 *122*j))*g&& ((FM ) *h''== X^^%;]]">>A%%^^#==1$$}}$ 6!;;}}q((
0=
>>7 $Vs   L)7ru   r   r   rd   abcr   r   collections.abcr   inspectr   numbersr   r   numpyrO   scipy.sparser	   r
   _configr   r   
validationr   rR   r   r   r4   r%   ry   r{   registerrN   r   r   rD   rB   rQ   r   rG   rF   rE   r=   r>   rA   r?   rJ   rK   rI   rH   rX  rL   rM   rq  r~  r   r   r   <module>r     sh      	 # $  "  - 0 0J	 IX+?\Sl    E 
"J# J4;; ;(k 	[ 	+ &Dk &DRK K"z
{ z
z+ !k ! 
K 
2
 
0
[ 
2*
K *
Z!3 !3H+ 
 
>
% 
%;|R?r   