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qwe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 r0   L/var/www/auris/lib/python3.9/site-packages/networkx/utils/tests/test_misc.pytest_flatten.   s    

&r2   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mylistr0   r0   r1   test_make_list_of_ints=   s    r:   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   )zr0   r0   r1   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)r6   importorskipnp)clsr0   r0   r1   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   )rB   arrayint64r,   r   listr5   r6   r7   r8   r9   )selfabcBr0   r0   r1   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   rJ   rK   r   mapping)rK   rJ   r   )r   rB   testingassert_allcloserF   sum)rI   drJ   r0   r0   r1   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   rO   r   r$   r   rP   !   )r   rB   rR   rS   rF   rT   rI   rU   rQ   rJ   r0   r0   r1   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 rW   )r   rB   rR   rS   rF   r   rT   rY   r0   r0   r1   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   rO   r   rP   r   )r   rB   rR   rS   rF   r   rT   rY   r0   r0   r1   test_dict_to_numpy_array_b~   s    

z)TestNumpyArray.test_dict_to_numpy_array_bN)
__name__
__module____qualname__classmethodrD   rN   rV   rZ   r[   r\   r0   r0   r0   r1   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cyclicr0   )rangerH   r   iter)nodesZ
node_pairsZnode_pairs_cycleZ
empty_iterr0   r0   r1   test_pairwise   s    
rd   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   rJ   rK   rL   rU   e)r   r   r   )dictzipr
   )Zmany_to_oneactualexpectedr0   r0   r1   test_groups   s
    rj   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   rJ   r   )r6   rA   randomRandomState
isinstancer   default_rng	Generatorr7   
ValueErrorallZrand)rB   rsrngr0   r0   r1   test_create_random_state   s    

rt   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   rJ   r@   i  )rk   Randomrm   r   r6   r7   rp   rA   rl   rn   ro   ZSFC64r   )ZpyrsrB   rr   rs   Zrng_explicitZnprsr0   r0   r1   test_create_py_random_state   s    
rv   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@   r3   r   r   rE   r   r         ?UUUUUU?r   r   Freplacec                    s   g | ]}  d dqS r   r   randint.0_rs   r0   r1   
<listcomp>       z:test_PythonRandomInterface_RandomState.<locals>.<listcomp>d   c                    s   g | ]}  d dqS r   r   r}   r   )rs42r0   r1   r      r   )r6   rA   rk   rl   r   	randranger~   choicegaussnormalexpovariateexponentialrq   shufflesamplera   Zrandom_sample)rB   rr   r0   )rs   r   r1   &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@   r3   r   r   rE   r   r   rw   rx   r   ry   Frz   c                    s   g | ]}  d dqS r|   r}   r   )prir0   r1   r      r   z8test_PythonRandomInterface_Generator.<locals>.<listcomp>r   c                    s   g | ]}  d dqS r   )integersr   r   r0   r1   r      r   )r6   rA   rk   rn   r   r   r   r   r   r   r   r   rq   r   r   ra   )rB   r0   )r   rs   r1   $test_PythonRandomInterface_Generator   s"    
 &"
r   )iterable_typeri   [c                 C   s    | g d}t ||ksJ d S )NrE   )r   )r   ri   iterabler0   r0   r1   test_arbitrary_element   s    r   iteratorc                 c   s   | ]
}|V  qd S )Nr0   )r   ir0   r0   r1   	<genexpr>   r   r   rE   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)r6   r7   rp   r   )r   r0   r0   r1   test_arbitrary_element_raises   s    r   )+rk   r   r6   Znetworkxr8   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parametrizer2   r:   r>   r?   rd   rj   rt   rv   r   r   rH   r-   strsetr   ra   rb   r   r0   r0   r0   r1   <module>   sB   4	
		=
