
    ;e                         d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dlm	Z	m
Z
mZ d dlZ ed          Z ed          ZdZ G d	 d
e j                  Zedk    r e j                     dS dS )    N)support)VALID_UNDERSCORE_LITERALSINVALID_UNDERSCORE_LITERALS)random)atan2isnancopysigninfnan))      ?      ?                )r           )r   r   )      ?r   )   r   c                   z   e Zd Zd Zd%dZd Zd%dZd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zej        d             Zd Zd Zd Zd Zej        d             Zd Z d Z!ej        d             Z"ej        d              Z#ej        d!             Z$ej        d"             Z%d# Z&d$S )&ComplexTestc                    t          |t                    rt          |t                    rXt          j                            | |j        |j                   t          j                            | |j        |j                   d S t          j                            | |j        |           t          j                            | |j        d           d S t          |t                    rNt          j                            | ||j                   t          j                            | d|j                   d S t          j                            | ||           d S )Nr   )
isinstancecomplexunittestTestCaseassertAlmostEqualrealimagselfabs      (/usr/lib/python3.11/test/test_complex.pyr   zComplexTest.assertAlmostEqual   s    a!! 	@!W%% F!33D!&!&III!33D!&!&IIIII!33D!&!DDD!33D!&"EEEEE!W%% @!33D!QVDDD!33D"afEEEEE!33D!Q?????    &.>c                 
   t          |          t          |          k    r||}}|dk    rt          |          |k     S |dk    rt          |          |k     S |                     t          ||z
  |z            |k                dS )z+Return true iff floats x and y "are close".r   N)abs
assertTruer   xyepss       r   assertCloseAbszComplexTest.assertCloseAbs(   s     q66CFF??aqA66q66C<66q66C<QqS!Gs*+++++r    c                 H   d}t          |          st          |          r!t          |          rt          |          rdS n7||k    r1|dk    rdS t          d|          t          d|          k    rdS |dz  }|                     |                    ||                     dS )a#  assert that floats x and y are identical, in the sense that:
        (1) both x and y are nans, or
        (2) both x and y are infinities, with the same sign, or
        (3) both x and y are zeros, with the same sign, or
        (4) x and y are both finite and nonzero, and x == y

        z&floats {!r} and {!r} are not identicalNr   r   z: zeros have different signs)r   r	   failformat)r   r&   r'   msgs       r   assertFloatsAreIdenticalz$ComplexTest.assertFloatsAreIdentical4   s     788 
	6uQxx 
	6Qxx E!HH !VVCxx#q!!Xc1%5%55555		#**Q""#####r    c                     |                      |j        |j        |           |                      |j        |j        |           dS )z.Return true iff complexes x and y "are close".N)r)   r   r   r%   s       r   assertClosezComplexTest.assertCloseK   s@    AFAFC000AFAFC00000r    c                 D   ||z  }|dk    rF||z  }|                      ||           |                    |          }|                      ||           |dk    rH||z  }|                      ||           |                    |          }|                      ||           dS dS )z8Compute complex z=x*y, and check that z/x==y and z/y==x.r   N)r0   __truediv__)r   r&   r'   zqs        r   	check_divzComplexTest.check_divP   s    E66AAQ"""a  AQ"""66AAQ"""a  AQ"""""	 6r    c           	         d t          dd          D             fdD             }|D ]}|D ]}|                     ||           |                     t          dd          d           |                     t          dd          d           t          d          D ]d}|                     t          t                      t                                t          t                      t                                           e|                     t                              d	d
          d           dt          ft          dft          t          ffD ]t\  }}t          dd          t          ||          z  }|                     t          |j	                             |                     t          |j
                             ud S )Nc                 ,    g | ]}t          |          S  )float).0is     r   
<listcomp>z,ComplexTest.test_truediv.<locals>.<listcomp>_   s    666AuQxx666r       c                 :    g | ]}D ]}t          ||          S r8   )r   )r:   r&   r'   simple_reals      r   r<   z,ComplexTest.test_truediv.<locals>.<listcomp>`   s.    RRRAkRR'!Q--RRRRr    gZbti      ?        N~hd          @        r   y      ?      r   )ranger5   r   r   r   r2   NANr$   r   r   r   )	r   simple_complexr&   r'   r;   
denom_real
denom_imagr3   r@   s	           @r   test_truedivzComplexTest.test_truediv^   s   66r1666RRRRRRR 	% 	%A# % %q!$$$$%
 	wue,,d333wvv..555 s 	8 	8ANN7688VXX66"688VXX668 8 8 8 	w224>>EEE()3x#qC:&F 	+ 	+"J
1
J ? ??AOOE!&MM***OOE!&MM****	+ 	+r    c                     t           D ]<\  }}|                     t                    5  ||z   d d d            n# 1 swxY w Y   =d S N)ZERO_DIVISIONassertRaisesZeroDivisionErrorr   s      r   test_truediv_zero_divisionz&ComplexTest.test_truediv_zero_divisionv   s    ! 	 	DAq""#455  A              	 	   9=	 =	c                 .   |                      t                    5  ddz   d d d            n# 1 swxY w Y   |                      t                    5  ddz   d d d            n# 1 swxY w Y   |                      t                    5  ddz   d d d            n# 1 swxY w Y   |                      t                    5  ddz   d d d            n# 1 swxY w Y   |                      t                    5  ddz   d d d            d S # 1 swxY w Y   d S Nr   rA   r   r   rN   	TypeErrorr   s    r   test_floordivzComplexTest.test_floordiv{   sM   y)) 	 	t	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	cMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	aKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	DMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	$KK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	T   -11A$$A(+A(	BB"B CCC7D

