bg' dZddlZddlZddlmZmZddlmcmZddl Zddl m Z m Z m Z m Z mZddlmZmZmZmZmZmZgdZddlmZgd ZeezZdd ZddZd dZdZd dZd dZeZ d!dZ!e!Z" d"dZ#d#dZ$d#dZ%d$dZ&d$dZ'd#dZ(d dZ)dS)%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 $ N)ndarrayfloat_)assert_assert_allcloseassert_array_almost_equal_nulp assert_raises build_err_msg)mask_orgetmask masked_arraynomaskmaskedfilled)almostapproxassert_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_equal)TestCase)rrrrrTh㈵>:0yE>ctt|t|}t|}t|}|jjdks|jjdkr't j||Stt|d|| t}tt|d|d t} t j tj || z ||tj | zz} | 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. OFcopymaskr )r r rdtypecharnpequalravelr astyper less_equalumathabsolute) ab fill_valuertolatolmd1d2xyds e/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib64/python3.11/site-packages/numpy/ma/testutils.pyrr)s   GAJJ''A B B x}rx}33xB%%'''|BU333Z@@GGOOA|BU333Q77>>vFFA enQU++TD5>!;L;L4L-LMMA 7799ctt|t|}t|}t|}|jjdks|jjdkr't j||Stt|d|| t}tt|d|d t}t j t j ||z |d| zk} | 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 r rr'r(r)r*r+r r,raroundabs) r0r1decimalr2r5r6r7r8r9r:s r;rr?s  GAJJ''A B B x}rx}33xB%%'''|BU333Z@@GGOOA|BU333Q77>>vFFA "&Q--))Twh-??A 7799r<c tt|t||tt|D]%}t||||d|d|&dS)z; Asserts the equality of two non-array sequences. item= N)rlenrange)actualdesirederr_msgks r;_assert_equal_on_sequencesrMRst Vc'llG444 3w<< FFVAY ,DA,D,D7,D,DEEEE Fr<c<t|j|j|jjD]t}tj||tj||}}|t ur?|t ur6ttj||tj||udS)zI Asserts that two records are equal. Pretty crude for now. N)rr'namesoperatorgetitemr)r0r1fafbfs r;rr]s!'""" W]II$Q**H,t|ts)t||g|}||kst|dS|tur |tus|tur-|tur$t||g|dd}t|tj|}tj|}|j|j}}|jd krA|jd kr6t||dSt)|||S) z, Asserts that two items are equal. z not in key=rFNrCrKr8r9)headerrOS) isinstancedictAssertionErrorreprtyperrGitemslisttuplerMrr r ValueErrorr) asanyarrayr'r(tolistr)rIrJrKrLimsg actual_dtype desired_dtypes r;rrlsT '4  &$'' 5 d6ll!3!344 4S[[#g,,888MMOO I IDAq$%;%;6%;%;<<< GAJ0Gq0G0Gg0G0G H H H H'D%=))Gj$.O.OG)&'2FFFF vw ' ':gw+G+GVW-w88&   %% % 6  Gv$5$5&F*:*:VW-#BjBBBoo ]6 " "FmG$$G%+\7==\CM$6#$=$=)&--//*1..*:*:24666 6 fgw 7 77r<c t|trt|ts)ttt |t t |t |||D]H\}}||vrtt|t ||||d|d|IdSt|ttfrt|ttfrot t |t ||tt |D]%}t ||||d|d|&dSt|tj st|tj rt|||St||g|}||kst|dS)z< Raises an assertion error if two items are equal. rVrFNrE)r[r\r]r^r_ fail_if_equalrGr`rarbrHr)rrr )rIrJrKrLrfrgs r;rkrks '4  &$'' 5 d6ll!3!344 4c&kk3w<<999MMOO J JDAq$T!WW--- &)WQZ1H1H1Hw1H1H I I I I'D%=))j$.O.Oc&kk3w<<999s7||$$ K KA &)WQZ1I1I1I1I1I J J J J&"*%%=GRZ)H)H="67G<<< )7 3 3C f  S!!!  r<c$t|tjst|tjrt|||||St ||g||}t t ||z |dkst|dS)z~ Asserts that two items are almost equal. The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal). )rBrKverbose)rKrnrN)r[r)rrr roundrAr])rIrJrBrKrnrgs r;rrs&"*%%KGRZ)H)HK('18'KKK K ) ' : : :C Wv%&& 0 0A 5 5S!!! 6 5r<ctt|t|}t|d|dd}t|d|dd}|tur |tus|tur.|tur%t ||g|||d}t |t j|| || ||||S)zn Asserts that comparison between two masked arrays is satisfied. The comparison is elementwise. F)r%r& keep_masksubokrX)rKrnrYrOrKrnrY) r r r rr rcr)testingrr) comparisonr8r9rKrnrYr2r5rgs r;rrs  GAJJ''AQUe5IIIAQUe5IIIA fqF{{6kkAKKQFGW#)===oo : * *:+,88J+?+?+,88J+?+?3:3:6 + K KKr<cDttj||||ddS)z@ Checks the elementwise equality of two masked arrays. Arrays are not equalrsN)rrP__eq__r8r9rKrns r;rrs5 !Q!(' 6888888r<c6d}t|||||ddS)zT Raises an assertion error if two masked arrays are not equal elementwise. cHtjt|| S)N)r)allrrXs r;comparez$fail_if_array_equal..comparesF6!Q<<((()r<rwrsNr)r8r9rKrnr}s r;rrs? ***!Q 6888888r<c<fd}t|||||ddS)| Checks the equality of two masked arrays, up to given number odecimals. The equality is checked elementwise. c0t||d zS).comparesa1111r<Arrays are not almost equalrsNr~r8r9rBrKrnr}s ` r;rrsL22222!Q =??????r<c<fd}t|||||ddS)rc&t||S)r)rrs r;r}z*assert_array_almost_equal..comparesaG$$$r<rrsNr~rs ` r;rrsL%%%%%!Q =??????r<cDttj||||ddS)z7 Checks that x is smaller than y elementwise. zArrays are not less-orderedrsN)rrP__lt__rys r;rr s5 !Q!(' =??????r<c|turt|tu|turt|tut|||dS)z- Asserts the equality of two masks. rWN)rrr)m1m2rKs r;rrsU  V||f  V||f r2w//////r<)Tr r!)r=T)rC)rlrCT)rCTrCT)rCT)r=rCT)*__doc__rPnumpyr)rrnumpy.core.umathcorer. numpy.testingrrrrr r r r rrr __all__maskedunittestr__some__from_testing__all__rrrMrrrkrrrrrrrrrrr<r;rs]!!!!!!!! IHHHHHHHHHHHHHHH  . .,&        $8$8$8$8N""""4! " " " " # MO$(KKKK288888888 ? ? ? ? ? ? ? ????? 0 0 0 0 0 0r<