o
    װij                     @   s^   d dl Zd dlZ		dddZddd	ZdddZdddZdddZdddZdddZ	dS )    NHz> Tc                 C   s(   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`

    )rtolatolerr_msgverboseN)numpytestingassert_allclosecupyasnumpy)actualdesiredr   r   r   r    r   G/home/ubuntu/.local/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   )xyr   r   r   r   r   r   r      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   )r   r   r   r   r   r   r   /   s   

r   c                 C   $   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   =   s   
r   Fc                 K   s   t jjt| t|f||d| |rE| j|jkrGdg}|r*|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`
    r   r   zStrides are not equal:r    z x: {}z y: {}
N)
r   r	   assert_array_equalr   r   stridesappendformatAssertionErrorjoin)r   r   r   r   strides_checkkwargsmsgr   r   r   r"   M   s&   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)typer&   r%   listtuplelenzipr   r	   r"   r   r   )xlistylistr   r   x_typey_typer   r   r   r   r   assert_array_list_equaln   s&   r4   c                 C   r   )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   N)r   r	   assert_array_lessr   r   )r   r   r   r   r   r   r   r5      s   
r5   )r   r   r   T)r   r   T)r   )r   N)r   TF)r   T)
numpy.testingr   r   r
   r   r   r   r"   r4   r5   r   r   r   r   <module>   s    





!%