
    c
                         d Z ddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZ  G d dej                  Zedk    r( ej        d	ej        
            ej                     dS dS )zN
Automated tests for checking transformation algorithms (the models package).
    N)MmCorpus)logentropy_model)datapathget_tmpfilec                   D    e Zd Zdgg ddgg gZd Zd Zd Zd Zd Zd	 Z	d
S )TestLogEntropyModel)         ?)r   g      ?)   r
   c                     t          t          d                    | _        t          t          d                    | _        g | _        d S )Nztest_corpus_small.mmztest_corpus_ok.mm)r   r   corpus_small	corpus_okcorpus_emptyselfs    Alib/python3.11/site-packages/gensim/test/test_logentropy_model.pysetUpzTestLogEntropyModel.setUp   sA    $X.D%E%EFF!(+>"?"?@@    c                     t           j        fd}|                     t          t          j         |                       dS )z>Test creating a model using a generator as input; should fail.c              3      K   | D ]}|V  d S )N )test_corpustest_docs     r   get_generatorz>TestLogEntropyModel.test_generator_fail.<locals>.get_generator   s*      '   r   corpusN)r   TEST_CORPUSassertRaises
ValueErrorr   LogEntropyModel)r   r   s     r   test_generator_failz'TestLogEntropyModel.test_generator_fail   sI    &9&E 	 	 	 	 	*&6&F}}_____r   c                 ^    |                      t          t          j        | j                   dS )z8Test creating a model using an empty input; should fail.r   N)r   r   r   r    r   r   s    r   test_empty_failz#TestLogEntropyModel.test_empty_fail$   s*    *&6&FtO`aaaaar   c                     t          j        | j        d          }t          | j                  d         }||         }g d}|                     t          j        ||                     d S )NF	normalizer   ))r   g3?)r	   g8֪?)   gGh8Y?)r   r    r   list
assertTruenpallclose)r   modeldoctransformedexpecteds        r   test_transformz"TestLogEntropyModel.test_transform(   so     05QQQ 4>""1%Cj
 
 

 	K::;;;;;r   c                 t   t          d          }t          j        | j        d          }|                    |           t          j                            |          }|                     |j        |j        k               g }|                     t          j	        ||         ||                              d S )Nzgensim_models_logentry.tstTr%   
r   r   r    r   saveloadr)   entrr*   r+   r   fnamer,   model2tstvecs        r   test_persistencez$TestLogEntropyModel.test_persistence7   s    899 04PPP

5!166u==
fk1222E&M6&>BBCCCCCr   c                 x   t          d          }t          j        | j        d          }|                    |           t          j                            |d           }|                     |j        |j        k               g }|                     t          j	        ||         ||                              d S )Nzgensim_models_logentry.tst.gzTr%   )mmapr2   r6   s        r   test_persistence_compressedz/TestLogEntropyModel.test_persistence_compressed@   s    ;<< 04PPP

5!166u46HH
fk1222E&M6&>BBCCCCCr   N)
__name__
__module____qualname__r   r   r!   r#   r0   r:   r=   r   r   r   r   r      s        :rHh#7<K  
` ` `b b b< < <D D DD D D D Dr   r   __main__z)%(asctime)s : %(levelname)s : %(message)s)formatlevel)__doc__loggingunittestnumpyr*   gensim.corpora.mmcorpusr   gensim.modelsr   gensim.test.utilsr   r   TestCaser   r>   basicConfigDEBUGmainr   r   r   <module>rO      s    
       , , , , , , * * * * * * 3 3 3 3 3 3 3 32D 2D 2D 2D 2D(+ 2D 2D 2Dj z GJRYR_````HMOOOOO r   