o
    X۷i                     @  s   d dl mZ d dlZd dlZd dlZd dlZ		ddddd	Z	dddZdddZdddZ		ddddddZ
dddZdddddZdS )    )annotationsNHz>T F)strictc             
   C  sx   t jt jdkrt jjt| t|||||||d dS |r't	dt
 t jjt| t||||||d dS )a9  Raises an AssertionError if objects are not equal up to desired tolerance.

    Args:
         actual(numpy.ndarray or cupy.ndarray): The actual object to check.
         desired(numpy.ndarray or cupy.ndarray): The desired, expected object.
         rtol(float): Relative tolerance.
         atol(float): Absolute tolerance.
         err_msg(str): The error message to be printed in case of failure.
         verbose(bool): If ``True``, the conflicting
             values are appended to the error message.

    .. seealso:: :func:`numpy.testing.assert_allclose`

    2.0.0)rtolatol	equal_nanerr_msgverboser   N`cupy.testing.assert_allclose` does not support `strict` option with NumPy v1.)r   r   r	   r
   r   N)numpylibNumpyVersion__version__testingassert_allclosecupyasnumpywarningswarnRuntimeWarning)actualdesiredr   r   r	   r
   r   r    r   I/home/ubuntu/vllm_env/lib/python3.10/site-packages/cupy/testing/_array.pyr      s    

r      c                 C  s&   t jjt| t||||d dS )a  Raises an AssertionError if objects are not equal up to desired precision.

    Args:
         x(numpy.ndarray or cupy.ndarray): The actual object to check.
         y(numpy.ndarray or cupy.ndarray): The desired, expected object.
         decimal(int): Desired precision.
         err_msg(str): The error message to be printed in case of failure.
         verbose(bool): If ``True``, the conflicting
             values are appended to the error message.

    .. seealso:: :func:`numpy.testing.assert_array_almost_equal`
    )decimalr
   r   N)r   r   assert_array_almost_equalr   r   )r   r   r   r
   r   r   r   r   r   3   s   
r      c                 C  s"   t jjt| t||d dS )af  Compare two arrays relatively to their spacing.

    Args:
         x(numpy.ndarray or cupy.ndarray): The actual object to check.
         y(numpy.ndarray or cupy.ndarray): The desired, expected object.
         nulp(int): The maximum number of unit in the last place for tolerance.

    .. seealso:: :func:`numpy.testing.assert_array_almost_equal_nulp`
    )nulpN)r   r   assert_array_almost_equal_nulpr   r   )xyr    r   r   r   r!   H   s   

r!   c                 C  s$   t jjt| t|||d dS )a  Check that all items of arrays differ in at most N Units in the Last Place.

    Args:
         a(numpy.ndarray or cupy.ndarray): The actual object to check.
         b(numpy.ndarray or cupy.ndarray): The desired, expected object.
         maxulp(int): The maximum number of units in the last place
             that elements of ``a`` and ``b`` can differ.
         dtype(numpy.dtype): Data-type to convert ``a`` and ``b`` to if given.

    .. seealso:: :func:`numpy.testing.assert_array_max_ulp`
    )maxulpdtypeN)r   r   assert_array_max_ulpr   r   )abr$   r%   r   r   r   r&   V   s   
r&   )r   strides_checkc                C  s   t jt jdkrt jjt| t||||d n|r#t	dt
 t jjt| t|||d |rd| j|jkrfdg}|rI|d d | g}|r]|d| j |d	|j td
|dS dS )a   Raises an AssertionError if two array_like objects are not equal.

    Args:
         x(numpy.ndarray or cupy.ndarray): The actual object to check.
         y(numpy.ndarray or cupy.ndarray): The desired, expected object.
         strides_check(bool): If ``True``, consistency of strides is also
             checked.
         err_msg(str): The error message to be printed in case of failure.
         verbose(bool): If ``True``, the conflicting values
             are appended to the error message.
         strict(bool): If ``True``, raise an AssertionError when either
             the shape or the data type of the array_like objects does not
             match. Requires NumPy version 1.24 or above.

    .. seealso:: :func:`numpy.testing.assert_array_equal`
    z1.24.0r
   r   r   r   r
   r   zStrides are not equal:r    z x: {}z y: {}
N)r   r   r   r   r   assert_array_equalr   r   r   r   r   stridesappendformatAssertionErrorjoin)r   r   r
   r   r   r)   msgr   r   r   r.   f   s2   r.   c                 C  s   t | }t |}||urtd|||ttfvr!td|t| t|kr-tdt| |D ]\}}tjj	t
|t
|||d q2dS )a  Compares lists of arrays pairwise with ``assert_array_equal``.

    Args:
         x(array_like): Array of the actual objects.
         y(array_like): Array of the desired, expected objects.
         err_msg(str): The error message to be printed in case of failure.
         verbose(bool): If ``True``, the conflicting values
             are appended to the error message.

    Each element of ``x`` and ``y`` must be either :class:`numpy.ndarray`
    or :class:`cupy.ndarray`. ``x`` and ``y`` must have same length.
    Otherwise, this function raises ``AssertionError``.
    It compares elements of ``x`` and ``y`` pairwise
    with :func:`assert_array_equal` and raises error if at least one
    pair is not equal.

    .. seealso:: :func:`numpy.testing.assert_array_equal`
    zZMatching types of list or tuple are expected, but were different types (xlist:{} ylist:{})z%List or tuple is expected, but was {}zList size is differentr+   N)typer2   r1   listtuplelenzipr   r   r.   r   r   )xlistylistr
   r   x_typey_typer"   r#   r   r   r   assert_array_list_equal   s&   r>   c                C  sl   t jt jdkrt jjt| t||||d dS |r$t	dt
 t jjt| t|||d dS )a  Raises an AssertionError if array_like objects are not ordered by less than.

    Args:
         x(numpy.ndarray or cupy.ndarray): The smaller object to check.
         y(numpy.ndarray or cupy.ndarray): The larger object to compare.
         err_msg(str): The error message to be printed in case of failure.
         verbose(bool): If ``True``, the conflicting values
             are appended to the error message.

    .. seealso:: :func:`numpy.testing.assert_array_less`
    r   r*   r   r+   N)r   r   r   r   r   assert_array_lessr   r   r   r   r   )r"   r#   r
   r   r   r   r   r   r?      s   

r?   )r   r   Tr   T)r   r   T)r   )r   N)r   T)
__future__r   r   r   numpy.testingr   r   r   r!   r&   r.   r>   r?   r   r   r   r   <module>   s(    '



0%