DDc                     t           D ]<\  }}|                     t                    5  ||z   d d d            n# 1 swxY w Y   =d S rL   rM   rN   rU   r   s      r   test_floordiv_zero_divisionz'ComplexTest.test_floordiv_zero_division   s    ! 	 	DAq""9--  Q              	 	rQ   c           	      V   |                      t                              dddz            d           |                      t                              dd           t                     |                      t                              dd          d           |                      t                              dd          d           |                      t                              dd          d           |                      t                              dd          d           t          dd          D ]}|dz  }|                      t                              |d	z   |          d           |                      t                              |d	z   |          d           |                      t                              t          ||          |          d           |                      t                              t          ||          |          d           |                      t                              dd          t                     |                      t                              dd          t                     |                      t                              dd          t                     |                      t          	                    dd          t                     | 
                    t          t          j        dd           | 
                    t          t          j        dd           | 
                    t          t          j        dd           | 
                    t          t          j        dd           |                      t          j        dd          d           |                      t          j        dd          d           |                      t          j        dd          d           |                      t          j        dd          d           d S )
Nr   r   i'  FTy       @       @rC   g      Y@r   )assertIsr   __eq____lt__NotImplemented__ne__rE   __le____gt____ge__rN   rU   operatorltlegtgeeqne)r   r;   fs      r   test_richcomparezComplexTest.test_richcompare   s   gnnT1e844e<<<gnnT400.AAAgnnT400$777gnnT400%888gnnT400%888gnnT400$777q# 	B 	BAE	AMM'..2q114888MM'..2q115999MM'..A::EBBBMM'..A::DAAAAgnnT400.AAAgnnT400.AAAgnnT400.AAAgnnT400.AAA)X[$===)X[$===)X[$===)X[$===hk$--t444hk$--u555hk$--u555hk$--t44444r    c           	      $    d fd	}t          dd          D ]Z}d|z   }d|z   |d|z  t          dd          fd            |d|z  t          dd          d	 t          |                     [ |d
t          dd          d            d S )Nr   c                    |D ]}| |z   }t          ||          }                    t                               ||           ||                                         t                               ||           ||                      d S rL   )r   r]   r^   ra   )ndeltasis_equalr   deltar;   r3   r   s          r   checkz6ComplexTest.test_richcompare_boundaries.<locals>.check   s     I IIAt$$gnnQ22HHUOODDDgnnQ224GHHHH	I Ir    r   
   4      e   c                     | z  dk    S )Nr   r8   )rs   mults    r   <lambda>z9ComplexTest.test_richcompare_boundaries.<locals>.<lambda>   s    9J r    c                     dS )NFr8   rs   s    r   r{   z9ComplexTest.test_richcompare_boundaries.<locals>.<lambda>   s     r    l          ir   c                     dS )NTr8   r}   s    r   r{   z9ComplexTest.test_richcompare_boundaries.<locals>.<lambda>   s    T r    )r   )rE   r9   )r   rt   r;   powrz   s   `   @r   test_richcompare_boundariesz'ComplexTest.test_richcompare_boundaries   s    	I 	I 	I 	I 	I 	I q" 	J 	JAq&C6DE!s(E!SMM+J+J+J+JKKKE!s(E!SMM+>+>aIIIIguT1~~'9'9:::::r    c                 .   |                      t                    5  ddz   d d d            n# 1 swxY w Y   |                      t                    5  ddz   d d d            n# 1 swxY w Y   |                      t                    5  ddz   d d d            n# 1 swxY w Y   |                      t                    5  ddz   d d d            n# 1 swxY w Y   |                      t                    5  ddz   d d d            d S # 1 swxY w Y   d S rS   rT   rV   s    r   test_modzComplexTest.test_mod   sK   y)) 	 	dOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	SLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	QJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	4LL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	JJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rX   c                     t           D ]<\  }}|                     t                    5  ||z   d d d            n# 1 swxY w Y   =d S rL   rZ   r   s      r   test_mod_zero_divisionz"ComplexTest.test_mod_zero_division   s    ! 	 	DAq""9--  A              	 	rQ   c                 Z   |                      t          t          dd           |                      t          t          dd           |                      t          t          dd           |                      t          t          dd           |                      t          t          dd           d S rS   )rN   rU   divmodrV   s    r   test_divmodzComplexTest.test_divmod   s    )VT4888)VT3777)VT1555)VS$777)VQ55555r    c                 d    t           D ]'\  }}|                     t          t          ||           (d S rL   )rM   rN   rU   r   r   s      r   test_divmod_zero_divisionz%ComplexTest.test_divmod_zero_division   s<    ! 	7 	7DAqiA6666	7 	7r    c                    |                      t          dd          d           |                      t          dd          d           |                     t          t          dd           |                      t          dd          d           |                      t          dd	          d
           |                     t          t          ddd           |                     t
          t          dd           d}|                     |dz  d
           |                     |dz  dz   d
           |                     dd
           |                     dd
           	 d|z   |                     d           n# t          $ r Y nw xY w	 ddz   |                     d           n# t          $ r Y nw xY w|                     |dz  |dz             |                     |dz  |dz             |                     |dz  |dz             |                     dd
           d}|                     t          t          ||d           t          j	        t          j	        d
z   t          j	        d
z
  t          j	         t          j	         d
z   t          j	         d
z   f}|D ]t}|D ]o}| 
                    ||          5  t          ||          }	 ||z   n# t
          $ r Y nw xY w	 ||z   n# t
          $ r Y nw xY wd d d            n# 1 swxY w Y   pud S )Nr   r   r   rD   r                 ?y                 r   yZbti      ?yp=
ף
@Q@rA   z,should fail 0.0 to negative or complex powery      @       i   iyffffff@ffffff@r   r   r   )r   r   rN   rO   
ValueErrorOverflowErrorassertEqualr+   sysmaxsizesubTestr   )r   r   r   valuesr   r   cs          r   test_powzComplexTest.test_pow   s   s4444s4444+S$;;;s2r{{D111s2s||Q///*c4t<<<-hAAAb!$$$ba(((1%%%!$$$	F!GG IIDEEEE ! 	 	 	D	
	F4LL IIDEEEE ! 	 	 	D	 	c18,,,dAI...c18,,,A&&&*c1a333 +s{1}ck!m;,QQ@ 	 	D 
 
\\t$\77 	 	d++AT			(   Q(   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
	 	s~   E7 7
FFF# #
F0/F04K?KK?
K	K?K	K?K#"K?#
K0	-K?/K0	0K??LLc           	         t          dd          t          dd          t          dt                    t          t          d          g}g d}|D ]}|D ]}|                     ||          5  	 ||z  }n# t          $ r d	}Y nw xY w	 |t	          |          z  }n# t          $ r d	}Y nw xY w	 |t          |          z  }n# t          $ r d	}Y nw xY w|                     t          |          t          |                     |                     t          |          t          |                     d d d            n# 1 swxY w Y   d S )
Ng      @g      (@g\nTg;%_nTg      r   )ir=   r   r   r   rw            )valueexponentoverflow)r   INFr   r   r9   r   str)r   r   	exponentsr   r   int_pow	float_powcomplex_pows           r   %test_pow_with_small_integer_exponentsz1ComplexTest.test_pow_with_small_integer_exponents  s    CGX&&D#C	
 =<<	 	E 	EE% E E\\\AA E E-"'/( - - -",-/$)5??$:		( / / /$.			/1&+WX->->&>( 1 1 1&01$$S^^S\\BBB$$S%5%5s7||DDDE E E E E E E E E E E E E E EE	E 	Es   ,D>.A43D>4B	 D>B	D>BD>B)	&D>(B)	)D>-C ?D> C	D>C	A#D>>EEc                     t          d          D ]C}|                     t          t                      dz   t                      dz                        D|                     t          dd                      d S )NrC   gư>r   )rE   r$   r   r   )r   r;   s     r   test_boolcontextzComplexTest.test_boolcontext,  sm    s 	G 	GAOOGFHHtOVXX_EEFFFFGC---.....r    c                 r    |                      t          dd                                          d           d S )Ng333333@g#@y333333@#)r0   r   	conjugaterV   s    r   test_conjugatezComplexTest.test_conjugate1  s4    c**4466AAAAAr    c           	           G d d          }|                      t           |d                    d           |                     t          t           |d                      |                     t          t          i            |                     t          t           |d                     |                     t          t           |d                     |                     t          d          d           |                     t          d          d           |                     t          d	          d           |                     t          d          d           |                     t          d          d           |                     t          dd          d           |                     t          dd          d           |                     t          dd	          d           |                     t          dd          d           |                     t          dd          d           |                     t          dd	          d           |                     t          d
d          d           |                     t          d
d          d           |                     t          d
d	          d           |                     t          d          d           |                     t          d          d           |                     t          d          d           |                     t          d          d           |                     t          dd          d           |                     t          dd          d           |                     t          dd          d           |                     t          dd          d           |                     t          dd          d           |                     t          dd          d           |                     t          dd          d           |                     t          dd          d           |                     t          d          d           |                     t          d          d           |                     t                      d           |                     t          d          d           |                     t          d          d           |                     t          d          d           |                     t          d          d           |                     t          d          d            |                     t          d!          d"           |                     t          d#          d$           |                     t          d%          d            |                     t          d&          d           |                     t          d'          d           |                     t          d(          d           |                     t          d)          d*           |                     t          d+          d           |                     t          d,          d           |                     t          d-          d            G d. d/t                    }|                     t           |d0                    d0           |                     t          d1d23          d4           |                     t          d45          d4           |                     t          d4d23          d6           |                     t          dd73          d8           d9 }|                       |t          d
d          j                   |d                     |                       |t          d
d:          j                   |d:                     |                       |t          dd
          j                   |d                     |                       |t          d:d
          j                   |d:                     d }|                     t          |          |u            ~|                     t          t          dd           |                     t          t          dd           |                     t          t          d;           |                     t          t          d<           |                     t          t          d<           |                     t          t          d<           |                     t          t          d=           |                     t          t          d            |                     t          d>t          d            |                     t          t          d?           |                     t          t          d@           |                     t          t          ddA           |                     t          t          ddB           |                     t          t          ddA           |                     t          t          dC           |                     t          t          dD           |                     t          t          dE           |                     t          t          dF           |                     t          t          dG           |                     t          t          dH           |                     t          t          dI           |                     t          t          dJ           |                     t          t          dK           |                     t          t          dL           |                     t          t          dM           |                     t          t          dN           |                     t          dOt          ddPid           |                     t          dQt          dddPi           |                     t          t          dR           |                     t          t          dS           |                     t          t          dT           |                      t          t          dU                    t                     |                      t          dV          d0           |                     t          t          dW            G dX dYt                     G fdZd[          }|                     t           |                        G d\ d]          }|                     t           |d^                    dB           |                     t           |d_           |d`          3          d4           |                     t          t           |d                       G da db          }|                     t           |dB                    dc           |                     t          dd |dB                    de           |                     t          t           |dPdfz                       |                     t          t          dd |dPdfz                        G dg dh          }|                     t          t           |                       |                     t          t          dd |                        G di djt                    }	 G dk dlt                    }
 G dm d/t                    }|                      t           |	d                    dn           |                     t                     5  |                      t           |
