Ë
    ¡eh (  ã                   ó  — d Z ddlZddlZddlmZ ddlmc mZ ddlZddlm	Z	m
Z
mZmZmZ ddlmZmZmZmZmZmZ g d¢ZddlmZ g d	¢Zeez   Zdd
„Zdd„Zdd„Zd„ Zdd„Zdd„ZeZ dd„Z!e!Z"	 	 dd„Z#dd„Z$dd„Z%dd„Z&dd„Z'dd„Z(dd„Z)y)zÌMiscellaneous functions for testing masked arrays and subclasses

:author: Pierre Gerard-Marchant
:contact: pierregm_at_uga_dot_edu
:version: $Id: testutils.py 3529 2007-11-13 08:01:14Z jarrod.millman $

é    N)Úndarray)Úassert_Úassert_allcloseÚassert_array_almost_equal_nulpÚassert_raisesÚbuild_err_msgé   )Úmask_orÚgetmaskÚmasked_arrayÚnomaskÚmaskedÚfilled)Ú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)r   r   r   r   r   c                 ó”  — t        t        | «      t        |«      «      }t        | «      }t        |«      }|j                  j                  dk(  s|j                  j                  dk(  r$t        j                  ||«      j                  «       S t        t        |d|¬«      |«      j                  t
        j                  «      }t        t        |d|¬«      d«      j                  t
        j                  «      }	t        j                  t        j                  ||	z
  «      ||t        j                  |	«      z  z   «      }
|
j                  «       S )a†  
    Returns true if all components of a and b are equal to given tolerances.

    If fill_value is True, masked values considered equal. Otherwise,
    masked values are considered unequal.  The relative error rtol should
    be positive and << 1.0 The absolute error atol comes into play for
    those elements of b that are very small or zero; it says how small a
    must be also.

    ÚOF©ÚcopyÚmaskr	   )r
   r   r   ÚdtypeÚcharÚnpÚequalÚravelr   ÚastypeÚfloat64Ú
less_equalÚumathÚabsolute)ÚaÚbÚ
fill_valueÚrtolÚatolÚmÚd1Úd2ÚxÚyÚds              úP/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/numpy/ma/testutils.pyr   r   )   sî   € ô 	”˜“
œG A›JÓ'€AÜ	�‹€BÜ	�‹€BØ	‡x�x‡}�}˜Ò˜rŸx™xŸ}™}°Ò3Ü�x‰x˜˜BÓ×%Ñ%Ó'Ð'ÜÜ�R˜e¨!Ô,¨jó	ç�fŒR�Z‰ZÓð ô 	Œ|˜B U°Ô3°QÓ7×>Ñ>¼r¿z¹zÓJ€AÜ
�‰”e—n‘n Q¨¡UÓ+¨T°D¼5¿>¹>È!Ó;LÑ4LÑ-LÓM€AØ�7‰7‹9Ðó    c                 óp  — t        t        | «      t        |«      «      }t        | «      }t        |«      }|j                  j                  dk(  s|j                  j                  dk(  r$t        j                  ||«      j                  «       S t        t        |d|¬«      |«      j                  t
        j                  «      }t        t        |d|¬«      d«      j                  t
        j                  «      }t        j                  t        j                  ||z
  «      |«      d| z  k  }	|	j                  «       S )z³
    Returns True if a and b are equal up to decimal places.

    If fill_value is True, masked values considered equal. Otherwise,
    masked values are considered unequal.

    r    Fr!   r	   ç      $@)r
   r   r   r$   r%   r&   r'   r(   r   r)   r*   ÚaroundÚabs)
r.   r/   Údecimalr0   r3   r4   r5   r6   r7   r8   s
             r9   r   r   A   sæ   € ô 	”˜“
