
    ^iW                     2   d Z ddlmZ ddlZddlmZ ddlmZm	Z	 dej                  defd	Zdej                  defd
Z	 ddedee   defdZdZej                   j!                  e      Zej                   j!                  e      Z ej&                  eef      Zej                   j+                  dde      Zdez   ej.                  dej0                  z  ez        z   dez  z
   ej2                  dej0                  z  ez        z
  ez   Z e	ee      Zy)z)Helpers for testing monotone constraints.    )OptionalN   )FeatureNames)BoosterDMatrixvreturnc                 ^    t        j                  t        j                  |       dk        dk(  S )zWhether is v increasing.        r   npcount_nonzerodiffr   s    e/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/xgboost/testing/monotone_constraints.pyis_increasingr      %    BGGAJ,-22    c                 ^    t        j                  t        j                  |       dkD        dk(  S )zWhether is v decreasing.r   r   r   r   s    r   is_decreasingr      r   r   learnerfeature_namesc                    d}t        j                  dd|      j                  |df      }t        j                  dd|      }t        |      D ]  }||   t        j                  |df      z  }t        j
                  ||f      }t        ||      }| j                  |      }	t        j
                  ||f      }
t        |
|      }| j                  |      }t        |	      rt        |      r y y)z5Whether the monotone constraint is correctly applied.d   r      )r   FT)
r   linspacereshaperangeonescolumn_stackr   predictr   r   )r   r   n
variable_xfixed_xs_valuesifixed_xmonotonically_increasing_xmonotonically_increasing_dsetmonotonically_increasing_ymonotonically_decreasing_xmonotonically_decreasing_dsetmonotonically_decreasing_ys                r   is_correctly_constrainedr-      s     	AQ1%--q!f5Jkk!Q*O1X !!$rww1v6%'__j'5J%K"(/&m)
% &-__5R%S"%'__gz5J%K"(/&m)
% &-__5R%S" 4589%( r   i  )sizer   g{Gz?)locscaler.      
   )label)N)__doc__typingr   numpyr   _typingr   corer   r   ndarrayboolr   r   r-   NUMBER_OF_DPOINTSrandomx1_positively_correlated_with_yx2_negatively_correlated_with_yr    xnormalzssinpicosytraining_dset r   r   <module>rH      sO   /   " #3RZZ 3D 3
3RZZ 3D 3 ?C%-l%;	>  "$))"2"28I"2"J "$))"2"28I"2"J BOO46UVWYY#T0AB''bffR"%%Z99:;
))* bffR"%%Z99:; 			  #r   