a
    ¬<bé  ã                   @   sÒ   U d Z ddlmZ ddlmZ ddlZddlmZmZm	Z	m
Z
 ddlmZ ddlmZ ee	ee
ee
f  ed< eeeefgZz6dd	lmZmZ e eeed
ƒƒeeed
ƒƒf¡ W n eyÄ   Y n0 dd„ ZdS )z‡
test_pythonmpq.py

Test the PythonMPQ class for consistency with gmpy2's mpq type. If gmpy2 is
installed run the same tests for both.
é    )ÚFraction)ÚDecimalN)ÚCallableÚListÚTupleÚType)Úraises)Ú	PythonMPQÚrational_types)ÚmpqÚmpzé   c                     sx	  t D 	]l\‰ ‰} ‰‡‡fdd„}|ˆ dƒƒdks4J ‚|ˆ ddƒƒdksJJ ‚|ˆ ˆ ddƒƒƒdksdJ ‚|ˆ dƒƒdksxJ ‚|ˆ d	ƒƒdksŒJ ‚|ˆ tddƒƒƒdks¦J ‚ˆ tu rÆ|ˆ td
ƒƒƒdksÆJ ‚tt‡ fdd„ƒ tt‡ fdd„ƒ |ˆ ddƒƒdksJ ‚|ˆ ddƒƒdksJ ‚|ˆ ddƒƒdks2J ‚|ˆ ddƒƒdksJJ ‚|ˆ ddƒƒdksbJ ‚tˆ ddƒƒdkszJ ‚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ksòJ ‚ˆ tu r.t	ˆ ddƒƒdksJ ‚t	ˆ ddƒƒdks^J ‚n0t	ˆ ddƒƒdksFJ ‚t	ˆ ddƒƒd ks^J ‚t
ˆ ddƒƒd!u svJ ‚t
ˆ d"ƒƒd#u sŒJ ‚ˆ ddƒˆ ddƒkd!u sªJ ‚ˆ ddƒˆ ddƒkd#u sÈJ ‚ˆ ddƒˆ ddƒkd#u sæJ ‚ˆ ddƒˆ ddƒkd!u sJ ‚tˆ ddƒƒttddƒƒks&J ‚ˆ ddƒ}t t |¡¡|ksJJ ‚ˆ ddƒˆ ddƒk d!u shJ ‚ˆ ddƒˆ ddƒk d#u s†J ‚ˆ ddƒˆ ddƒk d#u s¤J ‚ˆ ddƒˆ ddƒk d!u sÂJ ‚ˆ ddƒˆ ddƒk d#u sàJ ‚ˆ ddƒˆ ddƒkd!u sþJ ‚ˆ ddƒˆ ddƒkd!u sJ ‚ˆ ddƒˆ ddƒkd#u s:J ‚ˆ ddƒˆ ddƒkd!u sXJ ‚ˆ ddƒˆ ddƒkd#u svJ ‚ˆ ddƒˆ ddƒkd#u s”J ‚ˆ ddƒˆ ddƒkd#u s²J ‚ˆ ddƒˆ ddƒkd!u sÐJ ‚ˆ ddƒˆ ddƒkd#u sîJ ‚ˆ ddƒˆ ddƒkd!u sJ ‚ˆ ddƒˆ ddƒkd#u s*J ‚ˆ ddƒˆ ddƒkd!u sHJ ‚ˆ ddƒˆ ddƒkd!u sfJ ‚ˆ ddƒˆ ddƒkd#u s„J ‚ˆ ddƒˆ ddƒkd!u s¢J ‚tˆ ddƒƒtˆ ddƒƒ  krÔˆ ddƒksÚn J ‚ˆ ddƒ
 ˆ ddƒksöJ ‚ˆ ddƒ ˆ ddƒksJ ‚ˆ ddƒˆ dd$ƒ ˆ d%d&ƒks6J ‚ˆ ddƒd ˆ ddƒksTJ ‚dˆ ddƒ ˆ ddƒksrJ ‚tt‡ fd'd„ƒ tt‡ fd(d„ƒ ˆ ddƒˆ dd$ƒ ˆ dd&ƒksºJ ‚ˆ ddƒd ˆ ddƒksØJ ‚dˆ ddƒ ˆ ddƒksöJ ‚tt‡ fd)d„ƒ tt‡ fd*d„ƒ ˆ ddƒˆ dd$ƒ ˆ d+d&ƒks>J ‚ˆ ddƒd ˆ ddƒks\J ‚dˆ ddƒ ˆ ddƒkszJ ‚tt‡ fd,d„ƒ tt‡ fd-d„ƒ ˆ ddƒd ˆ d.d/ƒks¼J ‚ˆ ddƒd ˆ ddƒksÚJ ‚ˆ ddƒd ˆ d.d/ƒksøJ ‚ˆ ddƒd ˆ ddƒksJ ‚ˆ tu rDtt‡ fd0d„ƒ tt‡ fd1d„ƒ tt‡ fd2d„ƒ tt‡ fd3d„ƒ ˆ ddƒˆ dd$ƒ ˆ d4d5ƒksŒJ ‚ˆ ddƒd ˆ ddƒksªJ ‚dˆ ddƒ ˆ ddƒksÈJ ‚tt‡ fd6d„ƒ tt‡ fd7d„ƒ tt‡ fd8d„ƒ ˆ tu rtt‡ fd9d„ƒ tt‡ fd:d„ƒ tt‡ fd;d„ƒ tt‡ fd<d„ƒ tt‡ fd=d„ƒ tt‡ fd>d„ƒ qd S )?Nc                    s:   t | ˆ ƒsJ ‚t | jˆƒsJ ‚t | jˆƒs.J ‚| j| jfS ©N)Ú
