HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/hamcrest/library/number/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/hamcrest/library/number/__pycache__/iscloseto.cpython-312.pyc
�

���e�
����ddlmZddlmZddlmZmZmZddlm	Z	ddl
mZddlm
Z
dZdZd	ZeeefZd
edefd�ZGd
�de	e�Zed
edede
efd��Zed
edede
efd��Zd�Zy)�)�Decimal)�fabs)�Any�Union�overload)�BaseMatcher)�Description)�MatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txt�value�returnc��t|tttf�ry	t	|�dzdz
dz}y#t
$rYyt$rYywxYw)zFConfirm that 'value' can be treated numerically; duck-test accordinglyTr�F)�
isinstance�float�complex�intr�ArithmeticError�	Exception)r�_s  �C/usr/lib/python3/dist-packages/hamcrest/library/number/iscloseto.py�	isnumericrsR���%�%��#�.�/���
�%�[�1�_�q�
 �A�%�����������s�3�	A	�A	�A	c�p��eZdZdededdfd�Zdedefd�Zdedefd�Zded	e	ddf�fd
�Z
de	ddfd�Z�xZS)
�	IsCloseTor�deltarNc�x�t|�std��t|�std��||_||_y)NzIsCloseTo value must be numericzIsCloseTo delta must be numeric)r�	TypeErrorrr)�selfrrs   r�__init__zIsCloseTo.__init__s8������=�>�>�����=�>�>���
���
��itemc�V�t|�sy|j|�|jkS)NF)r�_diffr�rr s  r�_matcheszIsCloseTo._matches(s$�������z�z�$��4�:�:�-�-rc�2�t||jz
�S�N)rrr#s  rr"zIsCloseTo._diff-s���D�4�:�:�%�&�&r�mismatch_descriptionc����t|�stt|�||�y|j	|�}|j|�j
d�j|�y)Nz
 differed by )r�superr�describe_mismatchr"�append_description_of�append_text)rr r'�actual_delta�	__class__s    �rr*zIsCloseTo.describe_mismatch1sQ�������)�T�4�T�;O�P��:�:�d�+�L� �6�6�t�<�H�H��
�#�#�L�1r�descriptionc��|jd�j|j�jd�j|j�y)Nza numeric value within z of )r,r+rr)rr/s  r�describe_tozIsCloseTo.describe_to:s<����� 9�:�P�P��J�J�	
�
�+�f�
�3�3�D�J�J�?r)
�__name__�
__module__�__qualname__�Numberr�boolr$rr"r	r*r1�
__classcell__)r.s@rrrst����f��V����.�V�.��.�
'�&�'�U�'�2�f�2�K�2�TX�2�@�{�@�t�@rrrc��yr&��rrs  r�close_tor;@���rc��yr&r9r:s  rr;r;Er<rc��t||�S)a�Matches 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�� �U�E�"�"rN)�decimalr�mathr�typingrrr�hamcrest.core.base_matcherr�hamcrest.core.descriptionr	�hamcrest.core.matcherr
�
__author__�
__copyright__�__license__rr5r6rrr;r9rr�<module>rHs�����'�'�2�1�)�
�
�-�
�$��	�u�g�~�	���S��T��@��F�#�@�D
��E��%��G�E�N��
��
��G��G����0@��
��#r