d                    do           d d d            n# 1 swxY w Y   |                     t          t           |d                     d S )pNc                       e Zd Zd Zd ZdS )(ComplexTest.test_constructor.<locals>.NSc                     || _         d S rL   r   r   r   s     r   __init__z1ComplexTest.test_constructor.<locals>.NS.__init__6  s    Etzzzr    c                     | j         S rL   r   rV   s    r   __complex__z4ComplexTest.test_constructor.<locals>.NS.__complex__7  s	    $*#4r    N)__name__
__module____qualname__r   r   r8   r    r   NSr   5  s"        99944444r    r   y      ?      $@g      ?r   z1+10jru   y      $@        g      $@r   yQ	@        gQ	@i:  y     s@        r   r   r   y        Q	@yQ	        1rA   1jr   z-1r   z+1z(1+2j)      ?       @z
(1.3+2.2j)y?@z3.14+1JyQ	@      ?z ( +3.14-6J )yQ	@      z ( +3.14-J )yQ	@      z ( +3.14+j )Jz( j )z+Jz( -j)y             z1e-500z-1e-500jz-1e-500+1e-500jc                       e Zd ZdS ).ComplexTest.test_constructor.<locals>.complex2Nr   r   r   r8   r    r   complex2r   k  s          r    r   r         r   y      1@      7@)r   y      1@      G@      @      @y            @c                 "    t          | d          S )z7Function that produces different results for 0. and -0.      )r   )r&   s    r   split_zerosz1ComplexTest.test_constructor.<locals>.split_zerosu  s    C== r           z1+1j jy      @      @ znot 'NoneType' z3 92*   z1+z1+1j+1jz--z(1+2jz1+2j)z1+(2j)z	(1+2j)123r&   z1j+21e1ejz1e++1ejz)1+2j(z7first argument must be a string or a number, not 'dict'rw   z,second argument must be a number, not 'dict'z1..1jz1.11.1jz1e1.1j  11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111u    ( 1+1j ) u   こんにちはc                       e Zd ZdS )-ComplexTest.test_constructor.<locals>.EvilExcNr   r8   r    r   EvilExcr             Dr    r   c                       e Zd Z fdZdS )1ComplexTest.test_constructor.<locals>.evilcomplexc                     rL   r8   )r   r   s    r   r   z=ComplexTest.test_constructor.<locals>.evilcomplex.__complex__  s    r    N)r   r   r   r   )r   s   r   evilcomplexr     s.              r    r   c                       e Zd Zd Zd ZdS ),ComplexTest.test_constructor.<locals>.float2c                     || _         d S rL   r   r   s     r   r   z5ComplexTest.test_constructor.<locals>.float2.__init__      "


