Current File : //usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyo
�
E�`Qc@s�dZdZdZdZdZddlZddlZddlmZm	Z	ddl
jjZddl
TddljjZdd	lmZmZmZmZmZmZmZmZed
dd�Zd
ed�Zdd�Zd�Zdd�Zdd�ZeZ dded�Z!e!Z"deded�Z#ded�Z$ded�Z%d
ded�Z&d
ded�Z'ded�Z(dd�Z)dS(s�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 $
s5Pierre GF Gerard-Marchant ($Author: jarrod.millman $)s1.0s$Revision: 3529 $s5$Date: 2007-11-13 10:01:14 +0200 (Tue, 13 Nov 2007) $i����N(tndarraytfloat_(t*(tmask_ortgetmasktmasked_arraytnomasktmaskedtfilledtequaltlessg�h㈵��>g:�0�yE>cCs�tt|�t|��}t|�}t|�}|jjdksW|jjdkrmtj||�j�Stt|dt	d|�|�j
t�}tt|dt	d|�d�j
t�}	tjt
j||	�||t
j|	��}
|
j�S(ssReturns true if all components of a and b are equal subject 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.
    tOtcopytmaski(RRRtdtypetchartnpR	travelRtFalsetastypeRt
less_equaltumathtabsolute(tatbt
fill_valuetrtoltatoltmtd1td2txtytd((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pytapproxs	$**0ic
Cs�tt|�t|��}t|�}t|�}|jjdksW|jjdkrmtj||�j�Stt|dt	d|�|�j
t�}tt|dt	d|�d�j
t�}tjtj
||�|�d|k}	|	j�S(s�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.
    RRR
ig$@(RRRRRRR	RRRRRtaroundtabs(
RRtdecimalRRRRRR R!((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pytalmost-s$***tcCs_tt|�t|�|�x<tt|��D](}t||||d||f�q/WdS(s0Asserts the equality of two non-array sequences.s
item=%r
%sN(tassert_equaltlentrange(tactualtdesiredterr_msgtk((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyt_assert_equal_on_sequences>s&cCs�t|j|j�xy|jjD]k}tj||�tj||�}}|tk	r |tk	r ttj||�tj||��q q WdS(s9Asserts that two records are equal. Pretty crude for now.N(R(RtnamestoperatortgetitemR(RRtftaftbf((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pytassert_equal_recordsEs%,c
CsBt|t�r�t|t�s9ttt|����ntt|�t|�|�xa|j�D]S\}}||kr�td||f��nt||||d||f�qbWdSt|tt	f�r�t|tt	f�r�t
||dd�St|t�pt|t�sLt||g|�}||ksHt|��ndS|t
krd|t
k	s||t
kr�|t
k	r�t||g|dddd
�}t|��ntj|d
tdt�}tj|d
tdt�}|j|j}}|jdkr2|jdkr2t
|j�|j�dd�St|||�S(s!Asserts that two items are equal.s%s not in %ss	key=%r
%sNR-R'theaderR0RR RtsuboktS(RR (t
isinstancetdicttAssertionErrortreprttypeR(R)titemstlistttupleR/Rt
build_err_msgRt
ValueErrorRtarrayRtTrueRRttolisttassert_array_equal(R+R,R-R.titmsgtactual_dtypet
desired_dtype((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyR(Os:&*	cCs�t|t�r�t|t�s9ttt|����ntt|�t|�|�x]|j�D]O\}}||kr�tt|���nt||||d||f�qbWdSt|tt	f�rBt|tt	f�rBtt|�t|�|�x<t
t|��D](}t||||d||f�qWdSt|tj�sft|tj�rvt
|||�St||g|�}||ks�t|��ndS(s6Raises an assertion error if two items are equal.
    s	key=%r
%sNs
item=%r
%s(R:R;R<R=R>t
fail_if_equalR)R?R@RAR*RRtfail_if_array_equalRB(R+R,R-R.RHRI((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyRL{s&&*&$ic
Cs�t|tj�s$t|tj�rCt||d|d|d|�St||gd|d|�}tt||�|�dks�t|��ndS(svAsserts that two items are almost equal.
    The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal)
    R%R-tverboseiN(R:RRtassert_array_almost_equalRBtroundR$R<(R+R,R%R-RNRI((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pytassert_almost_equal�s$
c	Cstt|�t|��}t|dtd|dtdt�}t|dtd|dtdt�}|tkr{|tk	s�|tkr�|tk	r�t||gd|d|d|dd�}t|��ntj||j	|�|j	|�d|d|d|�S(sZAsserts that a comparison relation between two masked arrays is satisfied
    elementwise.RR
t	keep_maskR8R-RNR7R0RR (RR (
RRRRRRBRCtutilstassert_array_compareR(	t
comparisonRR R-RNR7RRRI((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyRT�s$$	c
Cs)ttj||d|d|dd�dS(s5Checks the elementwise equality of two masked arrays.R-RNR7sArrays are not equalN(RTR1t__eq__(RR R-RN((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyRG�sc
Cs/d�}t|||d|d|dd�dS(sKRaises an assertion error if two masked arrays are not equal (elementwise).cSstjt||��S(N(RtalltrueR"(RR ((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pytcompare�sR-RNR7sArrays are not equalN(RT(RR R-RNRX((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyRM�s	c
s5�fd�}t|||d|d|dd�dS(s[Checks the elementwise equality of two masked arrays, up to a given
    number of decimals.cst||dd��S(s<Returns the result of the loose comparison between x and y).Rg$@(R"(RR (R%(s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyRX�sR-RNR7sArrays are not almost equalN(RT(RR R%R-RNRX((R%s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pytassert_array_approx_equal�sc
s5�fd�}t|||d|d|dd�dS(s[Checks the elementwise equality of two masked arrays, up to a given
    number of decimals.cst||��S(s<Returns the result of the loose comparison between x and y).(R&(RR (R%(s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyRX�sR-RNR7sArrays are not almost equalN(RT(RR R%R-RNRX((R%s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyRO�sc
Cs)ttj||d|d|dd�dS(s,Checks that x is smaller than y elementwise.R-RNR7sArrays are not less-orderedN(RTR1t__lt__(RR R-RN((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pytassert_array_less�scCsU|tkrt|tk�n|tkr>t|tk�nt||d|�dS(s"Asserts the equality of two masks.R-N(Rtassert_RG(tm1tm2R-((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pytassert_mask_equal�s
(*t__doc__t
__author__t__version__t__revision__t__date__R1tnumpyRRRtnumpy.core.umathtcoreRt
numpy.testingtnumpy.testing.utilsttestingRSRRRRRRR	R
RER"R&R/R6R(RLtassert_not_equalRQtassert_closeRTRGRMRYROR[R_(((s8/usr/lib64/python2.7/site-packages/numpy/ma/testutils.pyt<module>s8
:	
,