o
    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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PythonRandomViaNumpyBits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   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)r4   r0   val_result	nexisting r<   R/var/www/vscode/kcb/lib/python3.10/site-packages/networkx/utils/tests/test_misc.pytest_flatten/   s   

(r>   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   r7   intpytestraisesnxNetworkXError)mylistr<   r<   r=   test_make_list_of_ints>   s   rH   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_distributionG   s   rL   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)rC   importorskipnp)clsr<   r<   r=   setup_classN   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 )Nr   r   r   )dtype)g      ?r   r   )g?r   r   r   )rP   arrayint64r7   r   listrB   rC   rD   rE   rF   )selfabcBr<   r<   r=   test_numpy_to_list_of_intsS   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   rY   rZ   r   mapping)rZ   rY   r   )r   rP   testingassert_allcloserU   sum)rX   drY   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   r^   r   r%   r   r_   !   )r   rP   ra   rb   rU   rc   rX   rd   r`   rY   r<   r<   r=   test__dict_to_numpy_array2g   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 rf   )r   rP   ra   rb   rU   r   rc   rh   r<   r<   r=   test_dict_to_numpy_array_aq   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   r^   r   r_   r   )r   rP   ra   rb   rU   r   rc   rh   r<   r<   r=   test_dict_to_numpy_array_b   s   

z)TestNumpyArray.test_dict_to_numpy_array_bN)
__name__
__module____qualname__classmethodrR   r]   re   ri   rj   rk   r<   r<   r<   r=   rM   M   s    



rM   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   )r   r   )r   r   )r   r   T)cyclicr<   )rangerW   r   iter)nodes
node_pairsnode_pairs_cycle
empty_iterr<   r<   r=   test_pairwise   s   
rw   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   rY   rZ   r[   rd   e)r   r   r   )dictzipr   )many_to_oneactualexpectedr<   r<   r=   test_groups   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 )NrN   r   rY   r   )rC   rO   randomRandomState
isinstancer   default_rng	GeneratorrD   
ValueErrorallrand)rP   rsrngr<   r<   r=   test_create_random_state   s   

*r   c            
      C   s6  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t|j |sMJ tt|d|sXJ tt||saJ tt||sjJ tt |srJ tt |szJ d}||dfD ]}t|}	|	d|d  |	d|d  qd S )Nr   rY   rN   i  l    r   r   )r   Randomr   r   rC   rD   r   rO   r   r   r   SFC64r   r   	randrangerandint)
pyrsrP   r   r   rng_explicitold_nprsnprsint64maxrprsr<   r<   r=   test_create_py_random_state   s.   
r   c                     s<  t d} d}| jj}t|| || ddddks#J  g dg dks3J  dd	ddksAJ  
dd	ksMJ |  g dg dks`J |  g dd
jg ddddkswJ |  fddtdD fddtdD ksJ    ksJ d S )NrN   r?   r   r   rS   r   r         ?UUUUUU?r   r   Freplacec                       g | ]}  d dqS r   r   r   .0_r   r<   r=   
<listcomp>       z:test_PythonRandomInterface_RandomState.<locals>.<listcomp>d   c                    r   r   r   r   r   )rs42r<   r=   r      r   )rC   rO   r   r   r   r   r   choicegaussnormalexpovariateexponentialr   shufflesamplerq   random_sample)rP   seedr   r<   )r   r   r=   &test_PythonRandomInterface_RandomState   s&   
 &"r   c                     s<  t d} d}| j|t| j|  ddddks#J  g dg dks3J  dd	ddksAJ  
dd	ksMJ |  g dg dks`J |  g dd
jg ddddkswJ |  fddtdD fddtdD ksJ    ksJ d S )NrN   r?   r   r   rS   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   )rC   rO   r   r   r   r   r   r   r   r   r   r   r   r   r   rq   )rP   r   r<   )r   r   r=   $test_PythonRandomInterface_Generator   s$   
 &"r   )iterable_typer~   [c                 C   s    | g d}t ||ksJ d S )NrS   )r   )r   r~   iterabler<   r<   r=   test_arbitrary_element   s   r   iteratorc                 c   s    | ]}|V  qd S )Nr<   )r   ir<   r<   r=   	<genexpr>  s    r   rS   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)rC   rD   r   r   )r   r<   r<   r=   test_arbitrary_element_raises  s   
"r   ),r   r   rC   networkxrE   networkx.utilsr   r   r   r   r   r   r	   r
   r   r   r   r   networkx.utils.miscr   r   nested_depth
nested_setnested_mixedmarkparametrizer>   rH   rL   rM   rw   r   r   r   r   r   rW   r8   strsetr   rq   rr   r   r<   r<   r<   r=   <module>   sF    8	
		=