r    c                     | j         S rL   r   rV   s    r   	__float__z6ComplexTest.test_constructor.<locals>.float2.__float__  
    z!r    N)r   r   r   r   r   r8   r    r   float2r     2        # # #" " " " "r    r   g      E@g      1@g      7@c                       e Zd Zd Zd ZdS )-ComplexTest.test_constructor.<locals>.MyIndexc                     || _         d S rL   r   r   s     r   r   z6ComplexTest.test_constructor.<locals>.MyIndex.__init__  r   r    c                     | j         S rL   r   rV   s    r   	__index__z7ComplexTest.test_constructor.<locals>.MyIndex.__index__  r   r    N)r   r   r   r   r   r8   r    r   MyIndexr     r   r    r   y      E@        {   y     ^@      E@i  c                       e Zd Zd ZdS )+ComplexTest.test_constructor.<locals>.MyIntc                     dS )Nr   r8   rV   s    r   __int__z3ComplexTest.test_constructor.<locals>.MyInt.__int__  s    rr    N)r   r   r   r   r8   r    r   MyIntr     s#            r    r   c                       e Zd ZdZd ZdS ).ComplexTest.test_constructor.<locals>.complex0z:Test usage of __complex__() when inheriting from 'complex'c                     dS )N              E@r8   rV   s    r   r   z:ComplexTest.test_constructor.<locals>.complex0.__complex__  s    sr    Nr   r   r   __doc__r   r8   r    r   complex0r     s)        LL    r    r   c                        e Zd ZdZddZd ZdS ).ComplexTest.test_constructor.<locals>.complex1z3Test usage of __complex__() with a __new__() methodr   c                 >    t                               | d|z            S )Nrw   )r   __new__r   s     r   r   z6ComplexTest.test_constructor.<locals>.complex1.__new__  s    tQuW555r    c                     | S rL   r8   rV   s    r   r   z:ComplexTest.test_constructor.<locals>.complex1.__complex__  s    r    N)r   )r   r   r   r   r   r   r8   r    r   complex1r     s=        EE6 6 6 6    r    r   c                       e Zd ZdZd ZdS )r   z`Make sure that __complex__() calls fail if anything other than a
            complex is returnedc                     d S rL   r8   rV   s    r   r   z:ComplexTest.test_constructor.<locals>.complex2.__complex__  s    tr    Nr   r8   r    r   r   z.ComplexTest.test_constructor.<locals>.complex2  s-        # #    r    r                  @)r   r   rN   rU   r   r   r   r$   r   intr9   assertRaisesRegextype	Exceptionr   assertWarnsDeprecationWarning)r   r   r   r   r   r   r   r   r   r   r   r   s              @r   test_constructorzComplexTest.test_constructor4  s   	5 	5 	5 	5 	5 	5 	5 	5 	E++U333)Wbbhh777)Wb111)Wbbgg666)Wbbee444ww//777wr{{E222wt}}e444wr{{E222wu~~u555wq}}e444wq}}e444wq666wq}}e444wq}}e444wq666ws2666ws2666ws400%888ww//999wt}}g666ws||X666ws||X666ww33W===wtS117;;;wsA999wsA999wr5118<<<wsE22H===wr400%888wsD115999ws||T222wt}}b111wyy1---wt}}b111wt}}b111wx00$777w|44h???wy117;;;w77AAAw~66@@@w~66@@@ws||R000ww//444wt}}b111ww//555wx00*===wz22J???w'899;GGG%%%%%w%%%wxx~~66===wBR888&AAAwF333V<<<wF<<<fEEEwDt<<<eDDD
	! 	! 	! 	WR__%9::KKOOLLLWR%5%5%:;;[[=M=MNNNWR__%9::KKOOLLLWS"%5%5%:;;[[=M=MNNN

a((()Wc3777)Wa555 	*gy999)S$///)S$///)UD111*gr222)Wd333y*:GTJJJ*gt444*gv666)Wc3777)Wc2666)Wa555*gt444*gy999*gt444*gw777*gw777*gx888*g{;;;*gs333*gv666*gw777*gy999*gx888EaUA	 	 	 	:Q1	 	 	
 	*gw777*gy999*gx888 	gg..//999!CDDdKKK 	*g/OPPP	 	 	 	 	i 	 	 		 	 	 	 	 	 	 	 	 	 	'7KKMM:::	" 	" 	" 	" 	" 	" 	" 	" 	wvvc{{33R888wFF3KKffSkkJJJFSSS)WffTll;;;	" 	" 	" 	" 	" 	" 	" 	" 	wwwr{{33Y???wsGGBKK88+FFF-''!T'2B2BCCC-#wwq$w7G7GHHH	 	 	 	 	 	 	 	 	)Weegg666)Wc5577;;;	 	 	 	 	w 	 	 	
	 	 	 	 	w 	 	 		 	 	 	 	w 	 	 	 	"..444011 	8 	8WXXb\\22B777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8)Whhrll;;;;;s   -A@@A@@A@c                    d}|                      |                                |           |                      t          |                                          t                      G d dt                    } |d          }|                      |                                d           |                      t          |                                          t                     d S )Nr   c                       e Zd ZdS )6ComplexTest.test___complex__.<locals>.complex_subclassNr   r8   r    r   complex_subclassr    r   r    r  )r   r   r   r   )r   r3   r  s      r   test___complex__zComplexTest.test___complex__  s    !,,,ammoo..888	 	 	 	 	w 	 	 	 V$$&111ammoo..88888r    c           	      "    G d dt                     }ddt          t           t          fD ]}ddt          t           t          fD ]}|                     ||          5  t          ||          }|                     |j        |           |                     |j        |            |||          }|                     t          |          |           |                     |j        |           |                     |j        |           t           |||                    }|                     t          |          t                      |                     |j        |           |                     |j        |            |t          ||                    }|                     t          |          |           |                     |j        |           |                     |j        |           d d d            n# 1 swxY w Y   Ȑd S )Nc                       e Zd ZdS )>ComplexTest.test_constructor_special_numbers.<locals>.complex2Nr   r8   r    r   r   r    r   r    r   r   r   )r&   r'   )	r   r   rF   r   r.   r   r   r]   r   )r   r   r&   r'   r3   s        r    test_constructor_special_numbersz,ComplexTest.test_constructor_special_numbers  s7   	 	 	 	 	w 	 	 	dC#s* 	= 	=A$cT3. = =\\A\++ = =1A11!&!<<<11!&!<<< AAMM$q''844411!&!<<<11!&!<<<A//AMM$q''733311!&!<<<11!&!<<< A//AMM$q''844411!&!<<<11!&!<<<= = = = = = = = = = = = = = ==	= 	=s   FH  HHc           
         t           D ]t          fddD                       st|                     t                    t	                               |                     t                    t                              dd                               t          D ]Cdv rt          fddD                       s!|                     t          t                     Dd S )Nc              3       K   | ]}|v V  	d S rL   r8   r:   chlits     r   	<genexpr>z/ComplexTest.test_underscores.<locals>.<genexpr>  '      44RrSy444444r    xXoObB_r   )0_709_99c              3       K   | ]}|v V  	d S rL   r8   r  s     r   r  z/ComplexTest.test_underscores.<locals>.<genexpr>  r  r    )	r   anyr   r   evalreplacer   rN   r   )r   r  s    @r   test_underscoreszComplexTest.test_underscores  s    , 	N 	NC4444844444 N  tCyy999  ws{{37K7K/L/LMMM. 	< 	<C&&&4444844444 <!!*gs;;;		< 	<r    c           
      .   t          dd          D ]}|                     t          |          t          t          |d                               |dz  }|                     t          |          t          t          |d                               d S )Nr      r         @r   )rE   r   hashr   )r   r&   s     r   	test_hashzComplexTest.test_hash   s    sB 	< 	<AT!WWd71a==&9&9:::HAT!WWd71b>>&:&:;;;;	< 	<r    c                     d t          dd          D             }|D ];}|                     |j        dz  |j        dz  z   dz  t	          |                     <d S )Nc                 `    g | ]+}t          d d          D ]}t          |dz  |dz            ,S )	   r   g      @)rE   r   )r:   r&   r'   s      r   r<   z(ComplexTest.test_abs.<locals>.<listcomp>'  s?    NNN%1++NNQ"ad##NNNNr    r%  r&  rw   g      ?)rE   r   r   r   r#   )r   numsnums      r   test_abszComplexTest.test_abs&  so    NNU2a[[NNN 	R 	RC""CHaK#(A+$=3#FCQQQQ	R 	Rr    c                 v   | j         fd} |dd            |dd            |dd| j                    |t          d	t                    d
            |t          d	t                     d            |t          t          d          d            |t          t           t                    d            |t          t          d          d            |t          dt                    d            |t          t          t                    d            |t          dt                    d            |t          dt                     d            |t          dt                    d           |                      dt          t          d                               |                      dt          t          d                               |                      dt          t          d                               |                      dt          t          d                               d S )Nc                 j     |t          |           |            |t          |           |           d S rL   reprr   vexpectedtest_fns      r   testz'ComplexTest.test_repr_str.<locals>.test,  8    GDGGX&&&GCFFH%%%%%r    y      ?      @z(1+6j)y      ?      z(1-6j)y             z(-1+-0j))r1  r   z(1+infj)z(1-infj)r   z(inf+1j)z(-inf+infj)z(nan+1j)z(1+nanj)z
(nan+nanj)r   infjz-infjnanjy             y              @)r   assertNotEqualr   r   rF   r-  r   r2  s     r   test_repr_strzComplexTest.test_repr_str+  s   &*&6 	& 	& 	& 	& 	T8T8Wj$*=>>>>WRz***WR#
+++WS!__j)))WcT3///WS!__j)))WQ__j)))WS#---WQ__f%%%WQw'''WQ__f%%%gd4jj11222gd4jj11222WT#YY//000GDHH--.....r    c                    | j         fd} |t          dd          d            |t          dd          d            |t          dd          d            |t          dd          d	            |t          dd          d
            |t          dd          d            |t          dd          d            |t          dd          d           d S )Nc                 j     |t          |           |            |t          |           |           d S rL   r,  r.  s      r   r2  z5ComplexTest.test_negative_zero_repr_str.<locals>.testH  r3  r    r   r   r   r   z(-0+1j)r   z-1jz(-0-1j)0jz-0jz(-0+0j)z(-0-0j))r   r   r7  s     r   test_negative_zero_repr_strz'ComplexTest.test_negative_zero_repr_strF  s    &*&6 	& 	& 	& 	& 	WR__%%%WS"	***WR&&&WS#	***WR__%%%WR&&&WS"	***WS#	*****r    c                 2    |                      dd           d S )Ny            )r   rV   s    r   test_negzComplexTest.test_negV  s    %(((((r    c                 N   |                      d                                d           |                      d                                d           |                      d                                d           |                      d                                d           |                      t          d	t                                                    d
t          f           |                      t          t          d	                                          t          d
f           d S )Nr   )r          @y      ?       )r   g       r   )r   r@                )r   r   r   r   )r   __getnewargs__r   r   rV   s    r   test_getnewargszComplexTest.test_getnewargsY  s    $..00*===$..00+>>>",,..
;;;#--//===C7799C:FFFa7799C:FFFFFr    c                     d\  }}|                      t          |j        d          t          dd                     |                      t          |j        d          t          dd                     d S )N)r   rA  r   r   r   )r   r   r   )r   z1z2s      r   test_plus_minus_0jzComplexTest.test_plus_minus_0ja  sg     Brw,,eBnn===rw,,eCoo>>>>>r    c                 b   d}d}d}|                      |j        d           |                      |j        d           |                      |j        d           |                      |j        d           |                      |j        d           |                      |j        t                      d S )NrA  y             y             r   g      )r.   r   r   r   )r   z0rE  rF  s       r   test_negated_imaginary_literalz*ComplexTest.test_negated_imaginary_literalh  s    
 	%%bgt444%%bgt444%%bgt444%%bgt444%%bgt444%%bgt44444r    c                 X   |                      t          d          t          t          d                     |                      t          d          t          dt                                |                      t          d          t          t           t                               d S )N1e500r   z-1e500jz-1e500+1.8e308j)r   r   r   rV   s    r   test_overflowzComplexTest.test_overflowx  s    ))73+<+<===++WS3$-?-?@@@!233WcT35G5GHHHHHr    c           	         dddddddt           t          g	}|d |D             z  }|D ]s}|D ]n}t          ||          }t          t          |                    }|                     |j        |j                   |                     |j        |j                   ott          d          t          d	          }}t          d|          t          d|          }	}|D ]}|D ]z}t          ||          }t          t          |                    }|                     d|j        z   d|j        z              |                     d|j        z   d|j        z              {d S )
Nr   gi    rB   g(0?go!	@gd~QJc                     g | ]}| S r8   r8   )r:   r/  s     r   r<   z3ComplexTest.test_repr_roundtrip.<locals>.<listcomp>  s    """!"""r    r
   r   )	r   rF   r   r-  r.   r   r   r9   r  )
r   valsr&   r'   r3   	roundtripr
   r   r4  r5  s
             r   test_repr_roundtripzComplexTest.test_repr_roundtrip~  s   VVVVVT3L""T""""  	F 	FA F FAqMM#DGG,,	--afinEEE--afinEEEE	F <<uSS#&&S(9(9d 	D 	DA D DAqMM aMM	--cAFl.1IN.BD D D--cAFl.1IN.BD D D DD	D 	Dr    c                 ,   |                      t          dd          t          d                     |                      t          dd          t          d                     |                      t          dd          t          d                     |                      t          dd          t          d                     |                      t          dd          t          d                     |                      t          dd          t          d                     |                      t          dd          t          d                     |                      t          dd	          t          d                     d
}|                      t          |d          t          |                     |                      t          |d          t          |                     |                      t          |d	          t          |                     |                      t          |d          t          |                     t          dd          }|                      t          |d          t          |                     |                      t          |d          t          |                     |                      t          |d	          t          |                     |                      t          |d          t          |                     t          dd          }|                      t          |d          t          |                     |                      t          |d          t          |                     |                      t          |d	          t          |                     |                      t          |d          t          |                     |                      t          dd          d           |                      t          dd          d           |                      t          dd          d           |                      t          dd          d           |                      t          dd          d           |                      t          dd          d           |                      t          dd          d           |                      t          dd          d           |                      t          dd          d            |                      t          d!d          d"           |                      t          d#d          d$           |                      t          d!d%          d&           |                      t          d!d'          d&           |                      t          d!d(          d)           |                      t          d!d*          d+           |                      t          d!d,          d-           |                      t          d.d/          d0           |                      t          d1d2          d3           |                      t          d1d4          d5           |                      t          d1d6          d7           |                      t          d1d8          d9           |                      t          d1d:          d;           |                      t          d1d<          d=           |                      t          d1d>          d?           |                      t          d@dA          dB           |                      t          d1dC          dD           |                      t          d1dE          dD           |                      t          d1dF          dG           |                      t          dHdF          dI           |                      t          dHdJ          dK           |                      t          dHdL          dM           |                      t          dNdL          dO           |                      t          dPdQ          dR           |                      t          dSdT          dU           |                      t          dSdV          dW           |                      t          dSdX          dY           |                      t          dSdZ          d[           |                      t          d\d          d]           |                      t          d\d^          d_           |                      t          dSd`          da           |                      t          dSdb          da           |                      t          dSdc          dd           |                      t          dSde          dd           |                      t          dfdg          dh           |                      t          dfdZ          di           |                      t          dfdj          dk           |                      t          dfdV          dl           |                      t          dfd^          dm           |                      t          dfdn          do           |                      t          dfdp          dq           |                     t
          drj        ds           |                     t
          d1j        dt           duD ]#}|                     t
          drj        |           $|                      dv                    dw          dx           |                      t          t          t          t                    d%          dy           |                      t          t          dzt                    d%          d{           |                      t          t          t          dz          d%          d|           |                      t          t          t          d}          d%          d~           |                      t          t          t          t                    d'          d           |                      t          t          dzt                    d'          d           |                      t          t          t          dz          d'          d           |                      t          t          t          d}          d'          d           |                      t          t          t          t                    d%          d           |                      t          t          dzt                    d%          d           |                      t          t          t          dz          d%          d           |                      t          t          t          d}          d%          d           |                      t          t          t          t                    d'          d           |                      t          t          dzt                    d'          d           |                      t          t          t          dz          d'          d           |                      t          t          t          d}          d'          d           d S )Ny      ?      @r   y      ?      @y              @y        	@y      @        y	@        -<y$I$I?%I$I,10r   r   r   r   r@  3gz1+3jz0+3jz1.5+3.5jz+gz	+1.5+3.5jy      ?      z	+1.5-3.5jz-gz1.5-3.5jz gz	 1.5+3.5jz	 1.5-3.5jy            @z	-1.5+3.5jy            z	-1.5-3.5jy      z-1.5-3.5e-20jrl   z-1.500000-3.500000jFez-1.500000e+00-3.500000e+00jz.2ez-1.50e+00-3.50e+00jz.2Ez-1.50E+00-3.50E+00jy       \z.2Gz-1.5E+10-3.5E+05jy      ?      @z<20gz1.5+3j              z*<20gz1.5+3j**************z>20gz              1.5+3jz^20gz       1.5+3j       z<20z(1.5+3j)            z>20z            (1.5+3j)z^20z      (1.5+3j)      y+?Clz^20.2z     (1.1-3.1j)     z20.2fz          1.50+3.00jz>20.2fz<20.2fz1.50+3.00j          y0)VC D      @z150000000000000000000.00+3.00jz>40.2fz(          150000000000000000000.00+3.00jz^40,.2fz(  150,000,000,000,000,000,000.00+3.00j  y|3*+TTD      @z( 1,500,000,000,000,000,000,000.00+3.00j y|3*+TTD     p@z,.2fz*1,500,000,000,000,000,000,000.00+3,000.00jr   z.0ez1e+00+1e+00jz#.0ez1.e+00+1.e+00jz.0fz1+1jz#.0fz1.+1.jy??z1.1+1.1jz#gz1.10000+1.10000jz.1ez1.0e+00+1.0e+00jz#.1ez.1fz1.0+1.0jz#.1fy            ?z#fz-1.500000+0.500000jz-2.+0.jz#ez-1.500000e+00+5.000000e-01jz-2.e+00+5.e-01jz-1.50000+0.500000jz.0gz-2+0.5jz#.0gz-2.+0.5jy      ?      ?010fz=20bcdoxXz	*{0:.3f}*yn!	@	@z*3.142+2.718j*znan+nanjr   z1.000000+nanjznan+1.000000jr   znan-1.000000jzNAN+NANjz1.000000+NANjzNAN+1.000000jzNAN-1.000000jzinf+infjz1.000000+infjzinf+1.000000jzinf-1.000000jzINF+INFjz1.000000+INFjzINF+1.000000jzINF-1.000000j)	r   r,   r   r   rN   r   
__format__rF   r   )r   r3   ts      r   test_formatzComplexTest.test_format  s   b))3t99555"--s8}}===BR111b))3t99555b))3t99555++S[[999 	,,c&kk:::,,c&kk:::2A///3Q0003Q0004#a&&111C2A///3Q0003Q0003Q000D#2A///3Q0003Q0003Q000c**F333C&111#..
;;;$//===$//===$//<<<$//===$//===	400+>>>	400+>>>s33_EEE	3//1FGGG	3//1FGGG	3//1NOOO	5113HIII	5113HIII668KLLL//2HIII002HIII//2HIII//2HIII..2HIII..2HIII..2HIIIg668NOOO002HIII113IJJJ113IJJJ	8446VWWW	8446`aaa	9557abbb	9557abbbf557cddd 	e,,n===f--/?@@@e,,f555f--x888#..
;;;$//1CDDD 	e,,/ABBBf--/ABBBe,,z:::f--z::: 	T224IJJJV44i@@@T224QRRRV446GHHHT224HIIIU33Y???V44jAAA 	*x&;VDDD 	*v&95AAA  	D 	DAj8*?CCCC 	++,<==?OPPP 	S 1 1377DDD355GGGQ55GGGR 0 0#66HHHS 1 1377DDD355GGGQ55GGGR 0 0#66HHHS 1 1377DDD355GGGQ55GGGR 0 0#66HHHS 1 1377DDD355GGGQ55GGGR 0 0#66HHHHHr    N)r!   )'r   r   r   r   r)   r.   r0   r5   rJ   rP   rW   r[   rm   r   r   r   r   r   r   r   r   r   r  r	  r   requires_IEEE_754r  r  r"  r)  r8  r<  r>  rC  rG  rJ  rM  rR  r_  r8   r    r   r   r      s       @ @ @
, 
, 
, 
,$ $ $.1 1 1 1
# # #+ + +0  

 
 
  
5 5 54; ; ;"    
6 6 67 7 7: : :xE E E8/ / /
B B B{< {< {<z
9 
9 
9 = = =,
< 
< 
<< < <R R R
/ / /6 + + +) ) )G G G ? ? ? 5 5 5 I I I
 D D D6wI wI wI wI wIr    r   __main__)r   r   r2  r   test.test_grammarr   r   r   mathr   r   r	   re   r9   r   rF   rM   r   r   r   mainr8   r    r   <module>re     s    



      < < < < < < < <       ' ' ' ' ' ' ' ' ' ' eElleEllzI zI zI zI zI(# zI zI zIz zHMOOOOO r    