œG A›JÓ'€AÜ	�‹€BÜ	�‹€BØ	‡x�x‡}�}˜Ò˜rŸx™xŸ}™}°Ò3Ü�x‰x˜˜BÓ×%Ñ%Ó'Ð'ÜÜ�R˜e¨!Ô,¨jó	ç�fŒR�Z‰ZÓð ô 	Œ|˜B U°Ô3°QÓ7×>Ñ>¼r¿z¹zÓJ€AÜ
�	‰	”"—&‘&˜˜Q™“- Ó)¨T°w°hÑ-?Ñ?€AØ�7‰7‹9Ðr:   c           	      ó¦   — t        t        | «      t        |«      |«       t        t        |«      «      D ]  }t        | |   ||   d|›d|› �«       Œ y)z;
    Asserts the equality of two non-array sequences.

    úitem=ú
N)r   ÚlenÚrange)ÚactualÚdesiredÚerr_msgÚks       r9   Ú_assert_equal_on_sequencesrI   V   sV   € ô
 ”�V“œc '›l¨GÔ4Ü”3�w“<Ó ò FˆÜ�V˜A‘Y ¨¡
¨e°A°5¸¸7¸)Ð,DÕEðFà
r:   c                 ó^  — t        | j                  |j                  «       | j                  j                  D ]t  }t        j                  | |«      t        j                  ||«      }}|t
        usŒ8|t
        usŒAt        t        j                  | |«      t        j                  ||«      «       Œv y)zI
    Asserts that two records are equal.

    Pretty crude for now.

    N)r   r$   ÚnamesÚoperatorÚgetitemr   )r.   r/   ÚfÚafÚbfs        r9   r   r   a   sˆ   € ô �—‘˜!Ÿ'™'Ô"Ø�W‰W�]‰]ò IˆÜ×$Ñ$ Q¨Ó*¬H×,<Ñ,<¸QÀÓ,BˆRˆØ”f’ r¬V¢|Üœ×)Ñ)¨!¨QÓ/´×1AÑ1AÀ!ÀQÓ1GÕHðIð r:   c           	      óÞ  — t        |t        «      r’t        | t        «      st        t        t	        | «      «      «      ‚t        t        | «      t        |«      |«       |j                  «       D ]2  \  }}|| vrt        |› d| › �«      ‚t        | |   ||   d|›d|› �«       Œ4 yt        |t        t        f«      r$t        | t        t        f«      rt        | |d¬«      S t        | t        «      s/t        |t        «      st        | |g|«      }|| k(  st        |«      ‚y| t        u r|t        us|t        u r$| t        urt        | |g|dd¬«      }t        |«      ‚t        j                   | «      } t        j                   |«      }| j"                  |j"                  }}|j$                  d	k(  r9|j$                  d	k(  r*t        | j'                  «       |j'                  «       d¬«      S t)        | ||«      S )
z,
    Asserts that two items are equal.

    z not in úkey=rB   NÚ ©rG   ©r6   r7   )ÚheaderrK   ÚS)Ú