isinstanceÚ	numeratorÚdenominator)Úq)ÚTQÚTZ© ús/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/sympy/external/tests/test_pythonmpq.pyÚcheck_Q#   s    ztest_PythonMPQ.<locals>.check_Qé   )r   r   é   )r   r   g      à?)r   é   z0.5z0.6c                      s   ˆ g ƒS r   r   r   ©ÚQr   r   Ú<lambda>7   ó    z test_PythonMPQ.<locals>.<lambda>c                      s
   ˆ g g ƒS r   r   r   r   r   r   r   8   r   r   )r   r   éþÿÿÿ)r   r   éýÿÿÿé   é   )r   r   r   éûÿÿÿéÿÿÿÿg      @g      ÀÚ2z1/2zMPQ(2,1)zMPQ(1,2)zmpq(2,1)zmpq(1,2)Tr   Fé   é   é   c                      s   g ˆ dƒ S ©Nr   r   r   r   r   r   r   †   r   c                      s   ˆ dƒg  S r)   r   r   r   r   r   r   ‡   r   c                      s   g ˆ dƒ S r)   r   r   r   r   r   r      r   c                      s   ˆ dƒg  S r)   r   r   r   r   r   r   Ž   r   é
   c                      s   g ˆ dƒ S r)   r   r   r   r   r   r   ”   r   c                      s   ˆ dƒg  S r)   r   r   r   r   r   r   •   r   é   é	   c                      s   dˆ ddƒ S )Nr   r   r   r   r   r   r   r   r      r   c                      s   ˆ ddƒˆ ddƒ S )Nr   r+   r   r   r   r   r   r   r   ž   r   c                      s   g ˆ dƒ S r)   r   r   r   r   r   r   Ÿ   r   c                      s   ˆ dƒg  S r)   r   r   r   r   r   r       r   é   é   c                      s   g ˆ dƒ S r)   r   r   r   r   r   r   ¦   r   c                      s   ˆ dƒg  S r)   r   r   r   r   r   r   §   r   c                      s   ˆ ddƒˆ dƒ S )Nr   r   r   r   r   r   r   r   r   ¨   r   c                      s   ˆ ddƒˆ ddƒ S ©Nr   r   r   r   r   r   r   r   r   ¬   r   c                      s   ˆ ddƒˆ ddƒ S r/   r   r   r   r   r   r   ­   r   c                      s   dˆ ddƒ S ©Nr   r   r   r   r   r   r   r   ®   r   c                      s   dˆ ddƒ S r0   r   r   r   r   r   r   ¯   r   c                      s   ˆ ddƒd S r/   r   r   r   r   r   r   °   r   c                      s   ˆ ddƒd S r/   r   r   r   r   r   r   ±   r   )r
   r   r	   r   r   Ú	TypeErrorÚintÚfloatÚstrÚreprÚboolÚhashÚpickleÚloadsÚdumpsÚabsÚZeroDivisionError)ÚZr   r   r   )r   r   r   r   Útest_PythonMPQ   sÂ    
"
8$$$
$r>   )Ú__doc__Z	fractionsr   Údecimalr   r8   Útypingr   r   r   r   Zsympy.testing.pytestr   Zsympy.external.pythonmpqr	   Ú__annotations__r2   r
   Zgmpy2r   r   ÚappendÚtypeÚImportErrorr>   r   r   r   r   Ú<module>   s   &