Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_cmath.cpython-311.opt-1.pyc
�

�Ke�`��@�ddlmZmZmZddlmZmZddlmZddlZddl	Z	ddl
Z
ddl	mZmZm
Z
mZddlZddlZed��Zed��Zd�dD��Zd	�ed
fedfeefdefd
efdefd
efeefedfed
fedfed
feefd
efdefd
efdefeefed
fedffD��Zd�eefed
fedfed
fedfeefeefd
efdefd
efdefeeffD��ZGd�dej��ZGd�dej��Zedkrej��dSdS)�)�requires_IEEE_754�cpython_only�
import_helper)�parse_testfile�	test_fileN)�phase�polar�rect�pi�inf�nanc�8�g|]}dD]}t||�����S)������complex��.0�x�ys   �9/usr/local/apps/python3/lib/python3.11/test/test_cmath.py�
<listcomp>rs-��I�I�I�1�[�I�I����A���I�I�I�I�rc�4�g|]\}}t||����S�rrs   rrrs0�������1�g�a��m�m���rr�ffffff@r�ffffff�c�4�g|]\}}t||����Srrrs   rrr%s0��
�
�
�$�!�Q���1�
�
�
�
�
rc�z�eZdZd�dD��Ze�d���e�d���d�Zd�Zd�Zd�Z		d!d�Z	d
�Z
d�Zd�Zd�Z
d�Zed���Zd�Zd�Zed���Zd�Zd�Zed���Zd�Zd�Zd�Zd�Zd�Zed���Zed���Zed ���ZdS)"�
CMathTestsc�8�g|]}tt|����Sr)�getattr�cmath)r�fnames  rrzCMathTests.<listcomp>6s.��$�$�$��g�e�U�+�+�$�$�$r)�acos�acosh�asin�asinh�atan�atanh�cos�cosh�exp�log�log10�sin�sinh�sqrt�tan�tanhc�,�tj|d��S)Ny�@�r$r/�rs r�<lambda>zCMathTests.<lambda>;s��U�Y�q�*�%=�%=�rc�,�tjd|��S)Ny,@;�r7r8s rr9zCMathTests.<lambda><s��U�Y�w��%:�%:�rc�<�ttd���|_dS)Nzutf-8)�encoding)�openr�test_values��selfs r�setUpzCMathTests.setUp>s���	�G�<�<�<����rc�8�|j���dS�N)r>�closer?s r�tearDownzCMathTests.tearDownAs������ � � � � rc��d}tj|��stj|��r+tj|��rtj|��rdSnA||kr;|dkrdStjd|��tjd|��krdS|dz
}|�|�||����dS)a#Fail unless 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��?z: zeros have different signs)�math�isnan�copysign�fail�format)r@rr�msgs    r�assertFloatIdenticalzCMathTests.assertFloatIdenticalDs���7���:�a�=�=�
	6�D�J�q�M�M�
	6��z�!�}�}�
���A���
����
�!�V�V��C�x�x�����s�A�&�&�$�-��Q�*?�*?�?�?����5�5���	�	�#�*�*�Q��"�"�#�#�#�#�#rc��|�|j|j��|�|j|j��dS)z�Fail unless complex numbers x and y have equal values and signs.

        In particular, if x and y both have real (or imaginary) part
        zero, but the zeros have different signs, this test will fail.

        N)rN�real�imag)r@rrs   r�assertComplexIdenticalz!CMathTests.assertComplexIdentical[s>��	
�!�!�!�&�!�&�1�1�1��!�!�!�&�!�&�1�1�1�1�1r�V瞯�<�
Nc���tj|��r@tj|��rdS|�|pd�|����tj|��r3||krdS|�|pd�||����|sY|sWtjd|��tjd|��kr+|�|pd�||����	t
||z
��}|t||t
|��z��krdSn#t$rYnwxYw|�|pd�||����dS)a�Fail if the two floating-point numbers are not almost equal.

        Determine whether floating-point values a and b are equal to within
        a (small) rounding error.  The default values for rel_err and
        abs_err are chosen to be suitable for platforms where a float is
        represented by an IEEE 754 double.  They allow an error of between
        9 and 19 ulps.
        Nz{!r} should be nanz>finite result where infinity expected: expected {!r}, got {!r}rGz,zero has wrong sign: expected {!r}, got {!r}z({!r} and {!r} are not sufficiently close)	rHrIrKrL�isinfrJ�abs�max�
OverflowError)r@�a�b�rel_err�abs_errrM�absolute_errors       r�rAssertAlmostEqualzCMathTests.rAssertAlmostEquales����:�a�=�=�	=��z�!�}�}�
����I�I�c�;�1�8�8��;�;�<�<�<��:�a�=�=�	>��A�v�v����I�I�c�=�0�06��q�!���
>�
>�
>��	3��	3��}�R��#�#�t�}�R��';�';�;�;��	�	�#�2�"%�%+�V�A�q�\�\�3�3�3�
	� ��1��X�X�N���W�g��A���.>�!?�!?�?�?���@���	�	�	��D�	����	
�	�	�#�J�<�C�C�A�q�I�I�	K�	K�	K�	K�	Ks�8D1�1
D>�=D>c	��d}d}|�tj|dd�tj|�����|�tj|dd�tj|�����dS)NgiW�
�@g-DT�!	@�	zcmath.pi is {}; should be {})�placesrMzcmath.e is {}; should be {})�assertAlmostEqualr$rrL�e)r@�
e_expected�pi_expecteds   r�test_constantszCMathTests.test_constants�s���+�
�,�����u�x��Q�.�5�5�e�h��L�L�	�	N�	N�	N����u�w�
�1�-�4�4�U�W�j�I�I�	�	K�	K�	K�	K�	Krc�*�|�tjjtj��|�tjjd��|�tjjd��|�tjjtj��|�t	jtj	j����|�tj	jd��|�tj
jd��|�t	jtj
j����|�ttj��d��|�ttj��d��|�ttj	��d��|�ttj
��d��dS)Nrr�infjr
�nanj)�assertEqualr$rrPrHrQri�
assertTruerIr
rj�reprr?s r�test_infinity_and_nan_constantsz*CMathTests.test_infinity_and_nan_constants�sf����������2�2�2��������-�-�-�������#�.�.�.�������$�(�3�3�3�����
�5�9�>�2�2�3�3�3��������-�-�-�������#�.�.�.�����
�5�:�?�3�3�4�4�4�	
����e�i���%�0�0�0�����e�j�)�)�6�2�2�2�����e�i���%�0�0�0�����e�j�)�)�6�2�2�2�2�2rc
������d�d�dddddt��tg}Gd�dt��}Gd	�d
��}Gd�dt���G�fd
�dt��}G�fd�d��}Gd�dt��}Gd�d��}Gd�d��}Gd�d��}	G��fd�dt��}
G��fd�d��}G�fd�dt��}G�fd�d ��}
|jD�]c}|�||�����|�����|�||�����|�����|�||
����|�����|�||����|�����|�||����|�����|�||
����|�����|�||����|t|��������|�t||����|�t||	����|�t||����|D]L}|�t|||����|�t|||�����M|��||����|��||������edS)!Ny��z�@7Ă?�?g]�ֆ�znot complex���@c��eZdZd�Zd�ZdS)�.CMathTests.test_user_object.<locals>.MyComplexc��||_dSrC��value�r@rws  r�__init__z7CMathTests.test_user_object.<locals>.MyComplex.__init__��
��"��
�
�
rc��|jSrCrvr?s r�__complex__z:CMathTests.test_user_object.<locals>.MyComplex.__complex__��
���z�!rN��__name__�
__module__�__qualname__ryr|rrr�	MyComplexrt��2������
#�
#�
#�
"�
"�
"�
"�
"rr�c��eZdZd�Zd�ZdS)�0CMathTests.test_user_object.<locals>.MyComplexOSc��||_dSrCrvrxs  rryz9CMathTests.test_user_object.<locals>.MyComplexOS.__init__�rzrc��|jSrCrvr?s rr|z<CMathTests.test_user_object.<locals>.MyComplexOS.__complex__�r}rNr~rrr�MyComplexOSr��r�rr�c��eZdZdS)�2CMathTests.test_user_object.<locals>.SomeExceptionN�rr�r�rrr�
SomeExceptionr����������Drr�c���eZdZ�fd�ZdS)�7CMathTests.test_user_object.<locals>.MyComplexExceptionc�����rCr�r@r�s �rr|zCCMathTests.test_user_object.<locals>.MyComplexException.__complex__��	���#�#rN�rr�r�r|�r�s�r�MyComplexExceptionr���.�������
$�
$�
$�
$�
$�
$�
$rr�c���eZdZ�fd�ZdS)�9CMathTests.test_user_object.<locals>.MyComplexExceptionOSc�����rCrr�s �rr|zECMathTests.test_user_object.<locals>.MyComplexExceptionOS.__complex__�r�rNr�r�s�r�MyComplexExceptionOSr��r�rr�c��eZdZdS)�;CMathTests.test_user_object.<locals>.NeitherComplexNorFloatNr�rrr�NeitherComplexNorFloatr��r�rr�c��eZdZdS)�=CMathTests.test_user_object.<locals>.NeitherComplexNorFloatOSNr�rrr�NeitherComplexNorFloatOSr��r�rr�c��eZdZd�Zd�ZdS)�*CMathTests.test_user_object.<locals>.Indexc��dS�N�rr?s r�__int__z2CMathTests.test_user_object.<locals>.Index.__int__����a�arc��dSr�rr?s r�	__index__z4CMathTests.test_user_object.<locals>.Index.__index__�s���rN)rr�r�r�r�rrr�Indexr��s"������'�'�'�)�)�)�)�)rr�c��eZdZd�ZdS)�*CMathTests.test_user_object.<locals>.MyIntc��dSr�rr?s rr�z2CMathTests.test_user_object.<locals>.MyInt.__int__�r�rN)rr�r�r�rrr�MyIntr��s������'�'�'�'�'rr�c�$��eZdZ�fd�Z�fd�ZdS)�4CMathTests.test_user_object.<locals>.FloatAndComplexc����SrCr�r@�flt_args �r�	__float__z>CMathTests.test_user_object.<locals>.FloatAndComplex.__float__������rc����SrCr�r@�cx_args �rr|z@CMathTests.test_user_object.<locals>.FloatAndComplex.__complex__������
rN�rr�r�r�r|�r�r�s��r�FloatAndComplexr���G�������
�
�
�
�
�
�
�
�
�
�
�
rr�c�$��eZdZ�fd�Z�fd�ZdS)�6CMathTests.test_user_object.<locals>.FloatAndComplexOSc����SrCrr�s �rr�z@CMathTests.test_user_object.<locals>.FloatAndComplexOS.__float__�r�rc����SrCrr�s �rr|zBCMathTests.test_user_object.<locals>.FloatAndComplexOS.__complex__�r�rNr�r�s��r�FloatAndComplexOSr��r�rr�c���eZdZ�fd�ZdS)�.CMathTests.test_user_object.<locals>.JustFloatc����SrCrr�s �rr�z8CMathTests.test_user_object.<locals>.JustFloat.__float__�r�rN�rr�r�r��r�s�r�	JustFloatr���.�������
�
�
�
�
�
�
rr�c���eZdZ�fd�ZdS)�0CMathTests.test_user_object.<locals>.JustFloatOSc����SrCrr�s �rr�z:CMathTests.test_user_object.<locals>.JustFloatOS.__float__�r�rNr�r�s�r�JustFloatOSr��r�rr�)�object�NotImplemented�	Exception�test_functionsrk�int�assertRaises�	TypeError)r@�
non_complexesr�r�r�r�r�r�r�r�r�r�r�r��f�bad_complexr�r�r�s                @@@r�test_user_objectzCMathTests.test_user_object�s�����,����'��1�b�$����>�3�
�	"�	"�	"�	"�	"��	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	�	�	�	�	�I�	�	�	�	$�	$�	$�	$�	$�	$�	$��	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�
	�	�	�	�	�V�	�	�	�	�	�	�	�	�	�	�	�	*�	*�	*�	*�	*�	*�	*�	*�	(�	(�	(�	(�	(�	(�	(�	(�
	�	�	�	�	�	�	�	�f�	�	�	�
	�	�	�	�	�	�	�	�	�	�	�
	�	�	�	�	�	�	��	�	�	�	�	�	�	�	�	�	�	�	�	��$�	H�	H�A����Q�Q�y�y��0�0�1�1�1�1�V�9�9�=�=�=����Q�Q�{�{�6�2�2�3�3�Q�Q�v�Y�Y�?�?�?����Q�Q���0�0�1�1�1�1�V�9�9�=�=�=����Q�Q�0�0�2�2�3�3�Q�Q�v�Y�Y�?�?�?����Q�Q�y�y�{�{�^�^�Q�Q�w�Z�Z�8�8�8����Q�Q�{�{�}�}�-�-�q�q��z�z�:�:�:����Q�Q�u�u�w�w�Z�Z���3�u�u�w�w�<�<���9�9�9�
���i��,B�,B�,D�,D�E�E�E����i��E�E�G�G�4�4�4����i��,D�,D�,F�,F�G�G�G�,�
J�
J���!�!�)�Q�	�	�+�0F�0F�G�G�G��!�!�)�Q���K�0H�0H�I�I�I�I����m�Q�0B�0B�0D�0D�E�E�E����m�Q�0D�0D�0F�0F�G�G�G�G�1	H�	Hrc	���|jD]A}dD]<}|�||��||��������=�B|jD]#}dD]}|�t||����$dS)N)r�rr)rZ�long_string�0�1j�)r�rkr�r�r�)r@r��args   r�test_input_typezCMathTests.test_input_types����$�	=�	=�A��
=�
=��� � ���3�����3�=�=�?�?�);�);�<�<�<�<�
=��$�	5�	5�A�:�
5�
5���!�!�)�Q��4�4�4�4�
5�	5�	5rc��gd�}|d�|D��zgd�z}|dgzd�|D��z}dg|z}dg|zd�|D��z}|||||||||||||d�
}|���D]~\}}tt|��}	tt|��}
|D]L}|
|��}|�|	|��|j��|�d|j���M�d	D]e}
|D]`}tj||
��}|�tj||
��|j��|�d|j���a�fdS)
N)g{�G�z�?g�������?g�������?��?g�������?g�G�z��?c��g|]}|��Srr�rrs  rrz6CMathTests.test_cmath_matches_math.<locals>.<listcomp>&s��&?�&?�&?�a��r�&?�&?�&?r)rrG��rGc��g|]}d|z��S)rGrr�s  rrz6CMathTests.test_cmath_matches_math.<locals>.<listcomp>*s��(C�(C�(C�!��A��(C�(C�(Crrc��g|]}|��Srrr�s  rrz6CMathTests.test_cmath_matches_math.<locals>.<listcomp>.s��&<�&<�&<�a��r�&<�&<�&<r)
r&r(r*r,r-r.r/r0r1r2r3r4r5)r�rrg$@)	�itemsr#rHr$r_rPrkrQr/)r@r>�
unit_interval�positive�nonnegative�	real_liner��fn�values�float_fn�
complex_fn�v�z�bases              r�test_cmath_matches_mathz"CMathTests.test_cmath_matches_maths���
7�6�6��$�&?�&?�;�&?�&?�&?�?��M�M��
��"��%�(C�(C�{�(C�(C�(C�C���d�X�o���D�8�O�&<�&<�8�&<�&<�&<�<�	�#�"��������� ���
 �
 ��)�.�.�0�0�	-�	-�J�B���t�R�(�(�H� ���+�+�J��
-�
-���J�q�M�M���'�'������Q�V�<�<�<�� � ��Q�V�,�,�,�,�
-�#�	-�	-�D��
-�
-���I�a��&�&���'�'����D�(9�(9�1�6�B�B�B�� � ��Q�V�,�,�,�,�
-�	-�	-rc�x�dh}d}tjdkr`tj��d}	tt	t
|�d������}n#t$rYnwxYwd�}d�}tt��D�](\}}}}	}
}}t||	��}
t|
|��}|�|dkr||vr�8|dkr|}n|d	kr|}ntt|��}d
|vsd|vrH	||
��}|�
d�||||	����n#t$rY��wxYwd
|vrH	||
��}|�
d�||||	����n#t$rY��wxYw||
��}d|vrNtt!|j��|j��}tt!|j��|j��}d|vrNt|jt!|j����}t|jt!|j����}|dvrd}nd}d�||||	|j|j|j|j��}|�|j|j||���|�|j|j|�����*dS)N�tan0064�darwinr�.c�@�tj|j|j��S)zaWrapped version of rect that accepts a complex number instead of
            two float arguments.)r$r
rPrQ�r�s r�rect_complexz5CMathTests.test_specific_values.<locals>.rect_complex\s���:�a�f�a�f�-�-�-rc�.�tt|���S)zYWrapped version of polar that returns a complex number instead of
            two floats.)rr	r�s r�
polar_complexz6CMathTests.test_specific_values.<locals>.polar_complexas���E�!�H�H�%�%r)�
rqr
r	zdivide-by-zero�invalidz9ValueError not raised in test {}: {}(complex({!r}, {!r}))�overflowz<OverflowError not raised in test {}: {}(complex({!r}, {!r}))zignore-real-signzignore-imag-sign)r/r0rSrTz�{}: {}(complex({!r}, {!r}))
Expected: complex({!r}, {!r})
Received: complex({!r}, {!r})
Received value insufficiently close to expected value.)r]rM)rM)�sys�platform�mac_ver�tuple�mapr��split�
ValueErrorrrrr#r$rKrLrYrWrPrQr_)r@�
SKIP_ON_TIGER�osx_version�version_txtr�r��idr��ar�ai�er�ei�flagsr��expected�function�actual�real_abs_err�
error_messages                   r�test_specific_valueszCMathTests.test_specific_valuesNsq��#��
����<�8�#�#�"�*�,�,�Q�/�K�
�#�C��[�->�->�s�-C�-C�$D�$D�E�E�����
�
�
���
����	.�	.�	.�
	&�	&�	&�
.<�I�-F�-F�=	;�=	;�)�B��B��B��E��"�b�/�/�C��r�2���H��&�;��+@�+@���&�&���V�|�|�'����w���(���"�5�"�-�-���5�(�(�I��,>�,>�P�%�X�c�]�]�F��I�I�8�8>��r�2�r�2�8N�8N�P�P�P�P��"�����H������U�"�"�P�%�X�c�]�]�F��I�I�8�8>��r�2�r�2�8N�8N�P�P�P�P��%�����H������X�c�]�]�F�!�U�*�*� ��V�[�!1�!1�6�;�?�?��"�3�x�}�#5�#5�x�}�E�E��!�U�*�*� ���c�&�+�.>�.>�?�?��"�8�=�#�h�m�2D�2D�E�E���%�%�%�$���%��I��&��R��R��]�H�M��[�&�+�/�/�
�
�#�#�H�M�6�;�0<�,9�
$�
;�
;�
;�
�#�#�H�M�6�;�,9�
$�
;�
;�
;�
;�y=	;�=	;s5�5A&�&
A3�2A3�8D/�/
D<�;D<�E;�;
F�Fc�������fd�}|dd��|dd��|ddtf��|ddtd	zf��|d
dtd	zf��td��}|t|d��|d
f��|t|d��|tf��|td|��|td	zf��|td|��|td	zf��|t||��|tdzf��|t||��|tdzf��|t||��|dtzdzf��|t||��|dtzdzf��td��}|t|d��||f��|td|��||f��|t||��||f��|t||��||f��|t||��||f��|t||��||f��|t||��||f��dS)Nc�v���|��}t||��D]\}}��||���dSrC)�zipr_)r�r�gotrd�g�funcr@s     ��r�checkz%CMathTests.check_polar.<locals>.check�sP����$�s�)�)�C��H�c�*�*�
.�
.���1��'�'��1�-�-�-�-�
.�
.rr)rrrp)rGr���rG��?r�y��g@rr�rq����r
)r�floatr)r@rrrr
s``   r�check_polarzCMathTests.check_polar�s�����	.�	.�	.�	.�	.�	.�	��a�����
��a�����
��b�2�r�(����
��b�2�r�A�v�,����
��c�B���a��=�!�!�!��E�l�l��
��g�c�1�o�o��R�y�)�)�)�
��g�s�d�A����b�	�*�*�*�
��g�a��o�o��R�!�V�}�-�-�-�
��g�a�#�����r�c�A�g��/�/�/�
��g�c�3���#�r�A�v��/�/�/�
��g�c�C�4� � �3���a��.�1�1�1�
��g�s�d�C� � �3��B���
�"3�4�4�4�
��g�s�d�S�D�!�!�C��b��1��#5�6�6�6��E�l�l��
��g�c�1�o�o��S�z�*�*�*�
��g�a��o�o��S�z�*�*�*�
��g�c�3���#�s��,�,�,�
��g�c�3���#�s��,�,�,�
��g�s�d�C� � �3��*�-�-�-�
��g�c�3���#�s��,�,�,�
��g�c�C�4� � �3��*�-�-�-�-�-rc�:�|�t��dSrC)r#r	r?s r�
test_polarzCMathTests.test_polar�s����������rc�d��tjd����fd�}|�|��dS)N�	_testcapic�����d��	t|����d��S#��d��wxYw)N�r)�	set_errnor	)r�r's �r�polar_with_errno_setz9CMathTests.test_polar_errno.<locals>.polar_with_errno_set�sV�������#�#�#�
'��Q�x�x��#�#�A�&�&�&�&��	�#�#�A�&�&�&�&���s	�<�A)r�
import_moduler#)r@r+r's  @r�test_polar_errnozCMathTests.test_polar_errno�sK���"�/��<�<�	�	'�	'�	'�	'�	'�	
���-�.�.�.�.�.rc��
�|�td��d��|�td��d��|�td��t��|�td��t��|�td��t��|�td��tdz��|�td	��tdz��|�tt	dd����d��|�tt	dd
����d
��|�tt	d
d����t��|�tt	d
d
����t��|�tt	t
d
����t��|�tt	t
d����t��|�tt	t
t
����dtz��|�tt	dt
����tdz��|�tt	d
t
����tdz��|�tt	dt
����tdz��|�tt	d
t
����tdz��|�tt	t
t
����tdz��|�tt	t
d����d
��|�tt	t
d
����d
��|�tt	t
d����d��|�tt	t
d
����d��|�tt	t
t
����tdz��|�tt	d
t
����tdz��|�tt	dt
����tdz��|�tt	d
t
����tdz��|�tt	dt
����tdz��|�tt	t
t
����dtz��|�tt	t
d
����t��|�tt	t
d����t��tD]6}|�tj	t|�������7dS)NrrrGr�y�Y��n�y�Y��n��rr�y��rrg�rr g�?)
rcrrrkr�INF�complex_nansrlrHrI�r@r�s  r�
test_phasezCMathTests.test_phase�s2�����u�Q�x�x��,�,�,����u�R�y�y�"�-�-�-����u�S�z�z�2�.�.�.����u�[�1�1�2�6�6�6����u�[�1�1�B�3�7�7�7����u�R�y�y�"�Q�$�/�/�/����u�S�z�z�B�3�q�5�1�1�1�	
����w�s�C�0�0�1�1�3�7�7�7�����w�s�D�1�1�2�2�D�9�9�9�����w�t�S�1�1�2�2�B�7�7�7�����w�t�T�2�2�3�3�b�S�9�9�9�	
���u�W�c�T�4�%8�%8�9�9�B�3�?�?�?����u�W�c�T�4�%8�%8�9�9�B�3�?�?�?����u�W�c�T�C�4�%8�%8�9�9�5��8�D�D�D����u�W�T�C�4�%8�%8�9�9�B�3�q�5�A�A�A����u�W�T�C�4�%8�%8�9�9�B�3�q�5�A�A�A����u�W�S�3�$�%7�%7�8�8�2�#�a�%�@�@�@����u�W�S�3�$�%7�%7�8�8�2�#�a�%�@�@�@����u�W�S�3�$�%7�%7�8�8�2�#�a�%�@�@�@�����w�s�D�1�1�2�2�D�9�9�9�����w�s�D�1�1�2�2�D�9�9�9�����w�s�C�0�0�1�1�3�7�7�7�����w�s�C�0�0�1�1�3�7�7�7����u�W�S�#�%6�%6�7�7��A��>�>�>����u�W�S�#�%6�%6�7�7��A��>�>�>����u�W�S�#�%6�%6�7�7��A��>�>�>����u�W�T�3�%7�%7�8�8�"�Q�$�?�?�?����u�W�T�3�%7�%7�8�8�"�Q�$�?�?�?����u�W�c�T�3�%7�%7�8�8�$�r�'�B�B�B����u�W�c�T�3�%7�%7�8�8�"�=�=�=����u�W�c�T�3�%7�%7�8�8�"�=�=�=��	2�	2�A��O�O�D�J�u�Q�x�x�0�0�1�1�1�1�	2�	2rc
���tD]%}|�t|��d���&tD]*}|�t|��t���+|�tttt����t��|�tj	tttd��������|�tj	tttd��������|�tj	tttd��������|�tj	tttd��������|�tttt����t��|�tttt����t��|�tj	ttdt��������|�tj	ttdt��������|�tj	ttdt��������|�tj	ttdt��������|�tttt����t��|�tj	tttt��������dS)Nrrrr)
�
complex_zerosrkrW�complex_infinitiesr/r�NANrlrHrIr1s  r�test_abszCMathTests.test_abs�s����	*�	*�A����S��V�V�S�)�)�)�)�$�	*�	*�A����S��V�V�S�)�)�)�)�	
����W�S�3�$�/�/�0�0�#�6�6�6�����
�3�w�s�D�'9�'9�#:�#:�;�;�<�<�<�����
�3�w�s�D�'9�'9�#:�#:�;�;�<�<�<�����
�3�w�s�C�'8�'8�#9�#9�:�:�;�;�;�����
�3�w�s�C�'8�'8�#9�#9�:�:�;�;�;�����W�S�#�.�.�/�/��5�5�5�����W�c�T�3�/�/�0�0�#�6�6�6�����
�3�w�t�S�'9�'9�#:�#:�;�;�<�<�<�����
�3�w�t�S�'9�'9�#:�#:�;�;�<�<�<�����
�3�w�s�C�'8�'8�#9�#9�:�:�;�;�;�����
�3�w�s�C�'8�'8�#9�#9�:�:�;�;�;�����W�S�#�.�.�/�/��5�5�5�����
�3�w�s�C�'8�'8�#9�#9�:�:�;�;�;�;�;rc�d�|�tttdd����dS)Ng��U���)r�rYrWrr?s r�test_abs_overflowszCMathTests.test_abs_overflowss,��	
���-��g�g�w�.G�.G�H�H�H�H�Hrc��d}t|j|dz
��|ks!t|j|dz
��|kr|�||f��dSdS)NgH�����z>rrp)rWrPrQrK)r@rZr[�epss    r�assertCEqualzCMathTests.assertCEqualse�����q�v��!��}����#�#�s�1�6�A�a�D�=�'9�'9�C�'?�'?��I�I�q�!�f������(@�'?rc��|�tdd��d��|�tdd��d��|�tdt��d��|�tdtdz��d��|�tdtdz��d��dS)	Nr)rrrp)rGr)r�rr�)rrG)rr�)r<r
rr?s r�	test_rectzCMathTests.test_rects������$�q�!�*�*�f�-�-�-����$�q�!�*�*�g�.�.�.����$�q�2�#�,�,��1�1�1����$�q�"�Q�$�-�-��1�1�1����$�q�2�#�a�%�.�.�(�3�3�3�3�3rc	�6�td��ddddtd��td��g}|D]e}|D]`}t||��}|�tj|��tj|��otj|�����a�fdS)Nz-infrrrrrr
)r"rrkr$�isfiniterH)r@�	real_valsrrr�s     r�
test_isfinitezCMathTests.test_isfinite#s����6�]�]�D�$��#�u�U�|�|�U�5�\�\�;�	��	I�	I�A��
I�
I���A�q�M�M��� � ����!2�!2�"&�-��"2�"2�"G�t�}�Q�7G�7G�I�I�I�I�
I�	I�	Irc��|�tjd����|�tjd����|�tjt����|�tjt
����|�tjt
t
d������|�tjt
dt
������|�tjt
t
t
������|�tjt
t
t������|�tjt
tt
������dS�Nrprr)�assertFalser$rIr/rlr6rr?s r�
test_isnanzCMathTests.test_isnan,�4�������Q���(�(�(������R���)�)�)������S�)�)�*�*�*������C�(�(�)�)�)������G�C��O�O�4�4�5�5�5������G�A�s�O�O�4�4�5�5�5������G�C��$5�$5�6�6�7�7�7������G�C��$5�$5�6�6�7�7�7������G�C��$5�$5�6�6�7�7�7�7�7rc��|�tjd����|�tjd����|�tjt����|�tjt
����|�tjt
t
d������|�tjt
dt
������|�tjt
t
t
������|�tjt
tt
������|�tjt
t
t������dSrD)rEr$rVr6rlr/rr?s r�
test_isinfzCMathTests.test_isinf7rGrc�j�tD]*}|�tj|��|���+dSrC)r4rRr$r5r1s  r�testTanhSignzCMathTests.testTanhSignB�<���	:�	:�A��'�'��
�1�
�
�q�9�9�9�9�	:�	:rc�j�tD]*}|�tj|��|���+dSrC)r4rRr$r*r1s  r�testAtanSignzCMathTests.testAtanSignKrLrc�j�tD]*}|�tj|��|���+dSrC)r4rRr$r+r1s  r�
testAtanhSignzCMathTests.testAtanhSignPs<���	;�	;�A��'�'���A����:�:�:�:�	;�	;r)rSrTN) rr�r�r��appendrArErNrRr_rgrnr�r�r�rrr#r%rr-r2r7r9r<r>rBrFrIrKrNrPrrrr!r!4sT������$�$�:#�$�$�$�N�
���=�=�>�>�>����:�:�;�;�;�=�=�=�!�!�!�$�$�$�.2�2�2�CI�#�0K�0K�0K�0K�dK�K�K�3�3�3�"`H�`H�`H�D
5�
5�
5�.-�.-�.-�`�T;�T;���T;�l.�.�.�8 � � ��	/�	/��\�	/�'2�'2�'2�R<�<�<�2�I�I���I����
4�4�4�I�I�I�	8�	8�	8�	8�	8�	8��:�:���:��:�:���:��;�;���;�;�;rr!c�.�eZdZejZd�Zd�Zd�ZdS)�IsCloseTestsc���|�t��5|�ddd���ddd��n#1swxYwY|�t��5|�ddd���ddd��n#1swxYwY|�t��5|�dddd���ddd��dS#1swxYwYdS)Nr��rel_tol��abs_tol)rVrX)r�r��iscloser?s r�test_reject_complex_tolerancesz+IsCloseTests.test_reject_complex_tolerancesYs���
�
�
�y�
)�
)�	-�	-��L�L��R��L�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-��
�
�y�
)�
)�	-�	-��L�L��R��L�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-��
�
�y�
)�
)�	9�	9��L�L��R��R�L�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9�	9�	9s5�A�A�A�%B
�
B�B�/C�C�Cc�j�gd�}|�|d���|�|d���dS)N))��?�?y��?�?)r\y�?��?)y��?y���?)y�?�y�?������g�-���q=rUg�vIh�%<=)�assertAllClose�assertAllNotClose)r@�complex_exampless  r�test_complex_valuesz IsCloseTests.test_complex_valuescsP������	
���,�e��<�<�<����/���?�?�?�?�?rc���gd�}|�|d���|�|d���|�ddd���|�ddd���dS)	N))y����MbP?r)���MbP?r)�����MbP?����MbP?r)y����MbP�����MbP?r)�����MbP?����MbP�r)y����MbP�����MbP�rg�~j�t�X?rWg����Mb@?rdrcg����Mb`?rb)r]r^�
assertIsClose�assertIsNotClose)r@�near_zero_exampless  r�test_complex_near_zeroz#IsCloseTests.test_complex_near_zerons��� � � ��	
���.���@�@�@����1�7��C�C�C����<��u��E�E�E����l�L�%��H�H�H�H�HrN)rr�r�r$rYrZr`rhrrrrSrSVsP�������m�G�9�9�9�	@�	@�	@�I�I�I�I�IrrS�__main__)�test.supportrrr�test.test_mathrr�	test_math�unittestr$rHrr	r
rrrr"r/r6r4r5r0�TestCaser!rSr�mainrrr�<module>rps���G�G�G�G�G�G�G�G�G�G�4�4�4�4�4�4�4�4�"�"�"�"�"�"�������������(�(�(�(�(�(�(�(�(�(�(�(�����
�
�
�
��e�E�l�l���e�E�l�l��I�I��I�I�I�
���	�c�
�	�c�
�	�c�
�	�c�
�	�c�
�	
�s��	
�s��

��s��

��s��

��s��

��t��

��t��

���t��	
��t��	
��t��	�s�d��	�s�d��	�s�d��	�d��	�d��)1
�����,
�
�	�s�d��	�d��	�d��	�c�
�	�c�
�	�c�
�

��s��	
�s��	
�s��	�c�
�	�c�
�	�c�
�
+
�
�
�
��_;�_;�_;�_;�_;��"�_;�_;�_;�D&I�&I�&I�&I�&I�9�)�&I�&I�&I�R�z����H�M�O�O�O�O�O��r