
    hb                         S SK r S SKr\ R                  " S5        S SKJrJrJrJr  S r	S r
S rS rS rS	 rS
 rS rS rS rS rS rS rg)    Nsklearn)	learn_gmmfisher_vectorFisherVectorExceptionDescriptorExceptionc                      [         R                  " [        5         [        SSS9  SSS5        g! , (       d  f       g= f)zTTest that DescriptorException is raised when wrong type for descriptions
is passed.
zcompletely wrong test   n_modesNpytestraisesr   r        b/var/www/fran/franai/venv/lib/python3.13/site-packages/skimage/feature/tests/test_fisher_vector.py"test_gmm_wrong_descriptor_format_1r      s(    
 
*	+)15 
,	+	+s   /
=c                      [         R                  " [        5         [        [        R
                  " S5      [        R
                  " S5      /SS9  SSS5        g! , (       d  f       g= f)zZTest that DescriptorException is raised when descriptors are of
different dimensionality.
)         
   r	   r
   Nr   r   r   r   npzerosr   r   r   "test_gmm_wrong_descriptor_format_2r      s>    
 
*	+288G$bhhw&78!D 
,	+	+   5A
A'c                      [         R                  " [        5         [        [        R
                  " S5      [        R
                  " S5      /SS9  SSS5        g! , (       d  f       g= f)zPTest that DescriptorException is raised when not all descriptors are of
rank 2.
r   r   )r   r   r	   r	   r
   Nr   r   r   r   "test_gmm_wrong_descriptor_format_3r    !   s>    
 
*	+288G$bhhz&:;QG 
,	+	+r   c                      [         R                  " [        5         [        / SQ/ SQ/SS9  SSS5        g! , (       d  f       g= f)zTest that DescriptorException is raised when elements of descriptor list
are of the incorrect type (i.e. not a NumPy ndarray).
)r	         r	   r
   Nr   r   r   r   "test_gmm_wrong_descriptor_format_4r$   *   s,    
 
