• File: testutils.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyc
  • Date Modified: 12/19/2017 2:16 PM
  • File size: 10.49 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

9Zc@`s
dZddlmZmZmZddlZddlZddlmZm	Z	ddl
jjZddl
mZmZmZmZmZmZmZddljjZddlmZmZmZmZmZmZdd	d
ddd
ddddddddgZddddddgZeeZ e!dddZ"de!d Z#d!d"Z$d#Z%d!d$Z&d!d%Z'e'Z(d&d!e!d'Z)e)Z*d!e!d!e!d(Z+d!e!d)Z,d!e!d*Z-dd!e!d+Z.dd!e!d,Z/d!e!d-Z0d!d.Z1dS(/sMiscellaneous 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 $

i(tdivisiontabsolute_importtprint_functionN(tndarraytfloat_(tTestCasetassert_tassert_allclosetassert_array_almost_equal_nulpt
assert_raisest
build_err_msgtrun_module_suitei(tmask_ortgetmasktmasked_arraytnomasktmaskedtfilledtalmosttapproxtassert_almost_equaltassert_array_almost_equaltassert_array_approx_equaltassert_array_comparetassert_array_equaltassert_array_lesstassert_closetassert_equaltassert_equal_recordstassert_mask_equaltassert_not_equaltfail_if_array_equalRRRRR	Rgh㈵>g:0yE>cC`stt|t|}t|}t|}|jjdksW|jjdkrmtj||jStt|dt	d||j
t}tt|dt	d|dj
t}	tjt
j||	||t
j|	}
|
jS(s
    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.

    tOtcopytmaski(RR
RtdtypetchartnptequaltravelRtFalsetastypeRt
less_equaltumathtabsolute(tatbt
fill_valuetrtoltatoltmtd1td2txtytd((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyR*s$**0ic
C`stt|t|}t|}t|}|jjdksW|jjdkrmtj||jStt|dt	d||j
t}tt|dt	d|dj
t}tjtj
|||d|k}	|	jS(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.

    R R!R"ig$@(RR
RR#R$R%R&R'RR(R)Rtaroundtabs(
R-R.tdecimalR/R2R3R4R5R6R7((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyR@s$***tcC`s_tt|t||x<tt|D](}t||||d||fq/WdS(s;
    Asserts the equality of two non-array sequences.

    s
item=%r
%sN(Rtlentrange(tactualtdesiredterr_msgtk((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyt_assert_equal_on_sequencesSs&cC`st|j|jxy|jjD]k}tj||tj||}}|tk	r |tk	r ttj||tj||q q WdS(sI
    Asserts that two records are equal.

    Pretty crude for now.

    N(RR#tnamestoperatortgetitemR(R-R.tftaftbf((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyR^s%,cC`sBt|trt|ts9ttt|ntt|t||xa|jD]S\}}||krtd||fnt||||d||fqbWdSt|tt	frt|tt	frt
||ddSt|tpt|tsLt||g|}||ksHt|ndS|t
krd|t
k	s||t
kr|t
k	rt||g|dddd
}t|ntj|d
tdt}tj|d
tdt}|j|j}}|jdkr2|jdkr2t
|j|jddSt|||S(s,
    Asserts that two items are equal.

    s%s not in %ss	key=%r
%sNR@R;theaderRCR5R6R!tsuboktS(R5R6(t
isinstancetdicttAssertionErrortreprttypeRR<titemstlistttupleRBRR
Rt
ValueErrorR%tarrayR(tTrueR#R$ttolistR(R>R?R@RAtitmsgtactual_dtypet
desired_dtype((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRms:&*cC`st|trt|ts9ttt|ntt|t||x]|jD]O\}}||krtt|nt||||d||fqbWdSt|tt	frBt|tt	frBtt|t||x<t
t|D](}t||||d||fqWdSt|tjsft|tjrvt
|||St||g|}||kst|ndS(s<
    Raises an assertion error if two items are equal.

    s	key=%r
%sNs
item=%r
%s(RLRMRNRORPt
fail_if_equalR<RQRRRSR=R%RRR
(R>R?R@RARXRY((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyR\s&&*&$ic	C`st|tjs$t|tjrCt||d|d|d|St||gd|d|}tt|||dkst|ndS(s~
    Asserts that two items are almost equal.

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

    R:R@tverboseiN(RLR%RRR
troundR9RN(R>R?R:R@R]RY((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRs$
c	C`stt|t|}t|dtd|dtdt}t|dtd|dtdt}|tkr{|tk	s|tkr|tk	rt||gd|d|d|dd}t|ntj||j	||j	|d|d|d|S(sn
    Asserts that comparison between two masked arrays is satisfied.

    The comparison is elementwise.

    R!R"t	keep_maskRJR@R]RIRCR5R6(R5R6(
RR
RR(RR
RTtutilsRR(	t
comparisonR5R6R@R]RIR/R2RY((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRs	$$	c
C`s)ttj||d|d|dddS(s@
    Checks the elementwise equality of two masked arrays.

    R@R]RIsArrays are not equalN(RRDt__eq__(R5R6R@R]((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRsc
C`s/d}t|||d|d|dddS(sT
    Raises an assertion error if two masked arrays are not equal elementwise.

    cS`stjt||S(N(R%talltrueR(R5R6((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pytcomparesR@R]RIsArrays are not equalN(R(R5R6R@R]Rd((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRs	c
`s5fd}t|||d|d|dddS(s|
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    c`st||ddS(s<Returns the result of the loose comparison between x and y).R0g$@(R(R5R6(R:(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRdsR@R]RIsArrays are not almost equalN(R(R5R6R:R@R]Rd((R:sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRsc
`s5fd}t|||d|d|dddS(s|
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    c`st||S(s<Returns the result of the loose comparison between x and y).(R(R5R6(R:(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRdsR@R]RIsArrays are not almost equalN(R(R5R6R:R@R]Rd((R:sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRsc
C`s)ttj||d|d|dddS(s7
    Checks that x is smaller than y elementwise.

    R@R]RIsArrays are not less-orderedN(RRDt__lt__(R5R6R@R]((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRscC`sU|tkrt|tkn|tkr>t|tknt||d|dS(s-
    Asserts the equality of two masks.

    R@N(RRR(tm1tm2R@((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyRs
(2t__doc__t
__future__RRRRDtnumpyR%RRtnumpy.core.umathtcoreR+t
numpy.testingRRRRR	R
Rtnumpy.testing.utilsttestingR`RR
RRRRt
__all__maskedt__some__from_testingt__all__RVRRRBRRR\RRRRRRRRRR(((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/testutils.pyt<module>sB4.			
	'