a
    P^N`¶
  ã                   @   sÌ   d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZ dZdZd	Zeeef Zeed
œdd„ZG dd„ de	e ƒZeeeee dœdd„ƒZeeeee dœdd„ƒZdd„ ZdS )é    )ÚDecimal)Úfabs)ÚAnyÚUnionÚoverload)ÚBaseMatcher)ÚDescription)ÚMatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txt)ÚvalueÚreturnc                 C   sT   t | tttfƒrdS zt| ƒd d d }W dS  tyB   Y dS    Y dS 0 dS )zKConfirm that 'value' can be treated numerically; duck-test accordingly
    Tr   é   FN)Ú
isinstanceÚfloatÚcomplexÚintr   ÚArithmeticError)r
   Ú_© r   ú@lib/python3.9/site-packages/hamcrest/library/number/iscloseto.pyÚ	isnumeric   s    r   c                       sh   e Zd Zeeddœdd„Zeedœdd„Zeedœdd	„Zee	dd
œ‡ fdd„Z
e	ddœdd„Z‡  ZS )Ú	IsCloseToN©r
   Údeltar   c                 C   s0   t |ƒstdƒ‚t |ƒs tdƒ‚|| _|| _d S )NzIsCloseTo value must be numericzIsCloseTo delta must be numeric)r   Ú	TypeErrorr
   r   )Úselfr
   r   r   r   r   Ú__init__    s    zIsCloseTo.__init__)Úitemr   c                 C   s   t |ƒsdS |  |¡| jkS )NF)r   Ú_diffr   ©r   r   r   r   r   Ú_matches)   s    zIsCloseTo._matchesc                 C   s   t || j ƒS ©N)r   r
   r   r   r   r   r   .   s    zIsCloseTo._diff)r   Úmismatch_descriptionr   c                    s@   t |ƒstt| ƒ ||¡ n |  |¡}| |¡ d¡ |¡ d S )Nz differed by )r   Úsuperr   Údescribe_mismatchr   Úappend_description_ofÚappend_text)r   r   r!   Zactual_delta©Ú	__class__r   r   r#   2   s    

ÿþzIsCloseTo.describe_mismatch)Údescriptionr   c                 C   s$   |  d¡ | j¡  d¡ | j¡ d S )Nza numeric value within z of )r%   r$   r   r
   )r   r(   r   r   r   Údescribe_to;   s    
ÿþþzIsCloseTo.describe_to)Ú__name__Ú
__module__Ú__qualname__ÚNumberr   Úboolr   r   r   r   r#   r)   Ú__classcell__r   r   r&   r   r      s
   		r   r   c                 C   s   d S r    r   ©r
   r   r   r   r   Úclose_toA   s    r1   c                 C   s   d S r    r   r0   r   r   r   r1   F   s    c                 C   s
   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)

    )r   r0   r   r   r   r1   K   s    N)Údecimalr   Zmathr   Útypingr   r   r   Zhamcrest.core.base_matcherr   Zhamcrest.core.descriptionr   Zhamcrest.core.matcherr	   Ú
__author__Z__copyright__Z__license__r   r-   r.   r   r   r1   r   r   r   r   Ú<module>   s    "