Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
testutils.cpython-313.pyc117 linesDownload Raw Back to __pycache__
1�

2z�j)��4�SrSSKrSSKrSSKJs Jr SSKrSSKJr SSKJ	r	J3r4JrJrJ
r
 SSKJrJrJrJrJrJr /SQrSSKJr /S	Qr\\-rSS5jrSSjrSSjrS
rSSjrSSjr\r SSjr!\!r"SSjr#SSjr$SSjr%SSjr&SSjr'SSjr(SSjr)g)z�Miscellaneous functions for testing masked arrays and subclasses6 7:author: Pierre Gerard-Marchant8:contact: pierregm_at_uga_dot_edu9 10�N)�ndarray)�assert_�assert_allclose�assert_array_almost_equal_nulp�
assert_raises�
build_err_msg�)�filled�getmask�mask_or�masked�masked_array�nomask)�almost�approx�assert_almost_equal�assert_array_almost_equal�assert_array_approx_equal�assert_array_compare�assert_array_equal�assert_array_less�assert_close�assert_equal�assert_equal_records�assert_mask_equal�assert_not_equal�fail_if_array_equal)�TestCase)rrrrrc��[[U5[U55n[U5n[U5nURRS:XdURRS:Xa$[11R"Xg5R5$[[USUS9U5R[12R5n[[USUS9S5R[13R5n	[14R"[R"X�-155XC[R"U	5--5n16U17R5$)aj18Returns true if all components of a and b are equal to given tolerances.19 20If fill_value is True, masked values considered equal. Otherwise,21masked values are considered unequal.  The relative error rtol should22be positive and << 1.0 The absolute error atol comes into play for23those elements of b that are very small or zero; it says how small a24must be also.25 26�OF��copy�maskr	)rrr27�dtype�char�np�equal�ravelr�astype�float64�28less_equal�umath�absolute)�a�b�29fill_value�rtol�atol�m�d1�d2�x�y�ds           �XD:\code\apps\devtools\python\user_packages\Python313\site-packages\numpy/ma/testutils.pyrr-s���	���30�G�A�J�'�A�	���B�	���B�	�x�x�}�}���r�x�x�}�}��3��x�x���%�%�'�'���R�e�!�,�j�	��f�R�Z�Z���	�|�B�U��3�Q�7�>�>�r�z�z�J�A�31�
�
�e�n�n�Q�U�+�T�5�>�>�!�;L�4L�-L�M�A��7�7�9��c�j�[[U5[U55n[U5n[U5nURRS:XdURRS:Xa$[32R"XV5R5$[[USUS9U5R[33R5n[[USUS9S5R[34R5n[35R"[36R"Xx-375U5SU*-:*n	U	R5$)z�38Returns True if a and b are equal up to decimal places.39 40If fill_value is True, masked values considered equal. Otherwise,41masked values are considered unequal.42 43r Fr!r	�$@)
rrr44r$r%r&r'r(rr)r*�around�abs)45r.r/�decimalr0r3r4r5r6r7r8s46          r9rrEs���	���47�G�A�J�'�A�	���B�	���B�	�x�x�}�}���r�x�x�}�}��3��x�x���%�%�'�'���R�e�!�,�j�	��f�R�Z�Z���	�|�B�U��3�Q�7�>�>�r�z�z�J�A�48�	�	�"�&�&���-��)�T�w�h�-?�?�A��7�7�9�r:c	��[[U5[U5U5 [[U55Hn[XXSU<SU35 M g)z349Asserts the equality of two non-array sequences.50 51�item=�52N)r�len�range)�actual�desired�err_msg�ks    r9�_assert_equal_on_sequencesrIZsH��53��V��c�'�l�G�4�
�3�w�<�
 ���V�Y��54�e�A�5��7�)�,D�E�!r:c�h�[URUR5 URRHxn[R"X5[R"X5pCU[55LdM9U[56LdMD[[R"X5[R"X55 Mz g)z=57Asserts that two records are equal.58 59Pretty crude for now.60 61N)rr$�names�operator�getitemr
)r.r/�f�af�bfs     r9rrdsr������!�'�'�"�
�W�W�]�]���$�$�Q�*�H�,<�,<�Q�,B�R��f��r�V�|���)�)�!�/��1A�1A�!�1G�H�r:c	���[U[5(a�[U[5(d[[[	U555e[[
U5[
U5U5 UH0nX0;a[USU35e[XXSU<SU35 M2 g[U[[45(a%[U[[45(a62[XSS9$[U[5(d3[U[5(d[X/U5nX:Xd[U5egU[La	U[LdU[La!U[La[X/USSS9n[U5e[R"U5n[R"U5nUR UR peUR"S	:Xa7UR"S	:Xa'[UR%5UR%5SS9$['XU5$)63z$64Asserts that two items are equal.65 66z not in �key=rBN��rG�r6r7)�headerrK�S)�67isinstance�dict�AssertionError�repr�typerrC�list�tuplerIrrr
�68ValueErrorr&�69asanyarrayr$r%�tolistr)rErFrGrH�msg�actual_dtype�
desired_dtypes       r9rrrs����'�4� � ��&�$�'�'� ��d�6�l�!3�4�4��S��[�#�g�,��8��A���$��s�(�6�(�%;�<�<����G�J�$�q�e�2�g�Y�0G�H��	��'�D�%�=�)�)�j��$���.O�.O�)�&�2�F�F��v�w�'�'�:�g�w�+G�+G��V�-�w�8��� � ��%�%��	�6�	�G�v�$5����&�F�*:��V�-�#�B�j�B����o��
�]�]�6�
"�F��m�m�G�$�G�%+�\�\�7�=�=�=����C��M�$6�$6�#�$=�)�&�-�-�/�*1�.�.�*:�24�6�	6��f�w�7�7r:c	�&�[U[5(a�[U[5(d[[[	U555e[[
U5[
U5U5 UH4nX0;a[[U55e[XXSU<SU35 M6 g[U[[45(an[U[[45(aS[[
U5[
U5U5 [[
U55Hn[XXSU<SU35 M g[U[R5(d[U[R5(a[XU5$[X/U5nX:wd[U5eg)z470Raises an assertion error if two items are equal.71 72rRrBNrA)rXrYrZr[r\�
fail_if_equalrCr]r^rDr&rrr)rErFrGrHrbs     r9rfrf�sA��73�'�4� � ��&�$�'�'� ��d�6�l�!3�4�4��c�&�k�3�w�<��9��A���$�T�!�W�-�-��&�)�W�Z�4��u�B�w�i�1H�I��	��'�D�%�=�)�)�j��$���.O�.O��c�&�k�3�w�<��9��s�7�|�$�A��&�)�W�Z�5���R��y�1I�J�%���&�"�*�*�%�%��G�R�Z�Z�)H�)H�"�6�G�<�<�74��)�7�753�C����S�!�!�r:c���[U[R5(d[U[R5(a[XUX4S9$[	X/X4S9n[[
X-765U5S:Xd[U5eg)zr77Asserts that two items are almost equal.78 79The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal).80 81)r?rG�verbose)rGrhrN)rXr&rrr�roundr>rZ)rErFr?rGrhrbs      r9rr�st���&�"�*�*�%�%��G�R�Z�Z�)H�)H�(��'�18�K�	K�82��)� '�:�C���W�%�&��0�A�5��S�!�!�6r:c	�h�[[U5[U55n[USUSSS9n[USUSSS9nU[La	U[LdU[La!U[La[	X/X4USS9n[U5e[RRUURU5URU5UXES9$)zb83Asserts that comparison between two masked arrays is satisfied.84 85The comparison is elementwise.86 87F)r"r#�	keep_mask�subokrU)rGrhrVrK�rGrhrV)88rrrr
rr_r&�testingrr89)	�90comparisonr6r7rGrhrVr0r3rbs	         r9rr�s���	���91�G�A�J�'�A��Q�U��e�5�I�A��Q�U��e�5�I�A�	92�f��q�F�{��6�k�A��K��Q�F�G�#)��=����o��
�:�:�*�*�:�+,�8�8�J�+?�+,�8�8�J�+?�3:�3:�	+�K�Kr:c	�8�[[RXX#SS9 g)z893Checks the elementwise equality of two masked arrays.94 95�Arrays are not equalrmN)rrL�__eq__�r6r7rGrhs    r9rr�s��96����!�!(� 6�8r:c	�"�Sn[X@XUSS9 g)zL97Raises an assertion error if two masked arrays are not equal elementwise.98 99c�J�[R"[X55(+$)N)r&�allrrUs  r9�compare�$fail_if_array_equal.<locals>.compare�s���F�F�6�!�<�(�(�)r:rqrmN�r)r6r7rGrhrws     r9rr�s��100*���Q�� 6�8r:c	�*^�U4Sjn[XPXUSS9 g)�p101Checks the equality of two masked arrays, up to given number odecimals.102 103The equality is checked elementwise.104 105c� >�[XST*-S9$)�<Returns the result of the loose comparison between x and y).r<)r1)r�r6r7r?s  �r9rw�*assert_array_approx_equal.<locals>.compare�s����a�����1�1r:�Arrays are not almost equalrmNry�r6r7r?rGrhrws  `   r9rr�s���2���Q�� =�?r:c	�*^�U4Sjn[XPXUSS9 g)r{c�>�[XT5$)r})rr~s  �r9rw�*assert_array_almost_equal.<locals>.compares����a�G�$�$r:r�rmNryr�s  `   r9rrs���%���Q�� =�?r:c	�8�[[RXX#SS9 g)z/106Checks that x is smaller than y elementwise.107 108zArrays are not less-orderedrmN)rrL�__lt__rss    r9rrs��109����!�!(� =�?r:c��U[La[U[L5 U[La[U[L5 [XUS9 g)z%110Asserts the equality of two masks.111 112rTN)rrr)�m1�m2rGs   r9rrs4��113114�V�|���f���	�V�|���f����r�w�/r:)Tg�h㈵��>g:�0�yE>)�T)rS)�rST)rSTrST)rST)r�rST)*�__doc__rL�numpyr&�numpy._core.umath�_corer,�
numpy.testingrrrrrr�corer115rrr
rr�
__all__masked�unittestr�__some__from_testing�__all__rrrIrrrfrrrrrrrrrr�r:r9�<module>r�s������!�!�����I�H��
����116�.�117.���0�*F�I�$8�N"�4!��
"� #��MO�$(�K�28�8�?�?�?�	0r:
codekingpro/portable-devtools · Team Ai