a
    h                      @   s  d dl Z d dlmZ d dlZd dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ d dlmZmZ dZh dZddd	h d
ddgfddddddddgZejddg dgddggejdeeegdd Zdd Zdd ZG d d! d!Zd"d# Zd$d% Zd&d' Zd(d) Z d*d+ Z!d,d- Z"ejd.e#dfe$dfe%d/fe&dffd0d1 Z'ejd2d3d4 e(d	D e)g d5fd6d7 Z*dS )8    N)copy)PythonRandomInterfacearbitrary_elementcreate_py_random_statecreate_random_statedict_to_numpy_arraydiscrete_sequenceflattengroupsmake_list_of_intspairwisepowerlaw_sequence)_dict_to_numpy_array1_dict_to_numpy_array2)      )      ))      )   )   )	   
      )                           >   )r   r   r   r   )r   r   r   r   r   )r   r   )r   r   r   )r   r    r!   r"   r#   r$   r   r   r   >   r   )r   r   r   r   r   ZfoobarZbaz)r   r   )r   r   ZqweZasd)r   r    )r!   )r"   Z19r$   resultexistingZ	existing1Z	existing2nestedc                 C   sz   |d u r$t | |}t|dksdJ n@t|}t|}t | |}t|t|  kr^d| ksdn J tt|tsvJ d S )Nr$   )r	   lenr   
issubclasstypetuple)r(   r&   val_resultZ	nexisting r/   Z/var/www/html/assistant/venv/lib/python3.9/site-packages/networkx/utils/tests/test_misc.pytest_flatten.   s    

&r1   c                  C   sl   g d} t | | u sJ t | | ks(J tt | d tu s@J ttjt g d ttjt g d d S )N)r   r   g      @*   r   )r   r   r   Zkermit)r   r   g@)r   r+   intpytestraisesnxNetworkXError)Zmylistr/   r/   r0   test_make_list_of_ints=   s    r9   c                  C   s    t ddd} tdg dd} d S )Nr$   g      @)exponent)r   r   r   r   r   r   r   r   r   r   r   )distribution)r   r   )zr/   r/   r0   test_random_number_distributionF   s    r=   c                   @   s@   e Zd Zedd Zdd Zdd Zdd Zd	d
 Zdd Z	dS )TestNumpyArrayc                 C   s   t dad S )Nnumpy)r5   importorskipnp)clsr/   r/   r0   setup_classM   s    zTestNumpyArray.setup_classc                 C   s   t jg dt jd}t g d}t g d}tt|tksDJ t|t|ksXJ t|}t|d tkstJ tt	j
t| d S )Nr   r   r   )Zdtype)g      ?r   r   )g?r   r   r   )rA   arrayZint64r+   r   listr4   r5   r6   r7   r8   )selfabcBr/   r/   r0   test_numpy_to_list_of_intsR   s    z)TestNumpyArray.test_numpy_to_list_of_intsc                 C   s|   ddd}t |dddd}tj|tddg t |dddd}tj|tddg t |}tj| d d S )Nr   r   rH   rI   r   mapping)rI   rH   r   )r   rA   testingassert_allcloserE   sum)rG   drH   r/   r/   r0   test__dict_to_numpy_array1\   s    
z)TestNumpyArray.test__dict_to_numpy_array1c                 C   sj   ddddddd}ddd}t ||d}tj|tddgddgg t |}tj| d d S 	Nr   r   rM   r   r$   r   rN   !   )r   rA   rP   rQ   rE   rR   rG   rS   rO   rH   r/   r/   r0   test__dict_to_numpy_array2f   s    
 z)TestNumpyArray.test__dict_to_numpy_array2c                 C   s   ddddddd}ddd}t ||d}tj|tddgddgg ddd}t ||d}tj|tddgddgg t|}tj| d d S rU   )r   rA   rP   rQ   rE   r   rR   rW   r/   r/   r0   test_dict_to_numpy_array_ap   s    
 
 z)TestNumpyArray.test_dict_to_numpy_array_ac                 C   sV   ddd}ddd}t ||d}tj|tddg t|}tj| d d S )Nr   r   rM   r   rN   r   )r   rA   rP   rQ   rE   r   rR   rW   r/   r/   r0   test_dict_to_numpy_array_b~   s    

z)TestNumpyArray.test_dict_to_numpy_array_bN)
__name__
__module____qualname__classmethodrC   rL   rT   rX   rY   rZ   r/   r/   r/   r0   r>   L   s   



