https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/numpy/ma/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/numpy/ma/__pycache__/testutils.cpython-310.pyc
o

6��a�'�@s8dZddlZddlZddlmZmZddlmmZddl	Zddl	m
Z
mZmZm
Z
mZddlmZmZmZmZmZmZgd�ZddlmZgd	�ZeeZd,d
d�Zd-dd�Zd.dd�Zdd�Zd.dd�Zd.dd�ZeZ d/dd�Z!e!Z"		
d0dd�Z#d1d d!�Z$d1d"d#�Z%d2d$d%�Z&d2d&d'�Z'd1d(d)�Z(d.d*d+�Z)dS)3z�Miscellaneous functions for testing masked arrays and subclasses

:author: Pierre Gerard-Marchant
:contact: pierregm_at_uga_dot_edu
:version: $Id: testutils.py 3529 2007-11-13 08:01:14Z jarrod.millman $

�N)�ndarray�float_)�assert_�assert_allclose�assert_array_almost_equal_nulp�
assert_raises�
build_err_msg�)�mask_or�getmask�masked_array�nomask�masked�filled)�almost�approx�assert_almost_equal�assert_array_almost_equal�assert_array_approx_equal�assert_array_compare�assert_array_equal�assert_array_less�assert_close�assert_equal�assert_equal_records�assert_mask_equal�assert_not_equal�fail_if_array_equal)�TestCase)rrrrrT��h㈵��>�:�0�yE>cCs�tt|�t|��}t|�}t|�}|jjdks|jjdkr%t�||���Stt|d|d�|��	t
�}tt|d|d�d��	t
�}	t�t�
||	�||t�
|	��}
|
��S)a�
    Returns true if all components of a and b are equal to given tolerances.

    If fill_value is True, masked values considered equal. Otherwise,
    masked values are considered unequal.  The relative error rtol should
    be positive and << 1.0 The absolute error atol comes into play for
    those elements of b that are very small or zero; it says how small a
    must be also.

    �OF��copy�maskr	)r
rr�dtype�char�np�equal�ravelr�astyper�
less_equal�umath�absolute)�a�b�
fill_value�rtol�atol�m�d1�d2�x�y�d�r9�4/usr/lib/python3/dist-packages/numpy/ma/testutils.pyr)s$r�c
Cs�tt|�t|��}t|�}t|�}|jjdks|jjdkr%t�||���Stt|d|d�|��	t
�}tt|d|d�d��	t
�}t�t�||�|�d|k}	|	��S)z�
    Returns True if a and b are equal up to decimal places.

    If fill_value is True, masked values considered equal. Otherwise,
    masked values are considered unequal.

    r!Fr"r	�$@)
r
rrr%r&r'r(r)rr*r�around�abs)
r.r/�decimalr0r3r4r5r6r7r8r9r9r:r?s r�cCsJtt|�t|�|�tt|��D]}t||||d|�d|���qdS)z;
    Asserts the equality of two non-array sequences.

    �item=�
N)r�len�range)�actual�desired�err_msg�kr9r9r:�_assert_equal_on_sequencesRs"rIcCsdt|j|j�|jjD]$}t�||�t�||�}}|tur/|tur/tt�||�t�||��qdS)zI
    Asserts that two records are equal.

    Pretty crude for now.

    N)rr%�names�operator�getitemr)r.r/�f�af�bfr9r9r:r]s�rcCs|t|t�rDt|t�sttt|����tt|�t|�|�|��D]!\}}||vr1t|�d|����t||||d|�d|���q dSt|tt	f�rYt|tt	f�rYt
||dd�St|t�stt|t�stt||g|�}||ksrt|��dS|t
ur||t
us�|t
ur�|t
ur�t||g|ddd�}t|��t�|�}t�|�}|j|j}}|jd	kr�|jd	kr�t
|��|��dd�St|||�S)
z,
    Asserts that two items are equal.

    z not in �key=rBNr@�rG�r6r7)�headerrJ�S)�
isinstance�dict�AssertionError�repr�typerrC�items�list�tuplerIrrr�
ValueErrorr'�
asanyarrayr%r&�tolistr)rErFrGrH�i�msg�actual_dtype�
desired_dtyper9r9r:rls>

"�

�rcCs.t|t�rAt|t�sttt|����tt|�t|�|�|��D]\}}||vr.tt|���t||||d|�d|���q dSt|tt	f�rtt|tt	f�rttt|�t|�|�t
t|��D]}t||||d|�d|���q_dSt|tj�s�t|tj�r�t
|||�St||g|�}||ks�t|��dS)z<
    Raises an assertion error if two items are equal.

    rPrBNrA)rUrVrWrXrY�
fail_if_equalrCrZr[r\rDr'rrr)rErFrGrHr`rar9r9r:rd�s(

""�rd�cCs^t|tj�st|tj�rt|||||d�St||g||d�}tt||�|�dks-t|��dS)z~
    Asserts that two items are almost equal.

    The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal).

    )r?rG�verbose)rGrfrN)rUr'rrr�roundr>rW)rErFr?rGrfrar9r9r:r�s���rc	Cs�tt|�t|��}t|d|ddd�}t|d|ddd�}|tur#|tus+|tur:|tur:t||g|||dd�}t|��tjj||�	|�|�	|�|||d�S)zn
    Asserts that comparison between two masked arrays is satisfied.

    The comparison is elementwise.

    F)r#r$�	keep_mask�subokrR)rGrfrSrJ�rGrfrS)
r
rrrrr]r'�testingrr)	�
comparisonr6r7rGrfrSr0r3rar9r9r:r�s	��rcC�ttj||||dd�dS)z@
    Checks the elementwise equality of two masked arrays.

    �Arrays are not equalrjN)rrK�__eq__�r6r7rGrfr9r9r:r��

�rcCs dd�}t|||||dd�dS)zT
    Raises an assertion error if two masked arrays are not equal elementwise.

    cSst�t||��S)N)r'�alltruerrRr9r9r:�compare�sz$fail_if_array_equal.<locals>.comparernrjN�r)r6r7rGrfrsr9r9r:r�s
�rc�$�fdd�}t|||||dd�dS)�|
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    cst||d�d�S)�<Returns the result of the loose comparison between x and y).r<)r1)rrR�r?r9r:rs�sz*assert_array_approx_equal.<locals>.compare�Arrays are not almost equalrjNrt�r6r7r?rGrfrsr9rxr:r��
�rcru)rvcst||��S)rw)rrRrxr9r:rssz*assert_array_almost_equal.<locals>.compareryrjNrtrzr9rxr:r�r{rcCrm)z7
    Checks that x is smaller than y elementwise.

    zArrays are not less-orderedrjN)rrK�__lt__rpr9r9r:r
rqrcCs:|tur
t|tu�|turt|tu�t|||d�dS)z-
    Asserts the equality of two masks.

    rQN)r
rr)�m1�m2rGr9r9r:rs
r)Trr )r;T)r@)rer@T)r@Tr@T)r@T)r;r@T)*�__doc__rK�numpyr'rr�numpy.core.umath�corer,�
numpy.testingrrrrrr
rrr
rr�
__all__masked�unittestr�__some__from_testing�__all__rrrIrrrdrrrrrrrrrrr9r9r9r:�<module>s< 




'

�







https://t.me/RX1948 - 2025