Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/numpy/ma/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/numpy/ma/__pycache__/testutils.cpython-35.pyc



(��^�(�@s4dZddlmZmZmZddlZddlZddlmZm	Z	ddl
jjZddl
mZmZmZmZmZmZmZddljjZddlmZmZmZmZmZmZdd	d
ddd
ddddddddgZddddddgZeeZ ddddd	�Z!d dd!d�Z"d"d#d$�Z#d%d�Z$d"d&d�Z%d"d'd(�Z&e&Z'd)d"dd*d
�Z(e(Z)d"dd"dd+d
�Z*d"dd,d�Z+d"dd-d�Z,d d"dd.d�Z-d d"dd/d�Z.d"dd0d�Z/d"d1d�Z0dS)2z�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 $

�)�division�absolute_import�print_functionN)�ndarray�float_)�TestCase�assert_�assert_allclose�assert_array_almost_equal_nulp�
assert_raises�
build_err_msg�run_module_suite�)�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_equalrrr	r
rr
Tg�h㈵��>g:�0�yE>cCs�tt|�t|��}t|�}t|�}|jjdksW|jjdkrmtj||�j�Stt|ddd|�|�j	t
�}tt|ddd|�d�j	t
�}	tjtj
||	�||tj
|	��}
|
j�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.

    �O�copyF�maskr)rrr�dtype�char�np�equal�ravelr�astyper�
less_equal�umath�absolute)�a�b�
fill_value�rtolZatol�m�d1�d2�x�y�d�r9�E/opt/alt/python35/lib64/python3.5/site-packages/numpy/ma/testutils.pyr*s$**0�c
Cs�tt|�t|��}t|�}t|�}|jjdksW|jjdkrmtj||�j�Stt|ddd|�|�j	t
�}tt|ddd|�d�j	t
�}tjtj||�|�d|k}	|	j�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#r$Fr%rg$@)
rrrr&r'r(r)r*rr+rZaround�abs)
r/r0�decimalr1r3r4r5r6r7r8r9r9r:r@s$***�cCs_tt|�t|�|�x<tt|��D](}t||||d||f�q/WdS)z;
    Asserts the equality of two non-array sequences.

    z
item=%r
%sN)r�len�range)�actual�desired�err_msg�kr9r9r:�_assert_equal_on_sequencesSs&rEcCs�t|j|j�xv|jjD]h}tj||�tj||�}}|tk	r |tk	r ttj||�tj||��q WdS)zI
    Asserts that two records are equal.

    Pretty crude for now.

    N)rr&�names�operator�getitemr)r/r0�f�afZbfr9r9r:r^s%)cCs6t|t�r�t|t�s6ttt|����tt|�t|�|�x^|j�D]P\}}||kr�td||f��t||||d||f�q_WdSt|tt	f�r�t|tt	f�r�t
||dd�St|t�pt|t�sCt||g|�}||ks?t|��dS|t
kr[|t
k	ss|t
kr�|t
k	r�t||g|dddd�}t|��tj|d
ddd
�}tj|d
ddd
�}|j|j}}|jdkr&|jdkr&t
|j�|j�dd�St|||�S)z,
    Asserts that two items are equal.

    z%s not in %sz	key=%r
%sNrCr>�headerrFr6r7r$F�subokT�S)r6r7)�
isinstance�dict�AssertionError�repr�typerr?�items�list�tuplerErrr�
ValueErrorr(�arrayr&r'�tolistr)rArBrCrD�i�msgZactual_dtypeZ
desired_dtyper9r9r:rms:&*cCs�t|t�r�t|t�s6ttt|����tt|�t|�|�xZ|j�D]L\}}||kr�tt|���t||||d||f�q_WdSt|tt	f�r<t|tt	f�r<tt|�t|�|�x<t
t|��D](}t||||d||f�qWdSt|tj�s`t|tj�rpt
|||�St||g|�}||ks�t|��dS)z<
    Raises an assertion error if two items are equal.

    z	key=%r
%sNz
item=%r
%s)rNrOrPrQrR�
fail_if_equalr?rSrTrUr@r(rr"r)rArBrCrDrYrZr9r9r:r[�s&&*&$r[�c	Cs�t|tj�s$t|tj�rCt||d|d|d|�St||gd|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=rC�verboserN)rNr(rrr�roundr<rP)rArBr=rCr]rZr9r9r:r�s$
c	Cstt|�t|��}t|ddd|dddd�}t|ddd|dddd�}|tkr{|tk	s�|tkr�|tk	r�t||gd|d|d|d	d�}t|��tj||j|�|j|�d|d|d|�S)
zn
    Asserts that comparison between two masked arrays is satisfied.

    The comparison is elementwise.

    r$Fr%Z	keep_maskrLrCr]rKrFr6r7)r6r7)	rrrrrrV�utilsrr)	Z
comparisonr6r7rCr]rKr1r3rZr9r9r:r�s	$$	c
Cs)ttj||d|d|dd�dS)z@
    Checks the elementwise equality of two masked arrays.

    rCr]rKzArrays are not equalN)rrG�__eq__)r6r7rCr]r9r9r:r�sc
Cs2dd�}t|||d|d|dd�dS)zT
    Raises an assertion error if two masked arrays are not equal elementwise.

    cSstjt||��S)N)r(Zalltruer)r6r7r9r9r:�compare�sz$fail_if_array_equal.<locals>.comparerCr]rKzArrays are not equalN)r)r6r7rCr]rar9r9r:r"�sc
s8�fdd�}t|||d|d|dd�dS)z|
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    cst||dd��S)z<Returns the result of the loose comparison between x and y).r2g$@)r)r6r7)r=r9r:ra�sz*assert_array_approx_equal.<locals>.comparerCr]rKzArrays are not almost equalN)r)r6r7r=rCr]rar9)r=r:r�sc
s8�fdd�}t|||d|d|dd�dS)z|
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    cst||��S)z<Returns the result of the loose comparison between x and y).)r)r6r7)r=r9r:rasz*assert_array_almost_equal.<locals>.comparerCr]rKzArrays are not almost equalN)r)r6r7r=rCr]rar9)r=r:rsc
Cs)ttj||d|d|dd�dS)z7
    Checks that x is smaller than y elementwise.

    rCr]rKzArrays are not less-orderedN)rrG�__lt__)r6r7rCr]r9r9r:rscCsO|tkrt|tk�|tkr8t|tk�t||d|�dS)z-
    Asserts the equality of two masks.

    rCN)rrr)�m1�m2rCr9r9r:r s
)1�__doc__�
__future__rrrrG�numpyr(rrZnumpy.core.umath�corer-Z
numpy.testingrrr	r
rrr
Znumpy.testing.utils�testingr_rrrrrrZ
__all__maskedZ__some__from_testing�__all__rrrErrr[r!rrrrr"rrrr r9r9r9r:�<module>sB4.			
'