r>   c                  C   s   t d} g d}|dg }tt| |ks.J ttt| |ksFJ tt| dd|ks^J td}tt|g kszJ td}tt|ddg ksJ d S )Nr   ))r   r   )r   r   )r   r   )r   r   T)Zcyclicr/   )rangerF   r   iter)nodesZ
node_pairsZnode_pairs_cycleZ
empty_iterr/   r/   r0   test_pairwise   s    
rb   c                  C   sP   t tdg d} t| }ddhddhdhd}||ks<J i ti ksLJ d S )	NZabcde)r   r   r   r   r   rH   rI   rJ   rS   e)r   r   r   )dictzipr
   )Zmany_to_oneactualexpectedr/   r/   r0   test_groups   s
    rh   c                  C   s   t d} | jj}ttd|s$J ttd |s6J tt| j|sJJ tt|d|s`J | j }tt|| jjsJ t t	td | 
|ddtddksJ d S )Nr?   r   rH   r   )r5   r@   randomRandomState
isinstancer   default_rng	Generatorr6   
ValueErrorallZrand)rA   rsrngr/   r/   r0   test_create_random_state   s    

rr   c                  C   s   t j} ttd| sJ ttd | s*J tt| d| s@J tttd td}|j j}|j 	d}|j 
|j  }t}tt|j |sJ tt|d|sJ tt||sJ tt||sJ tt |sJ d S )Nr   rH   r?   i  )ri   Randomrk   r   r5   r6   rn   r@   rj   rl   rm   ZSFC64r   )ZpyrsrA   rp   rq   Zrng_explicitZnprsr/   r/   r0   test_create_py_random_state   s    
rt   c                     s<  t d} | jj}t|d |d ddddksBJ  g dg dksbJ  dd	ddks~J  
dd	ksJ |  g dg dksJ |  g dd
jg ddddksJ |  fddtdD fddtdD ks"J    ks8J d S )Nr?   r2   r   r   rD   r   r         ?UUUUUU?r   r   Freplacec                    s   g | ]}  d dqS r   r   randint.0_rq   r/   r0   
<listcomp>       z:test_PythonRandomInterface_RandomState.<locals>.<listcomp>d   c                    s   g | ]}  d dqS r   r   r{   r}   )rs42r/   r0   r      r   )r5   r@   ri   rj   r   	randranger|   choicegaussnormalexpovariateexponentialro   shufflesampler_   Zrandom_sample)rA   rp   r/   )rq   r   r0   &test_PythonRandomInterface_RandomState   s$    
 &"
r   c                     s<  t d} | jdt| jd  ddddksBJ  g dg dksbJ  dd	ddks~J  
dd	ksJ |  g dg dksJ |  g dd
jg ddddksJ |  fddtdD fddtdD ks"J    ks8J d S )Nr?   r2   r   r   rD   r   r   ru   rv   r   rw   Frx   c                    s   g | ]}  d dqS rz   r{   r}   )prir/   r0   r      r   z8test_PythonRandomInterface_Generator.<locals>.<listcomp>r   c                    s   g | ]}  d dqS r   )integersr}   r   r/   r0   r      r   )r5   r@   ri   rl   r   r   r   r   r   r   r   r   ro   r   r   r_   )rA   r/   )r   rq   r0   $test_PythonRandomInterface_Generator   s"    
 &"
r   )iterable_typerg   [c                 C   s    | g d}t ||ksJ d S )NrD   )r   )r   rg   iterabler/   r/   r0   test_arbitrary_element   s    r   iteratorc                 c   s   | ]
}|V  qd S )Nr/   )r~   ir/   r/   r0   	<genexpr>   r   r   rD   c                 C   s:   t jtdd t|  W d   n1 s,0    Y  dS )z0Value error is raised when input is an iterator.zfrom an iterator)matchN)r5   r6   rn   r   )r   r/   r/   r0   test_arbitrary_element_raises   s    r   )+ri   r   r5   Znetworkxr7   Znetworkx.utilsr   r   r   r   r   r   r	   r
   r   r   r   Znetworkx.utils.miscr   r   Znested_depthZ
nested_setZnested_mixedmarkZparametrizer1   r9   r=   r>   rb   rh   rr   rt   r   r   rF   r,   strsetr   r_   r`   r   r/   r/   r/   r0   <module>   sB   4	
		=
