e ddlmZddlmZddlmZmZmZddlm Z ddl m Z ddl m Z dZdZd ZeeefZd ed efd ZGd de eZed eded e efdZed eded e efdZdZy))Decimal)fabs)AnyUnionoverload) BaseMatcher) Description)MatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txtvaluereturnct|tttfry t |dzdz dz}y#t $rYyt $rYywxYw)zFConfirm that 'value' can be treated numerically; duck-test accordinglyTrF) isinstancefloatcomplexintrArithmeticError Exception)r _s C/usr/lib/python3/dist-packages/hamcrest/library/number/iscloseto.py isnumericrsR%%#./ %[1_q A %  s3 A A A cpeZdZdededdfdZdedefdZdedefdZded e ddffd Z d e ddfd Z xZ S) IsCloseTor deltar Ncxt|s tdt|s td||_||_y)NzIsCloseTo value must be numericzIsCloseTo delta must be numeric)r TypeErrorr r)selfr rs r__init__zIsCloseTo.__init__s8=> >=> >  itemcVt|sy|j||jkS)NF)r_diffrrr s r_matcheszIsCloseTo._matches(s$zz$4::--rc2t||jz SN)rr r#s rr"zIsCloseTo._diff-sD4::%&&rmismatch_descriptionct|stt|||y|j |}|j |j dj |y)Nz differed by )rsuperrdescribe_mismatchr"append_description_of append_text)rr r' actual_delta __class__s rr*zIsCloseTo.describe_mismatch1sQ )T 4T;O P::d+L 6 6t < H H ##L1r descriptionc|jdj|jjdj|jy)Nza numeric value within z of )r,r+rr )rr/s r describe_tozIsCloseTo.describe_to:s< 9:PP JJ +f 33DJJ?r) __name__ __module__ __qualname__Numberrboolr$rr"r r*r1 __classcell__)r.s@rrrstfV.V.. '&'U'2f2K2TX2@{@t@rrrcyr&r rs rclose_tor;@rcyr&r9r:s rr;r;Er<rct||S)aMatches if object is a number close to a given value, within a given delta. :param value: The value to compare against as the expected value. :param delta: The maximum delta between the values for which the numbers are considered close. This matcher compares the evaluated object against ``value`` to see if the difference is within a positive ``delta``. Example:: close_to(3.0, 0.25) )rr:s rr;r;Js UE ""rN)decimalrmathrtypingrrrhamcrest.core.base_matcherrhamcrest.core.descriptionr hamcrest.core.matcherr __author__ __copyright__ __license__rr5r6rrr;r9rrrHs''21)  - $ ug~  S T @ F#@D E%GEN  GG0@ #r