isinstanceÚdictÚAssertionErrorÚreprÚtyper   rC   ÚitemsÚlistÚtuplerI   r   r   r   Ú
ValueErrorr&   Ú
asanyarrayr$   r%   Útolistr   )rE   rF   rG   rH   ÚiÚmsgÚactual_dtypeÚdesired_dtypes           r9   r   r   p   s¾  € ô �'œ4Ô Ü˜&¤$Ô'Ü ¤¤d¨6£lÓ!3Ó4Ð4Ü”S˜“[¤# g£,°Ô8Ø—M‘M“Oò 	I‰DˆAˆqØ˜‰Ü$¨ s¨(°6°(Ð%;Ó<Ð<Ü˜ ™ G¨A¡J°$°q°e¸2¸g¸YÐ0GÕHð	Ið 	ä�'œD¤%˜=Ô)¬j¸Ä$ÌÀÔ.OÜ)¨&°'À2ÔFÐFÜ�vœwÔ'¬:°g¼wÔ+GÜ˜V WÐ-¨wÓ8ˆØ˜&Ò Ü  Ó%Ð%Øà	”6Ñ	 G¬vÑ$5ØœÑ¨&´FÑ*:Ü˜V WÐ-Ø#¨B°jôBˆä˜‹oÐÜ�]‰]˜6Ó"€FÜ�m‰m˜GÓ$€GØ%+§\¡\°7·=±=�=€\Ø×Ñ˜CÒ M×$6Ñ$6¸#Ò$=Ü)¨&¯-©-«/Ø*1¯.©.Ó*:Ø24ô6ð 	6ô ˜f g¨wÓ7Ð7r:   c           	      ó
  — t        |t        «      r–t        | t        «      st        t        t	        | «      «      «      ‚t        t        | «      t        |«      |«       |j                  «       D ]6  \  }}|| vrt        t        |«      «      ‚t        | |   ||   d|›d|› �«       Œ8 yt        |t        t        f«      rht        | t        t        f«      rRt        t        | «      t        |«      |«       t        t        |«      «      D ]  }t        | |   ||   d|›d|› �«       Œ yt        | t        j                  «      st        |t        j                  «      rt        | ||«      S t        | |g|«      }|| k7  st        |«      ‚y)z<
    Raises an assertion error if two items are equal.

    rR   rB   NrA   )rX   rY   rZ   r[   r\   Úfail_if_equalrC   r]   r^   r_   rD   r&   r   r   r   )rE   rF   rG   rH   rc   rd   s         r9   rh   rh   —   sW  € ô
 �'œ4Ô Ü˜&¤$Ô'Ü ¤¤d¨6£lÓ!3Ó4Ð4Ü”c˜&“k¤3 w£<°Ô9Ø—M‘M“Oò 	J‰DˆAˆqØ˜‰Ü$¤T¨!£WÓ-Ð-Ü˜& ™) W¨Q¡Z°4¸°u¸B¸w¸iÐ1HÕIð	Jð 	Ü�'œD¤%˜=Ô)¬j¸Ä$ÌÀÔ.OÜ”c˜&“k¤3 w£<°Ô9Ü”s˜7“|Ó$ò 	KˆAÜ˜& ™) W¨Q¡Z°5¸¸¸RÀ¸yÐ1IÕJð	KàÜ�&œ"Ÿ*™*Ô%¬°G¼R¿Z¹ZÔ)HÜ" 6¨7°GÓ<Ð<Ü
˜ Ð)¨7Ó
3€CØ�fÒÜ˜SÓ!Ð!ð r:   c                 óø   — t        | t        j                  «      st        |t        j                  «      rt        | ||||¬«      S t	        | |g||¬«      }t        t        || z
  «      |«      dk(  st        |«      ‚y)z~
    Asserts that two items are almost equal.

    The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal).

    )r?   rG   Úverbose)rG   rj   r   N)rX   r&   r   r   r   Úroundr>   rZ   )rE   rF   r?   rG   rj   rd   s         r9   r   r   ´   sx   € ô �&œ"Ÿ*™*Ô%¬°G¼R¿Z¹ZÔ)HÜ(¨°À'Ø18À'ôKð 	Kä
˜ Ð)Ø '°ô:€Cä”�W˜vÑ%Ó&¨Ó0°AÒ5Ü˜SÓ!Ð!ð 6r:   c                 ó~  — t        t        |«      t        |«      «      }t        |d|dd¬«      }t        |d|dd¬«      }|t        u r|t        us|t        u r%|t        urt	        ||g|||d¬«      }t        |«      ‚t        j                  j                  | |j                  |«      |j                  |«      |||¬«      S )zn
    Asserts that comparison between two masked arrays is satisfied.

    The comparison is elementwise.

    F)r"   r#   Ú	keep_maskÚsubokrU   )rG   rj   rV   rK   ©rG   rj   rV   )
