• File: testutils.cpython-37.opt-1.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/site-packages/numpy/ma/__pycache__/testutils.cpython-37.opt-1.pyc
  • Date Modified: 04/24/2023 7:10 PM
  • File size: 8.15 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

<Fd(@sndZddlmZmZmZddlZddlZddlmZm	Z	ddl
mmZddl
mZmZmZmZmZmZmZddlmmZddlmZmZmZmZmZmZdd	d
ddd
ddddddddgZddddddgZeeZ d2dd	Z!d3d!dZ"d4d#d$Z#d%dZ$d5d&dZ%d6d'd(Z&e&Z'd7d*d
Z(e(Z)d8d+d
Z*d9d,dZ+d:d-dZ,d;d.dZ-d<d/dZ.d=d0dZ/d>d1dZ0dS)?zMiscellaneous 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 $

)divisionabsolute_importprint_functionN)ndarrayfloat_)TestCaseassert_assert_allcloseassert_array_almost_equal_nulp
assert_raises
build_err_msgrun_module_suite)mask_orgetmaskmasked_arraynomaskmaskedfilledalmostapproxassert_almost_equalassert_array_almost_equalassert_array_approx_equalassert_array_compareassert_array_equalassert_array_lessassert_closeassert_equalassert_equal_recordsassert_mask_equalassert_not_equalfail_if_array_equalrrr	r
rr
Th㈵>:0yE>cCstt|t|}t|}t|}|jjdks:|jjdkrJt||Stt|d|d|	t
}tt|d|dd	t
}	tt
||	||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)copymaskr)rrrdtypecharnpequalravelrastyperZ
less_equalumathZabsolute)ab
fill_valuertolZatolmd1d2xydr9E/opt/alt/python37/lib64/python3.7/site-packages/numpy/ma/testutils.pyr*s$c
Cstt|t|}t|}t|}|jjdks:|jjdkrJt||Stt|d|d|	t
}tt|d|dd	t
}tt|||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%F)r&r'rg$@)
rrrr(r)r*r+r,rr-rZaroundabs)
r/r0decimalr1r3r4r5r6r7r8r9r9r:r@s cCsJtt|t||x0tt|D] }t||||d||fq"WdS)z;
    Asserts the equality of two non-array sequences.

    z
item=%r
%sN)rlenrange)actualdesirederr_msgkr9r9r:_assert_equal_on_sequencesSs rEcCsht|j|jxT|jjD]H}t||t||}}|tk	r|tk	rtt||t||qWdS)zI
    Asserts that two records are equal.

    Pretty crude for now.

    N)rr(namesoperatorgetitemr)r/r0fZafZbfr9r9r:r^scCst|trt|ts$ttt|tt|t||xH|D]<\}}||krbtd||ft||||d||fqBWdSt|tt	frt|tt	frt
||ddSt|tst|tst||g|}||kst|dS|t
kr|t
k	s|t
kr(|t
k	r(t||g|ddd}t|tj|dd	d
}tj|dd	d
}|j|j}}|jdkr|jdkrt
||ddSt|||S)z,
    Asserts that two items are equal.

    z%s not in %sz	key=%r
%sNr>)rC)r6r7)headerrFFT)r&subokS)
isinstancedictAssertionErrorreprtyperr?itemslisttuplerErrr
ValueErrorr*Zarrayr(r)tolistr)rArBrCrDimsgZactual_dtypeZ
desired_dtyper9r9r:rms:

 cCs4t|trt|ts$ttt|tt|t||xD|D]8\}}||kr^tt|t||||d||fqBWdSt|tt	frt|tt	frtt|t||x0t
t|D] }t||||d||fqWdSt|tjst|tjrt
|||St||g|}||ks0t|dS)z<
    Raises an assertion error if two items are equal.

    z	key=%r
%sNz
item=%r
%s)rMrNrOrPrQ
fail_if_equalr?rRrSrTr@r*rr"r)rArBrCrDrWrXr9r9r:rYs&

  
rYcCs^t|tjst|tjr*t|||||dSt||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=rCverbose)rCr[rN)rMr*rrrroundr<rO)rArBr=rCr[rXr9r9r:rs

c	Cstt|t|}t|d|ddd}t|d|ddd}|tkrF|tk	sV|tkrt|tk	rtt||g|||dd}t|tj||||||||dS)zn
    Asserts that comparison between two masked arrays is satisfied.

    The comparison is elementwise.

    F)r&r'Z	keep_maskrK)r6r7)rCr[rJrF)rCr[rJ)	rrrrrrUutilsrr)	Z
comparisonr6r7rCr[rJr1r3rXr9r9r:rs	
cCsttj||||dddS)z@
    Checks the elementwise equality of two masked arrays.

    zArrays are not equal)rCr[rJN)rrG__eq__)r6r7rCr[r9r9r:rs
cCs dd}t|||||dddS)zT
    Raises an assertion error if two masked arrays are not equal elementwise.

    cSstt||S)N)r*Zalltruer)r6r7r9r9r:comparesz$fail_if_array_equal.<locals>.comparezArrays are not equal)rCr[rJN)r)r6r7rCr[r_r9r9r:r"scs$fdd}t|||||dddS)z|
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    cst||ddS)z<Returns the result of the loose comparison between x and y).g$@)r2)r)r6r7)r=r9r:r_sz*assert_array_approx_equal.<locals>.comparezArrays are not almost equal)rCr[rJN)r)r6r7r=rCr[r_r9)r=r:rscs$fdd}t|||||dddS)z|
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    cst||S)z<Returns the result of the loose comparison between x and y).)r)r6r7)r=r9r:r_sz*assert_array_almost_equal.<locals>.comparezArrays are not almost equal)rCr[rJN)r)r6r7r=rCr[r_r9)r=r:rscCsttj||||dddS)z7
    Checks that x is smaller than y elementwise.

    zArrays are not less-ordered)rCr[rJN)rrG__lt__)r6r7rCr[r9r9r:rs
cCs:|tkrt|tk|tkr(t|tkt|||ddS)z-
    Asserts the equality of two masks.

    )rCN)rrr)Zm1Zm2rCr9r9r:r s
)Tr#r$)r;T)r>)r>)r>)rZr>T)r>Tr>T)r>T)r>T)r;r>T)r;r>T)r>T)r>)1__doc__Z
__future__rrrrGZnumpyr*rrZnumpy.core.umathZcorer.Z
numpy.testingrrr	r
rrr
Znumpy.testing.utilsZtestingr]rrrrrrZ
__all__maskedZ__some__from_testing__all__rrrErrrYr!rrrrr"rrrr r9r9r9r:<module>sB$ 




'