o
    lhk                     @   s4   d dl T d dlT d dlZdd Zdd Zdd ZdS )	    )*Nc                   C   s   dt _tdd dksJ tdd dksJ tdd d	ks!J tdd
 dks+J tdd ds6J tdd dsAJ tdd dsLJ tdd
 dsWJ tdd dsbJ tdd dsmJ d S )N      g      @i   @   g      ?   g      g      ?g      g      P?
   gR[:XL	@gXs@gIHb=?g3i?g333333?g[-?g333333ӿgRB3Ϲ	?)mpdpsmpfae r   r   k/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/mpmath/tests/test_power.pytest_fractional_pow   s   r   c                  C   s   t d dD ]A} tdD ]:}t d| d > d| > }t dd}|| }ttt|t|| t|k s6J ttt|t|| t|ksGJ qqdS )zR
    Test that inexact integer powers are rounded in the right
    direction.
    i  )r   5      2         d   N)	randomseedrangerandintto_intmpf_powfrom_int
round_downround_up)preciababr   r   r   test_pow_integer_direction   s   
"$r#   c                  C   s  dd } dD ]\}}|t _tdtd| d   }tdtd| d   }| }| }|t _t}| |d|dks=J | |d|dksGJ | |d|dk sQJ | |d|dks[J | |d|dkseJ | |d|dksoJ | |d|dksyJ | |d|dksJ | |d	|dksJ | |d	|dksJ | |d	|dksJ | |d	|dk sJ | |d
|dksJ | |d
|dksJ | |d
|dksJ | |d
|dksJ t}| |d|dksJ | |d|dk sJ | |d|dksJ | |d|dksJ | |d|dksJ | |d|dk sJ | |d|dksJ | |d|dk s)J | |d	|dk s4J | |d	|dks?J | |d	|dksJJ | |d	|dksUJ | |d
|dk s`J | |d
|dkskJ | |d
|dk svJ | |d
|dksJ t}| |d|dksJ | |d|dksJ | |d|dksJ | |d|dksJ | |d|dksJ | |d|dksJ | |d|dksJ | |d|dksJ | |d	|dksJ | |d	|dksJ | |d	|dksJ | |d	|dksJ | |d
|dksJ | |d
|dksJ | |d
|dks(J | |d
|dks3J t}| |d|dks@J | |d|dk sKJ | |d|dk sVJ | |d|dksaJ | |d|dkslJ | |d|dk swJ | |d|dksJ | |d|dk sJ | |d	|dk sJ | |d	|dksJ | |d	|dksJ | |d	|dk sJ | |d
|dk sJ | |d
|dksJ | |d
|dk sJ | |d
|dksJ qdt _dS )a  
    Stress test directed rounding for powers with integer exponents.
    Basically, we look at the following cases:

    >>> 1.0001 ** -5 # doctest: +SKIP
    0.99950014996500702
    >>> 0.9999 ** -5 # doctest: +SKIP
    1.000500150035007
    >>> (-1.0001) ** -5 # doctest: +SKIP
    -0.99950014996500702
    >>> (-0.9999) ** -5 # doctest: +SKIP
    -1.000500150035007

    >>> 1.0001 ** -6 # doctest: +SKIP
    0.99940020994401269
    >>> 0.9999 ** -6 # doctest: +SKIP
    1.0006002100560125
    >>> (-1.0001) ** -6 # doctest: +SKIP
    0.99940020994401269
    >>> (-0.9999) ** -6 # doctest: +SKIP
    1.0006002100560125

    etc.

    We run the tests with values a very small epsilon away from 1:
    small enough that the result is indistinguishable from 1 when
    rounded to nearest at the output precision. We check that the
    result is not erroneously rounded to 1 in cases where the
    rounding should be done strictly away from 1.
    c                 S   s   t t| j|tj|S )N)make_mpfmpf_pow_int_mpf_r   r   )xnrr   r   r   powrC   s   z'test_pow_epsilon_rounding.<locals>.powr))r      )i  i  r   r         ir   N)r   r   r
   r   r   round_ceilinground_floorr	   )r*   inprecoutprecpos10001pos09999neg10001neg09999r)   r   r   r   test_pow_epsilon_rounding#   s    
r8   )mpmathmpmath.libmpr   r   r#   r8   r   r   r   r   <module>   s    