o
    ˷e%                     @   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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d d! Z d"d# Z!d$d% Z"d&d' Z#d(d) Z$G d*d+ d+Z%d,d- Z&d.d/ Z'd0d1 Z(d2d3 Z)d4d5 Z*d6d7 Z+d8d9 Z,ejd:e-dfe.dfe/d;fe0dffd<d= Z1ejd>d?d@ e2d	D e3g dAfdBdC Z4dDdE Z5dS )F    N)copy)PythonRandomInterfacearbitrary_elementcreate_py_random_statecreate_random_statedict_to_numpy_arraydiscrete_sequenceflattengroupsis_string_likeiterablemake_list_of_intsmake_strpairwisepowerlaw_sequenceto_tuple)_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   foobarbaz)r   r   )r   r    qweasd)r!   r$   )r%   )r&   19r(   resultexisting	existing1	existing2nestedc                 C   s|   |d u rt | |}t|dksJ n!t|}t|}t | |}t|t|  kr0d| ks3J  J tt|ts<J d S )Nr(   )r	   lenr   
issubclasstypetuple)r7   r3   val_result	nexisting r?   U/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/utils/tests/test_misc.pytest_flatten2   s   

(rA   c                   C   s(   t dsJ t d rJ t drJ d S )Naaaa{   )r   r?   r?   r?   r@   test_is_string_likeA   s   rD   c                   C   sV   t d rJ t drJ t g dsJ t dsJ t ddds#J t ds)J d S )Nr   r   r   r   AXr   r   ABC)r   r?   r?   r?   r@   test_iterableG   s   rJ   c                  C   s:   t d} t| sJ t|  sJ t|  sJ d S )Nr   )nxcomplete_graphr   nodesedges)Kr?   r?   r@   test_graph_iterableP   s   
rP   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   kermit)r   r   g@)r   r:   intpytestraisesrK   NetworkXError)mylistr?   r?   r@   test_make_list_of_intsW   s   rY   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?   r@   test_random_number_distribution`   s   r]   c                  C   .   d} t | }t|tsJ t|dksJ d S Nu   qualitér   r   
isinstancestrr8   xyr?   r?   r@   test_make_str_with_bytesf      rf   c                  C   r^   r_   r`   rc   r?   r?   r@   test_make_str_with_unicodem   rg   rh   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)rU   importorskipnp)clsr?   r?   r@   setup_classu   s   zTestNumpyArray.setup_classc                 C   s   t jg dt jd}t g d}t g d}tt|tks"J t|t|ks,J t|}t|d tks:J tt	j
t| d S )NrE   )dtype)g      ?r   r   )g?r   r   r   )rl   arrayint64r:   r   listrT   rU   rV   rK   rW   )selfabcBr?   r?   r@   test_numpy_to_list_of_intsz   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   rt   ru   r   mapping)ru   rt   r   )r   rl   testingassert_allcloserp   sum)rs   drt   r?   r?   r@   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   ry   r   r(   r   rz   !   )r   rl   r|   r}   rp   r~   rs   r   r{   rt   r?   r?   r@   test__dict_to_numpy_array2   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 r   )r   rl   r|   r}   rp   r   r~   r   r?   r?   r@   test_dict_to_numpy_array_a   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   ry   r   rz   r   )r   rl   r|   r}   rp   r   r~   r   r?   r?   r@   test_dict_to_numpy_array_b   s   

z)TestNumpyArray.test_dict_to_numpy_array_bN)
__name__
__module____qualname__classmethodrn   rx   r   r   r   r   r?   r?   r?   r@   ri   t   s    



