o
    Ú­jk  ã                   @   sÎ   U d Z ddlmZmZmZmZ ddlZddlm	Z	m
Z
 ddlmZ ed Zeed< d	dd
œdedededededdfdd„Zdededefdd„Zddee dedefdd„Zddee dedefdd„ZdS )zHelpers for test code.é    )ÚAnyÚLiteralÚSequenceÚ	TypeAliasNé   )Ú_is_cupy_alikeÚimport_cupy)ÚDMatrix)ÚcpuÚcudaÚDevicegH¯¼šò×z>)ÚrtolÚatolÚdeviceÚaÚbr   r   Úreturnc                C   sN   | dkrt |ƒst |ƒstjj||||d� dS tƒ }|jj||||d� dS )z)Dispatch the assert_allclose for devices.r
   )r   r   N)r   ÚnpÚtestingÚassert_allcloser   )r   r   r   r   r   Úcp© r   úR/var/www/html/CropPilot/venv/lib/python3.10/site-packages/xgboost/testing/utils.pyr      s   r   ÚlhsÚrhsc                 C   sB   |   ¡ }|  ¡ }tt |j|j¡t |j|j¡t |j|j¡fƒS )z9Assert whether two DMatrices contain the same predictors.)Úget_dataÚallr   Úarray_equalÚdataÚindicesÚindptr)r   r   ÚlcsrÚrcsrr   r   r   Úpredictor_equal   s   ýÿr#   ç-Cëâ6?ÚLÚ	tolerancec                    ó$   t ‡ fdd„t| | dd… ƒD ƒƒS )z*Values in the sequence are not increasing.c                 3   s    � | ]\}}|| ˆ k V  qd S ©Nr   ©Ú.0ÚxÚy©r&   r   r   Ú	<genexpr>'   s   € z!non_increasing.<locals>.<genexpr>é   N©r   Úzip©r%   r&   r   r-   r   Únon_increasing%   ó   $r3   c                    r'   )z*Values in the sequence are not decreasing.c                 3   s"   � | ]\}}|| ˆ  kV  qd S r(   r   r)   r-   r   r   r.   ,   s   €  z!non_decreasing.<locals>.<genexpr>r/   Nr0   r2   r   r-   r   Únon_decreasing*   r4   r5   )r$   )Ú__doc__Útypingr   r   r   r   Únumpyr   Úcompatr   r   Úcorer	   r   Ú__annotations__Úfloatr   Úboolr#   r3   r5   r   r   r   r   Ú<module>   s.    ÿÿÿÿÿÿ
þ 