r
   r   r   r   r   r`   r&   Útestingr   r   )	Ú
comparisonr6   r7   rG   rj   rV   r0   r3   rd   s	            r9   r   r   Ç   s¹   € ô 	”˜“
œG A›JÓ'€AÜ�Q˜U¨°eÀ5ÔI€AÜ�Q˜U¨°eÀ5ÔI€AØ	
Œf‰˜q¤F™{Ø”6‰k A¬¡KÜ˜Q ˜F¨G¸WØ#)°ô=ˆä˜‹oÐä�:‰:×*Ñ*¨:Ø+,¯8©8°JÓ+?Ø+,¯8©8°JÓ+?Ø3:Ø3:À6ð	 +ó Kð Kr:   c                 óB   — t        t        j                  | |||d¬«       y)z@
    Checks the elementwise equality of two masked arrays.

    úArrays are not equalro   N)r   rL   Ú__eq__©r6   r7   rG   rj   s       r9   r   r   à   s   € ô
 œŸ™¨!¨QØ!(°'Ø 6ö8r:   c                 ó,   — d„ }t        || |||d¬«       y)zT
    Raises an assertion error if two masked arrays are not equal elementwise.

    c                 óB   — t        j                  t        | |«      «       S )N)r&   Úallr   rU   s     r9   Úcomparez$fail_if_array_equal.<locals>.compareï   s   € Ü—F‘Fœ6 ! Q›<Ó(Ð(Ð)r:   rs   ro   N©r   )r6   r7   rG   rj   ry   s        r9   r   r   ê   s   € ò
*ä˜ ! Q°ÀØ 6ö8r:   c                 ó2   ‡— ˆfd„}t        || |||d¬«       y)ú|
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    c                 ó(   •— t        | |d‰ z  ¬«      S )ú<Returns the result of the loose comparison between x and y).r<   )r1   )r   ©r6   r7   r?   s     €r9   ry   z*assert_array_approx_equal.<locals>.compareü   s   ø€ ä�a˜ ¨¨¡Ô1Ð1r:   úArrays are not almost equalro   Nrz   ©r6   r7   r?   rG   rj   ry   s     `   r9   r   r   õ   s   ø€ ô2ô ˜ ! Q°ÀØ =ö?r:   c                 ó2   ‡— ˆfd„}t        || |||d¬«       y)r|   c                 ó   •— t        | |‰«      S )r~   )r   r   s     €r9   ry   z*assert_array_almost_equal.<locals>.compare
  s   ø€ ä�a˜˜GÓ$Ð$r:   r€   ro   Nrz   r�   s     `   r9   r   r     s   ø€ ô%ô ˜ ! Q°ÀØ =ö?r:   c                 óB   — t        t        j                  | |||d¬«       y)z7
    Checks that x is smaller than y elementwise.

    zArrays are not less-orderedro   N)r   rL   Ú__lt__ru   s       r9   r   r     s   € ô
 œŸ™¨!¨QØ!(°'Ø =ö?r:   c                 ó„   — | t         u rt        |t         u «       |t         u rt        | t         u «       t        | ||¬«       y)z-
    Asserts the equality of two masks.

    rT   N)r   r   r   )Úm1Úm2rG   s      r9   r   r     s6   € ð
 
ŒV�|Ü�”f�ÔØ	ŒV�|Ü�”f�ÔÜ�r˜2 wÖ/r:   )Tgñhãˆµøä>g:Œ0âŽyE>)é   T)rS   )é   rS   T)rS   TrS   T)rS   T)r‰   rS   T)*Ú__doc__rL   Únumpyr&   r   Únumpy._core.umathÚ_corer,   Únumpy.testingr   r   r   r   r   Úcorer
   r   r   r   r   r   Ú__all__maskedÚunittestr   Ú__some__from_testingÚ__all__r   r   rI   r   r   rh   r   r   r   r   r   r   r   r   r   r   © r:   r9   ú<module>r–      s³   ðñó ã Ý ß !Ð !Û ÷õ ÷ I× Hò€õ òÐ ð
 Ð.Ñ
.€óó0ó*òó$8óN"ð4 !Ð ó"ð  #€ð MOØ$(óKó28ó8ó?ó?ó?ô	0r:   