
    
3j                         S r SrSrSSKJrJr  SSK7  SSKJr  SSK	r	SSK
r
SSKrSSKrSSKJrJrJr   SSKr\ " S	 S
\	R&                  5      5       r\S:X  a  \	R                  " 5         gg! \ a     N;f = f)zChristopher Hahnezinbox@christopherhahne.dea  
    Copyright (c) 2020 Christopher Hahne <inbox@christopherhahne.de>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    )ColorMatcherMETHODS)*)mainN)ddtidataunpackc                    	  ^  \ rS rSrU 4S jrS r\S#S j5       r\" S \	 5       5      \
S$S j5       5       r\R                  " S\R                  ;   S	5      S
 5       r\" S S 5       5      \
S 5       5       r\" SS/S/SS/S/SS/S/SS/S/SS/S/45      \
S 5       5       rS r\" \R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SS5      \R*                  R-                  SS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  SSSS5      \R*                  R-                  SSSS5      S/\R*                  R-                  SSS5      \R*                  R-                  SSS5      S/\R*                  R-                  S5      \R*                  R-                  S5      S/\R*                  R-                  S5      \R*                  R-                  S5      S/\R*                  R-                  S5      \R*                  R-                  S5      S// S Q45      \
S! 5       5       rS"rU =r$ )%MatchMethodTester%   c                 .   > [         [        U ]
  " U0 UD6  g N)superr   __init__)selfargskwargs	__class__s      I/home/wildlama/miniconda3/lib/python3.13/site-packages/tests/unit_test.pyr   MatchMethodTester.__init__(   s    /@@    c                     [         R                  R                  [         R                  R                  [        5      5      U l        [         R                  R                  U R
                  S5      U l        g )Ndata)ospathdirnamerealpath__file__dir_pathjoindat_path)r   s    r   setUpMatchMethodTester.setUp+   s?    (8(8(BCT]]F;r   c                     [         R                  " X5      S   n[         R                  " X5      S   n[         R                  " [         R                  " [         R                  " X4-
  5      5      5      $ )Nr   )np	histogramsqrtsumsquare)img1img2binshist_ahist_bs        r   avg_hist_distMatchMethodTester.avg_hist_dist0   sM     d)!,d)!,wwrvvbii89::r   c              #   &   #    U  H  o/v   M	     g 7fr    ).0ms     r   	<genexpr>MatchMethodTester.<genexpr>8   s     !AC   Fc                 n   Uc  U R                  S5        [        [        R                  R	                  U R
                  S5      5      n[        [        R                  R	                  U R
                  S5      5      n[        [        R                  R	                  U R
                  S5      5      n[        XCUS9R                  5       nU R                  X55      nU R                  X65      n[        S[        US5      < SU< S	[        US5      < 35        [        XCS
S9n	U	R                  5         U	R                  U	R                  U	R                  U	R                  4u  pp[        XFS
S9n	U	R                  5         U	R                  U	R                  p[        R                   " XXS9n[        R                   " XXS9n[        S[        US5      < SU< S	[        US5      < 35        U R#                  SXx:  5        U(       a7  [%        U[        R                  R	                  U R
                  SU-   5      SS9  g g )Nz"Type 'None' was passed and skippedscotland_plain.pngscotland_house.pngzscotland_pitie.pngsrcrefmethod%
Avg. histogram distance of original     vs.  mvgd)mu_amu_bcov_acov_bz#Wasserstein-2 distance of original T	scotland_png)	file_path	file_type)skipTestload_img_filer   r   r    r!   r   r   r/   printround	init_varsmu_rmu_zcov_rcov_zw2_distassertEqualsave_img_file)r   r>   saveplainhouserefermatch	refer_val	match_valcmmu_housemu_plain	cov_house	cov_plainmu_match	cov_matchrefer_w2match_w2s                     r   test_match_method#MatchMethodTester.test_match_method8   s   
 >MM@A bggll4==:NOPbggll4==:NOPbggll4==:NOP &AFFH &&u4	&&u4	eIWXFY[achirtucvwxev>
3577BGGRXXrxx3W0Iev>
 ggrxx)''XIg''XIg5STCUW]_demop_qrs 	y45 %277<<{SYGY+Zfkl r   imageiozrequires imageioc           	         [         S   nSnSn[        R                  " SU-   S-   5      n[        R                  " SU-   S-   5      n[        XEUS9R	                  5       nU R                  XE5      nU R                  XF5      n[        S[        US5      < S	[        US5      < 35        [        R                  R                  U R                  UR                  S
5      S   S-   U-   S-   U-   5      n	[        U[        R                  R                  U R                  U5      S9  [        U[        R                  R                  U R                  U5      S9  [        XiS9  U R                  SXx:  5        g )Nr   chelsea	astronautzimageio:z.png)r>   r?   r@   rA   ._from__)rJ   T)r   rj   imreadr   r   r/   rN   rO   r   r   r    r!   splitrW   rV   )
r   r>   fn_img1fn_img2r*   r+   r\   r]   r^   output_filenames
             r   test_match_method_imageio+MatchMethodTester.test_match_method_imageio]   s7     ~~j078~~j078 T7<<> &&t2	&&t3	5TUCVX]^gijXklm '',,t}}gmmC6H6Kh6VY`6`cf6fio6opdbggll4=='&JKdbggll4=='&JKe7 	y45r   c              #   &   #    U  H  o/v   M	     g 7fr   r2   )r3   kws     r   r5   r6   z   s     ,+RD+r7   )z-hz--helpc                     [         R                  R                  U5         [        5       nU R                  SU5        g ! [         a    Sn N!f = f)NT)sysargvappendr   
SystemExitrV   )r   ry   rets      r   test_cli_helpMatchMethodTester.test_cli_helpz   sH    
 		&C 	s#  	C	s   
> AA-s -r Tz--src=z--ref=z--wrongr   rn    c                    [         R                  R                  US   [        R                  R                  U R                  S5      -   5        [         R                  R                  US   [        R                  R                  U R                  S5      -   5         [        5       n[         R                  S   /[         l        U R                  X#5        g ! [         a    Sn N=f = f)Nr   r:      r9   F)
r{   r|   r}   r   r   r    r!   r   r~   rV   )r   ry   exp_valr   s       r   test_cli_argsMatchMethodTester.test_cli_args   s     	1T]]<P QQR1T]]<P QQR	&C
 HHQK= 	&  	C	s   
C C$#C$c                 z   [         R                  R                  SU R                  -   5        [         R                  R                  S[        R
                  R                  U R                  S5      -   5        [         R                  R                  S[        S   -   5        [        5       nU R                  SU5        g )Nr   r   r9   zmethod==r   T)
r{   r|   r}   r!   r   r   r    r   r   rV   )r   r   s     r   test_batch_process$MatchMethodTester.test_batch_process   sz     	-.T]]<P QQR
WQZ/0 f 	s#r      r      r@   	      r   )NNFc                      [        5       nUR                  XSS9nUR                  5       R                  S5      nSnU R                  X6US9  g ! [         a  nSnUn S nAN$S nAff = f)Ndefaultr;   boolr   F)msg)r   transfermeanastypeBaseExceptionrV   )	r   src_imgref_imgr   r_   resr   r   es	            r   test_img_dimsMatchMethodTester.test_img_dims   sl    8	B++'y+IC((*##F+CC
 	3/	  	CC	s   ;A 
A&A!!A&)r!   r   )   )NF)__name__
__module____qualname____firstlineno__r   r"   staticmethodr/   r   r   r	   rh   unittest
skipUnlessr{   modulesrv   r   r   r   r%   randomrandr   __static_attributes____classcell__)r   s   @r   r   r   %   s
   A<
 ; ; !!"!m  #!mF ckk13EF6 G68 ,+,-	$  .	$ U^T"!4( %(3Z"Xu  ' '$$ YY^^Aq!$biinnQ1&=tDYY^^Aq!299>>!Q#7>YY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!$biinnQ1&=tDYY^^Aq!Q'1a)CUKYY^^Aq!$biinnQ1&=uEYY^^A		q 159YY^^A		q 159YY^^A		q 159/ 2 0 340r   r   __main__)
__author__	__email____license__color_matcher.top_levelr   r   color_matcher.io_handlercolor_matcher.bin.clir   r   r   r{   numpyr%   r   r   r	   rj   ImportErrorTestCaser   r   r2   r   r   <module>r      s    !
'	$ : & &    " "	
 m0)) m0 m0` zMMO k  		s   A, ,A54A5