ri   c                  C   s   t d} g d}|dg }tt| |ksJ ttt| |ks#J tt| dd|ks/J td}tt|g ks=J td}tt|ddg ksMJ d S )Nr   ))r   r   rH   )r   r   )r   r   T)cyclicr?   )rangerr   r   iter)rM   
node_pairsnode_pairs_cycle
empty_iterr?   r?   r@   test_pairwise   s   
r   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s&J d S )	Nabcde)r   r   r   r   r   rt   ru   rv   r   e)r   r   r   )dictzipr
   )many_to_oneactualexpectedr?   r?   r@   test_groups   s
   r   c                  C   sl   ddddgg} t | }d}||ksJ d}t |}|}||ks!J ddddgf}t |}d}||ks4J d S )Nr   r   r   )r   r   )r   r   rH   )r   )a_listr   r   a_tuplea_mixr?   r?   r@   test_to_tuple   s   r   c                  C   s   t d} | jj}ttd|sJ ttd |sJ tt| j|s%J tt|d|s0J | j }tt|| jjs@J t t	td | 
|ddtddksZJ d S )Nrj   r   rt   r   )rU   rk   randomRandomStatera   r   default_rng	GeneratorrV   
ValueErrorallrand)rl   rsrngr?   r?   r@   test_create_random_state   s   

*r   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 |sKJ tt|d|sVJ tt||s_J tt||shJ tt |spJ d S )Nr   rt   rj   i  )r   Randomra   r   rU   rV   r   rk   r   r   r   SFC64r   )pyrsrl   r   r   rng_explicitnprsr?   r?   r@   test_create_py_random_state   s   
r   c                     s8  t d} | jj}t|d |d ddddks!J  g dg dks1J  dd	ddks?J  
dd	ksKJ |  g dg dks^J |  g dd
jg ddddksuJ |  fddtdD fddtdD ksJ    ksJ d S )Nrj   rQ   r   r   rE   r   r         ?UUUUUU?r   r   Freplacec                       g | ]}  d dqS r   r   randint.0_r   r?   r@   
<listcomp>      z:test_PythonRandomInterface_RandomState.<locals>.<listcomp>d   c                    r   r   r   r   r   )rs42r?   r@   r     r   )rU   rk   r   r   r   	randranger   choicegaussnormalexpovariateexponentialr   shufflesampler   random_sample)rl   r   r?   )r   r   r@   &test_PythonRandomInterface_RandomState   s$   
 &"r   c                     s8  t d} | jdt| jd  ddddks!J  g dg dks1J  dd	ddks?J  
dd	ksKJ |  g dg dks^J |  g dd
jg ddddksuJ |  fddtdD fddtdD ksJ    ksJ d S )Nrj   rQ   r   r   rE   r   r   r   r   r   r   Fr   c                    r   r   r   r   )prir?   r@   r   $  r   z8test_PythonRandomInterface_Generator.<locals>.<listcomp>r   c                    r   r   )integersr   r   r?   r@   r   %  r   )rU   rk   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )rl   r?   )r   r   r@   $test_PythonRandomInterface_Generator  s"   
 &"r   )iterable_typer   [c                 C   s    | g d}t ||ksJ d S )NrE   )r   )r   r   r   r?   r?   r@   test_arbitrary_element*  s   r   iteratorc                 c   s    | ]}|V  qd S )Nr?   )r   ir?   r?   r@   	<genexpr>3  s    r   rE   c                 C   s<   t jtdd t|  W d   dS 1 sw   Y  dS )z0Value error is raised when input is an iterator.zfrom an iterator)matchN)rU   rV   r   r   )r   r?   r?   r@   test_arbitrary_element_raises2  s   
"r   c                  C   s   t d} ddi}t   tj| W d    n1 sw   Y  dddii}t   tj| W d    d S 1 s?w   Y  d S )Nrj   rt   r   ru   r   )rU   rk   deprecated_callrK   utilsdict_to_numpy_array1dict_to_numpy_array2)rl   r   d2r?   r?   r@   %test_dict_to_numpy_array_deprecations;  s   


"r   )6r   r   rU   networkxrK   networkx.utilsr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   networkx.utils.miscr   r   nested_depth
nested_setnested_mixedmarkparametrizerA   rD   rJ   rP   rY   r]   rf   rh   ri   r   r   r   r   r   r   r   rr   r;   rb   setr   r   r   r   r   r?   r?   r?   r@   <module>   sR    D	
			=

