%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python3.9/site-packages/numpy/ma/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib64/python3.9/site-packages/numpy/ma/__pycache__/testutils.cpython-39.opt-1.pyc

a

z[yc�'�@s4dZddlZddlZddlmZmZddlmmZddl	Zddl	m
Z
mZmZm
Z
mZddlmZmZmZmZmZmZgd�ZddlmZgd	�ZeeZd,d
d�Zd-dd�Zd.dd�Zdd�Zd/dd�Zd0dd�ZeZ d1dd�Z!e!Z"d2dd�Z#d3d d!�Z$d4d"d#�Z%d5d$d%�Z&d6d&d'�Z'd7d(d)�Z(d8d*d+�Z)dS)9z�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:|jjdkrJt�||���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�astyperZ
less_equal�umath�absolute)�a�b�
fill_value�rtolZatol�m�d1�d2�x�y�d�r7�8/usr/lib64/python3.9/site-packages/numpy/ma/testutils.pyr)s$r�c
Cs�tt|�t|��}t|�}t|�}|jjdks:|jjdkrJt�||���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*rZaround�abs)
r-r.�decimalr/r1r2r3r4r5r6r7r7r8r?s r�cCsJtt|�t|�|�tt|��D]$}t||||d|�d|���q dS)z;
    Asserts the equality of two non-array sequences.

    �item=�
N)r�len�range)�actual�desired�err_msg�kr7r7r8�_assert_equal_on_sequencesRs"rFcCsdt|j|j�|jjD]H}t�||�t�||�}}|tur|turtt�||�t�||��qdS)zI
    Asserts that two records are equal.

    Pretty crude for now.

    N)rr%�names�operator�getitemr)r-r.�f�afZbfr7r7r8r]srcCs�t|t�r�t|t�s$ttt|����tt|�t|�|�|��D]B\}}||vrbt|�d|����t||||d|�d|���q@dSt|tt	f�r�t|tt	f�r�t
||dd�St|t�s�t|t�s�t||g|�}||ks�t|��dS|t
ur�|t
u�s|t
u�r*|t
u�r*t||g|ddd�}t|��t�|�}t�|�}|j|j}}|jd	k�rz|jd	k�rzt
|��|��dd�St|||�S)
z,
    Asserts that two items are equal.

    z not in �key=r?Nr=�rD�r4r5)�headerrG�S)�
isinstance�dict�AssertionError�repr�typerr@�items�list�tuplerFrrr�
ValueErrorr'Z
asanyarrayr%r&�tolistr)rBrCrDrE�i�msgZactual_dtypeZ
desired_dtyper7r7r8rlsD

"���

�rcCs4t|t�r�t|t�s$ttt|����tt|�t|�|�|��D]<\}}||vr\tt|���t||||d|�d|���q@dSt|tt	f�r�t|tt	f�r�tt|�t|�|�t
t|��D]$}t||||d|�d|���q�dSt|tj��st|tj��rt
|||�St||g|�}||k�s0t|��dS)z<
    Raises an assertion error if two items are equal.

    rLr?Nr>)rQrRrSrTrU�
fail_if_equalr@rVrWrXrAr'rrr)rBrCrDrEr[r\r7r7r8r]�s&

""
r]�cCs^t|tj�st|tj�r*t|||||d�St||g||d�}tt||�|�dksZt|��dS)z~
    Asserts that two items are almost equal.

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

    )r<rD�verbose)rDr_rN)rQr'rrr�roundr;rS)rBrCr<rDr_r\r7r7r8r�s��rc	Cs�tt|�t|��}t|d|ddd�}t|d|ddd�}|turF|tusV|turt|turtt||g|||dd�}t|��tjj||�	|�|�	|�|||d�S)zn
    Asserts that comparison between two masked arrays is satisfied.

    The comparison is elementwise.

    F)r#r$Z	keep_maskZsubokrN)rDr_rOrG�rDr_rO)
r
rrrrrYr'Ztestingrr)	Z
comparisonr4r5rDr_rOr/r1r\r7r7r8r�s$	����rcCsttj||||dd�dS)z@
    Checks the elementwise equality of two masked arrays.

    �Arrays are not equalraN)rrH�__eq__�r4r5rDr_r7r7r8r�s
�rcCs dd�}t|||||dd�dS)zT
    Raises an assertion error if two masked arrays are not equal elementwise.

    cSst�t||��S)N)r'ZalltruerrNr7r7r8�compare�sz$fail_if_array_equal.<locals>.comparerbraN�r)r4r5rDr_rer7r7r8r�s�rcs$�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:)r0)rrN�r<r7r8re�sz*assert_array_approx_equal.<locals>.compare�Arrays are not almost equalraNrf�r4r5r<rDr_rer7rir8r�s�rcs$�fdd�}t|||||dd�dS)rgcst||��S)rh)rrNrir7r8resz*assert_array_almost_equal.<locals>.comparerjraNrfrkr7rir8r�s�rcCsttj||||dd�dS)z7
    Checks that x is smaller than y elementwise.

    zArrays are not less-orderedraN)rrH�__lt__rdr7r7r8r
s
�rcCs:|turt|tu�|tur(t|tu�t|||d�dS)z-
    Asserts the equality of two masks.

    rMN)r
rr)Zm1Zm2rDr7r7r8rs
r)Trr )r9T)r=)r=)r=)r^r=T)r=Tr=T)r=T)r=T)r9r=T)r9r=T)r=T)r=)*�__doc__rHZnumpyr'rrZnumpy.core.umathZcorer+Z
numpy.testingrrrrrr
rrr
rrZ
__all__maskedZunittestrZ__some__from_testing�__all__rrrFrrr]rrrrrrrrrrr7r7r7r8�<module>s: 



'

�








Zerion Mini Shell 1.0