HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/imh-python/lib/python3.9/site-packages/numpy/ma/__pycache__/testutils.cpython-39.pyc
a

e�h�'�@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��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/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*r�around�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"rGcCsdt|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�af�bfr7r7r8r]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>�rE�r4r5)�headerrH�S)�
isinstance�dict�AssertionError�repr�typerrA�items�list�tuplerGrrr�
ValueErrorr'Z
asanyarrayr%r&�tolistr)rCrDrErF�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.

    rNr@Nr?)rSrTrUrVrW�
fail_if_equalrArXrYrZrBr'rrr)rCrDrErFr]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=rE�verbose)rErarN)rSr'rrr�roundr<rU)rCrDr=rErar^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_maskZsubokrP)rErarQrH�rErarQ)
r
rrrrr[r'Ztestingrr)	Z
comparisonr4r5rErarQr/r1r^r7r7r8r�s$	����rcCsttj||||dd�dS)z@
    Checks the elementwise equality of two masked arrays.

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

    cSst�t||��S)N)r'�allrrPr7r7r8�compare�sz$fail_if_array_equal.<locals>.comparerdrcN�r)r4r5rErarhr7r7r8r�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)rrP�r=r7r8rh�sz*assert_array_approx_equal.<locals>.compare�Arrays are not almost equalrcNri�r4r5r=rErarhr7rlr8r�s�rcs$�fdd�}t|||||dd�dS)rjcst||��S)rk)rrPrlr7r8rhsz*assert_array_almost_equal.<locals>.comparermrcNrirnr7rlr8r�s�rcCsttj||||dd�dS)z7
    Checks that x is smaller than y elementwise.

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

    rON)r
rr)�m1�m2rEr7r7r8rs
r)Trr )r9T)r>)r>)r>)r`r>T)r>Tr>T)r>T)r>T)r9r>T)r9r>T)r>T)r>)*�__doc__rI�numpyr'rrZnumpy.core.umath�corer+Z
numpy.testingrrrrrr
rrr
rrZ
__all__maskedZunittestrZ__some__from_testing�__all__rrrGrrr_rrrrrrrrrrr7r7r7r8�<module>s: 



'