*	+9i(!4 
,	+	+s	   5
Ac                      [         R                  " [        5         [        [        R
                  " S5      [        R
                  " S5      /SS9  SSS5        g! , (       d  f       g= f)zqTest that FisherVectorException is raised when incorrect type for
n_modes is passed into the learn_gmm function.
r   r   	not_validr
   Nr   r   r   r   r   r   r   r   r   !test_gmm_wrong_num_modes_format_1r(   3   s>    
 
,	-288G$bhhw&78+N 
.	-	-r   c                      [         R                  " [        5         [        [        R
                  " S5      [        R
                  " S5      /SS9  SSS5        g! , (       d  f       g= f)zTest that FisherVectorException is raised when a number that is not a
positive integer is passed into the n_modes argument of learn_gmm.
r   r   r
   Nr'   r   r   r   !test_gmm_wrong_num_modes_format_2r+   <   s>    
 
,	-288G$bhhw&78"E 
.	-	-r   c                      [         R                  " [        5         [        [        R
                  R                  S5      SSS0S9  SSS5        g! , (       d  f       g= f)ziTest that FisherVectorException is raised when wrong covariance type is
passed in as a keyword argument.
r   r   r"   covariance_typefullr   gm_argsN)r   r   r   r   r   randomr   r   r   test_gmm_wrong_covariance_typer3   E   sA    
 
,	-IIX&<Mv;V	
 
.	-	-s   +A
Ac                      [        [        R                  R                  S5      SSS0S9n U R                  c   eU R                  c   eU R
                  c   eg)zlTest that GMM estimation is successful when the correct covariance type
is passed in as a keyword argument.
r-   r"   r.   diagr0   Nr   r   r2   means_covariances_weights_gmms    r    test_gmm_correct_covariance_typer<   P   s^    
 
		"A8I67RC ::!!!'''<<###r   c                      [        [        R                  R                  S5      SS9n U R                  c   eU R                  c   eU R
                  c   eg)a  
Test the GMM estimation. Since this is essentially a wrapper for the
scikit-learn GaussianMixture class, the testing of the actual inner
workings of the GMM estimation is left to scikit-learn and its
dependencies.

We instead simply assert that the estimation was successful based on the
fact that the GMM object will have associated mixture weights, means, and
variances after estimation is successful/complete.
)d   @   r   r
   Nr6   r:   s    r   test_gmm_e2er@   ^   sQ     BII$$Y/
;C::!!!'''<<###r   c                       SSK Jn   [        R
                  " [        5         [        / SQ/W " 5       5        SSS5        g! [         a    [        S5         NOf = f! , (       d  f       g= f)z
Test that DescriptorException is raised when the incorrect type for the
descriptors is passed into the fisher_vector function.
r   GaussianMixturezmscikit-learn is not installed. Please ensure it is installed in order to use the Fisher vector functionality.)r	   r"   r#   r   N)sklearn.mixturerC   ImportErrorprintr   r   r   r   rB   s    r   test_fv_wrong_descriptor_typesrG   q   sW    

3 
*	+|no&78 
,	+  
<	

 
,	+s   A  A AA
A)c                       " S S5      n [         R                  " [        5         [        [        R
                  " S5      U " 5       5        SSS5        g! , (       d  f       g= f)z
Test that FisherVectorException is raised when a GMM not of type
sklearn.mixture.GaussianMixture is passed into the fisher_vector
function.
c                       \ rS rSrSrg):test_fv_wrong_gmm_type.<locals>.MyDifferentGaussianMixture   r   N)__name__
__module____qualname____firstlineno____static_attributes__r   r   r   MyDifferentGaussianMixturerJ      s    r   rQ   r-   N)r   r   r   r   r   r   )rQ   s    r   test_fv_wrong_gmm_typerR      s>      
,	-bhhx(*D*FG 
.	-	-s   &A
A"c            	      .   Sn SnSU-  U -  U-   n[        S5       Vs/ s HB  n[        R                  R                  [        R                  R                  SS5      U 45      PMD     nn[	        XAS9n[        US   U5      n[        U5      U:X  d   eg	s  snf )
at  
Test the Fisher vector computation given a GMM returned from the learn_gmm
function. We simply assert that the dimensionality of the resulting Fisher
vector is correct.

The dimensionality of a Fisher vector is given by 2KD + K, where K is the
number of Gaussians specified in the associated GMM, and D is the
dimensionality of the descriptors using to estimate the GMM.
      r"   r   r      r
   r   Nranger   r2   randintr   r   lendim	num_modesexpected_dim_descriptorsr;   
fisher_vecs          r   test_fv_e2erb      s     CIy=3&2LNSTViXi299##RYY%6%6q"%=s$CDiKX
K
3C{1~s3Jz?l*** Ys   A	Bc            	      ,   Sn SnSU-  U -  U-   n[        S5       Vs/ s HB  n[        R                  R                  [        R                  R                  SS5      U 45      PMD     nn[	        XAS9n[        US   US	S
9n[        U5      U:X  d   egs  snf )a}  
Test the improved Fisher vector computation given a GMM returned from the
learn_gmm function. We simply assert that the dimensionality of the
resulting Fisher vector is correct.

The dimensionality of a Fisher vector is given by 2KD + K, where K is the
number of Gaussians specified in the associated GMM, and D is the
dimensionality of the descriptors using to estimate the GMM.
rT   rU   r"   r   r   rV   r
   r   T)improvedNrW   r[   s          r   test_fv_e2e_improvedre      s     CIy=3&2LNSTViXi299##RYY%6%6q"%=s$CDiKX
K
3C{1~sTBJz?l*** Ys   A	B)r   numpyr   importorskipskimage.feature._fisher_vectorr   r   r   r   r   r   r    r$   r(   r+   r3   r<   r@   rG   rR   rb   re   r   r   r   <module>ri      si        I  6EH5OF
$$&9"H+2+r   