U
    	-eY                     @   s  d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZmZ d dlmZ d dlmZ d d	lmZmZm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%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJ d dlKmLZLmMZM d dlNmOZO d dlPmQZQmRZR ed\ZSZTZUZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd  Z_d!d" Z`d#d$ Zad%d& Zbd'd( Zcd)d* Zdd+d, Zed-d. Zfd/d0 Zgd1d2 Zhd3d4 Zid5d6 Zjd7d8 Zkd9d: Zld;d< Zmd=d> Znd?d@ ZodAdB ZpdCdD ZqdEdF ZrdGdH ZsdIdJ ZtdKdL ZudMdN ZvdOdP ZwdQdR ZxdSdT ZydUdV ZzdWdX Z{dYdZ Z|d[d\ Z}d]d^ Z~d_d` Zdadb Zdcdd Zdedf Zdgdh Zdidj ZdkS )l    )dedent)isliceproduct)Basic)Integerordered)Dummysymbols	factorial)Matrix)RGS_enum
RGS_unrankPermutation)4
_partition_set_partitionsbinary_partitions	braceletscapturecartescommon_prefixcommon_suffixconnected_components
dict_mergefilter_symbolsflattengenerate_bellgenerate_derangementsgenerate_involutionsgenerate_oriented_forestgrouphas_dupsibiniproductkbinsminlexmultisetmultiset_combinationsmultiset_partitionsmultiset_permutations	necklacesnumbered_symbols
partitionspermutations	postfixesprefixesreshaperotate_leftrotate_rightrunssiftstrongly_connected_componentssubsetstaketopological_sort	unflattenuniq
variationsordered_partitions	rotationsis_palindromiciterableNotIterablemultiset_derangementssequence_partitionssequence_partitions_empty)factoring_visitormultiset_partitions_taocp)S)raiseswarns_deprecated_sympyzw,x,y,zc               	   C   sp   ddl m} m} t " t|ttgttgks4tW 5 Q R X t " tttg| dttgksbtW 5 Q R X d S )Nr   default_sort_keyr   key)	sympy.utilities.iterablesrK   r   rI   listyxAssertionErrorsortedrJ    rT   e/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/sympy/utilities/tests/test_iterables.pytest_deprecated_iterables!   s
    &rV   c                   C   s   t dstt dstt ds$tt ds0tt dr<tt drHtt ddsVtt dd	rdtt dd	d
sttt dd	dstt ddstt dd	rtt dd	dstd S )N rQ   ZxxZxyxZxyZxyzxZxxyzzyx         Zxxyzyx   )r?   rR   rT   rT   rT   rU   test_is_palindromic)   s    r]   c                     s<  t dddgkstt ttffttgks.tddgdgg t  dd ksPtt  dddddgksjtt  ddd	d
ddddgkstt  ddd	d
ddddgksttt fdd G dd dt} t | tttg| tttgkstt | tttg| dtttgkstt dddhtdddhks8td S )N)rX   rX   rX   )rZ   rX   rY   r   r   r   ZlevelsrY   r_   rZ      c                      s   t  ddS )NrZ   rb   )r   rT   ZlsrT   rU   <lambda>D       ztest_flatten.<locals>.<lambda>c                   @   s   e Zd ZdS )ztest_flatten.<locals>.MyOpN__name__
__module____qualname__rT   rT   rT   rU   MyOpF   s   rk   cls   )	r   rR   rQ   rH   
ValueErrorr   rP   zrO   )rk   rT   rd   rU   test_flatten9   s      $&rq   c               	   C   s  t t dgkstt tg g ks(tt tdddgdddgksHtttddgddd	gd
dddddgksttttddgddgddgddddddddgksttttjdksttttjtjdkstdttjkstdttjtjkstdttjtjtjkstttttjtjtjd} | D ]<\}}}t	|t
sXtt	|t
shtt	|t
s>tq>tttddgd  D ]"}|ttjtjtjkstqd S )NrT   rX   rY   rc   r^   rY   rc      r\   rX   rc   rX   rt   rX   r\   rY   rc   rY   rt   rY   r\   r   r   r   r   r   r   rX   r   rX   r   r   rX   rX   rX   r   r   rX   r   rX   rX   rX   r   rX   rX   rX   T)rt   r\   rX   rY   rc   i  r_   )rO   r$   rR   rS   r@   rG   ZIntegerssetr   
isinstancer   r   range)ZtriplesZn1Zn2Zn3trT   rT   rU   test_iproductO   sB          
       
r   c                	   C   sp  t g g kstt g ddg ks$tt dgdggks:tt dgdddgksRtt ddgddggksltt ddgdddgkstt dddgdddggkstt dddgdddgkstt dddgdgdgdggkstt dddgdddddgkstt ddddddd	d	gddgdddgdgd	d	ggks>tt ddddddd	d	gdddd
ddgksltd S )NF)ZmultiplerX   rX   rX   r`   ru   rY   rY   rX   rc   rx   rc   rY   )r!   rR   rT   rT   rT   rU   
test_groupe   s     "":  r   c                  C   sR  t tdddgddgkstt tdddgddddgks@tt tdddgdd	d
dgksbtt tdddgddgkstt td} t t| ddddgkstt t| dddddddgkstt t| ddddddddd	d
dddg
kstt t| dddddddddddd d!d"d#d$d%dd&d'd(d)d*gks<ttt t| dddd+ks\tt t| d d dd,dg kstt t| d d ddddddd"gkstt tddgddddddd	dgkstt tddgd,ddddd	gkstt tdddgdd	d
dgks tt tdddgddddd	d
dddgksNtd S )-NrX   rY   rc   r   rT   r^   rr   rs   r`   ru   rx   r   rt   TZ
repetitionr   ra   r   rX   r   rY   r   rc   r   rY   rY   rc   rc   r{   r|   )r   r   rY   )r   r   rc   r~   r   rX   rY   r   rX   rc   )r   rY   rY   r   rY   rc   )r   rc   rc   r   )rX   rX   rY   )rX   rX   rc   )rX   rY   rY   )rX   rc   rc   )rY   rY   rY   )rY   rY   rc   )rY   rc   rc   )rc   rc   rc   #   F)rO   r7   rR   r   lenlrT   rT   rU   test_subsetsz   sn    """    
         
 $



r   c                  C   s  t td} t t| ddddgks(tt t| dddddd	d
gksJtt t| dddddddddddddddgks|tt t| ddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0gkstt t| dd1ddgkstt t| dd1dddd	d
gkstt t| dd1dd2ddddd3ddddd4ddddd5gksBttt t| dd1dd6ksbttt t| dd1dd7kstt t| d d dddg kstt t| d d dd1dd8d9d:d;d<d=d>d?gkstd S )@Nrt   r   Fr   rT   rX   r   r^   rr   rs   rY   r   r   r   rX   r   r`   ru   )rY   r   r   rx   )rc   r   rc   rX   r   rc   r   r   r   rY   rX   r   )r   rc   rX   )r   rc   rY   rX   r   rY   )rX   r   rc   rX   rY   r   r   )rX   rc   r   )rX   rc   rY   rY   r   rX   )rY   r   rc   rY   rX   r   )rY   rX   rc   )rY   rc   r   )rY   rc   rX   )rc   r   rX   )rc   r   rY   )rc   rX   r   )rc   rX   rY   )rc   rY   r   )rc   rY   rX   Tra   r   r   r   @      r{   r|   r}   r~   r   r   r   r   )rO   r   r<   rR   r   r   rT   rT   rU   test_variations   sF    "2J$          $      r   c                   C   s   t tddgdddgdddd	d
dgks,tt t dgks@tt tddgksVtt tddddgksptt tt tdddgkstd S )NrX   rY   rc   rt   r\   ru   rv   rw   rx   ry   rz   rT   a)r   )repeat)r   r   r   r^   )rO   r   rR   r   rT   rT   rT   rU   test_cartes   s    r   c                  C   s2   t  } t| td}t|dttdks.td S )Nzx0 x2 x3rc   zx1 x4 x5)r,   r   r
   r8   rO   rR   )sfilteredrT   rT   rU   test_filter_symbols   s    r   c                  C   sD   t td} tt| tsttt ddtdgdtdks@td S )Nrl   CrX   ZC1)startexcludeZC2)r,   r	   r   nextrR   r
   )r   rT   rT   rU   test_numbered_symbols   s
    
r   c                   C   s   t ttddd ddgdddgd	ks.tt ttgd
d tgtgdksRtt tjgdd ddgiksrtt ddddgdd ddddgddgfkstt ddddgdd dddgdddgfksttt	dd  d S )Nr\   c                 S   s   | d S NrY   rT   _rT   rT   rU   re      rf   ztest_sift.<locals>.<lambda>rX   rc   r   rY   rt   r   c                 S   s
   |  tS NhasrQ   r   rT   rT   rU   re      rf   )FTc                 S   s
   |  tS r   r   r   rT   rT   rU   re      rf   Fc                 S   s   | d S r   rT   rQ   rT   rT   rU   re      rf   Tbinaryc                 S   s   | d dkS )Nrc   rX   rT   r   rT   rT   rU   re      rf   c                   S   s   t ddddgdd ddS )	Nr   rX   rY   rc   c                 S   s   | d S )Nrc   rT   r   rT   rT   rU   re      rf   z-test_sift.<locals>.<lambda>.<locals>.<lambda>Tr   )r5   rT   rT   rT   rU   re      s    )
r5   rO   r   rR   rQ   rP   rG   ZOnerH   ro   rT   rT   rT   rU   	test_sift   s    .$  
 
r   c                  C   sd   t  } t| dttdks tt| dttdks:ttdddddgddddddgks`td S )Nr\   zx0:5zx5:10rX   rY   rc   rt   )r,   r8   rO   r
   rR   )XrT   rT   rU   	test_take   s    r   c                   C   s   t i dtttidtttiks"tt dtttii dtttiksDtt dtidtttidtdtttiksntt dtttidtidtdtttikstt ttddtttidtdtttikstt dtttittddtdtttikstd S )NrX   rY   r`   )r   rQ   rP   rp   rR   rT   rT   rT   rU   test_dict_merge   s    ""**,r   c                
   C   s   t tg g kstt tdgdggks.tt tddgdgddggksPtt tdddddgdgddgdddgddddgdddddggkstd S NrX   rY   rc   rt   r\   )rO   r0   rR   rT   rT   rT   rU   test_prefixes   s    "*r   c                
   C   s   t tg g kstt tdgdggks.tt tddgdgddggksPtt tdddddgdgddgdddgddddgdddddggkstd S r   )rO   r/   rR   rT   rT   rT   rU   test_postfixes   s    "*r   c                	      s   ddddddddgd	d
dddddddg	 t  fddddddddgksNtt  fdd dddddddddgkszttt fdd d S )NrY   rc   r\         	   
   rn   )r   rn   r   r   )r\   rn   )rc   r   )rc   r   )rn   rY   )rn   r   )rn   r   )r   r   c                 S   s   |  S r   rT   )vrT   rT   rU   re   	  rf   z'test_topological_sort.<locals>.<lambda>rL   c                      s   t  dg fS )N)r   r   )r9   rT   EVrT   rU   re     rf   )r9   rR   rH   ro   rT   rT   r   rU   test_topological_sort  s        $r   c                  C   s   t g g fg kstt dddgg fdgdgdggks:tdddg} dddddg}t | |fdddggksntdddd	g} ddd
dg}t | |fd	gddgdggkstdddd	g} ddddg}t | |fddgdd	ggkstd S )NrX   rY   rc   r`   ru   r   rx   r   rt   r   rc   rt   )rt   rc   )r6   rR   r   r   rT   rT   rU   "test_strongly_connected_components  s    &
"r   c                  C   s   t g g fg kstt dddgg fdgdgdggks:tdddg} dddddg}t | |fdddggksntdddd	g} ddd
dg}t | |fdddd	ggkstdddd	g} ddg}t | |fddgdd	ggkstd S )NrX   rY   rc   r`   ru   r   rx   r   rt   r   r   )r   rR   r   rT   rT   rU   test_connected_components   s    &
r   c                  C   s   dddddg} t | ddddddgks*tt| ddddddgksFtg } t| d}|g ks`t|d | g ksvtt | d}|g kst|d | g kstd S )Nr   rX   rY   rc   rt   )r2   rR   r3   append)ABrT   rT   rU   test_rotate1  s    



r   c               $   C   sH  dddddg} t t| ddgdgdgdgdgggks:ttt t| ddksTttt t| ddksntt tdddddgdddddgdggdddgddggddddgdggdddgddggddgdddgggkstt tddddgddddgdggddgddggdddgdggddgddgggks6tt tddddgddddgdggdddgdggddgddggdddgdggddgddggddgddggdgdddgggkstt tdddgdddgdggdgddgggkstt tddddggddgdggddgdggdgddggdgdgdgggks@tt tddddgdggddgdggdgddgggks|tt tdgd ddgddgggkstt tdgd dddggdgddggdgdgdgggkstdddg}t t|t tt|kstt t|dg ks*tt t|ddddgggksLtt t|dg dg ksjtt t|dg dddddgggkstt tddg kstt tddddgggkstt td	d	gggkstt td	dg ks tt td
d	dggd	gdgggks(tt td
dd	dgggksHtt tdddggksdtt tddgdddgggkstdddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0g$}d1d2 td3D |kstd4gd5dgd6dgdd7gdddgd7ddgddddgg}d8d2 tddgD |ksDtd S )9Nr   rX   rY   rc   rt   r\   r      r   abbaaa)Zmpsyy)ZmpsyrP   )mpsyy)r   rP   rP   )Zmpyyr   )mpysy)r   r   rP   )mpsyy)r   r   rP   )r   r   r   )r   r   rP   rP   )Zmsyyp)msypy)r   r   rP   )mspyy)r   r   rP   )r   r   r   )r   r   rP   rP   )myyps)r   r   r   )mypsy)r   r   rP   )r   r   r   )r   r   r   )r   r   r   rP   )mZpsyy)r   r   rP   )r   r   r   )r   r   rP   rP   )r   r   r   )r   r   r   )r   r   r   rP   )r   r   r   )r   r   r   rP   )r   r   r   r   )r   r   r   rP   rP   c                 S   s   g | ]}t d d |D qS )c                 s   s   | ]}d  |V  qdS rW   Njoin).0partrT   rT   rU   	<genexpr>{  s     z6test_multiset_partitions.<locals>.<listcomp>.<genexpr>)tupler   r   rT   rT   rU   
<listcomp>{  s   z,test_multiset_partitions.<locals>.<listcomp>Zsympy   r      r[   c                 S   s   g | ]}t |d dgqS rx   )rE   r   rT   rT   rU   r     s   )rO   r)   rR   r   rS   rF   )r   r   ansZ
factoringsrT   rT   rU   test_multiset_partitionsA  s    ,   
       

     *
  


"* ( $                     
 

r   c                  C   s  ddddddddd	d
dddddg} dd t tddD | ksBttd}dd t t|dD | ksjtdd t|dD g kstt tdgddggddgddgggksttt tdddksttt tdddkstt tdddgdgdggks
tttdd  d S ) NZiiiZiimZiipZiisimpZimsZippipsZissZmppr   ZmssZppsZpssZsssc                 S   s   g | ]}d  |qS rW   r   r   irT   rT   rU   r     s     z.test_multiset_combinations.<locals>.<listcomp>Zmississippirc   c                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r     s     c                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r     s        rX   rY   r   r   abcr   cc                   S   s   t tddddS )Nrc   rZ   r   rY   )rO   r(   rT   rT   rT   rU   re     rf   z,test_multiset_combinations.<locals>.<lambda>)rO   r(   rR   r'   r   rH   ro   )r   MrT   rT   rU   test_multiset_combinations  s4          ,$r   c                     s  ddddddddd	d
ddg} dd t dD | ks6tdd t tdD | ksTttt dddgdddggksvttt dddgdddgddgddgddgddgddggkstttt dddkstttt dddkstg i dfD ]}tt |g gkstqtt |dg gks*ttt |dg ksBttt |dg ksZtdd  t fddtdkstttdd  d S )NZabbyZabybZaybbbabyZbaybZbbayZbbyaZbyabZbybaZyabbZybabZybbac                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r     s     z.test_multiset_permutations.<locals>.<listcomp>c                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r     s     r   rY   rX   r   rc   rW   rZ   c                  S   s>   t ddD ].} t|  tdddddg| D ]}t| q*q
d S )NrX   r   r   )r   printr*   )r   r   rT   rT   rU   test  s    z(test_multiset_permutations.<locals>.testc                      s     S r   rT   rT   r   rT   rU   re     rf   z,test_multiset_permutations.<locals>.<lambda>a          1
        [0]
        [1]
        2
        [0, 0]
        [0, 1]
        [1, 0]
        [1, 1]
        3
        [0, 0, 0]
        [0, 0, 1]
        [0, 1, 0]
        [0, 1, 1]
        [1, 0, 0]
        [1, 0, 1]
        [1, 1, 0]
        4
        [0, 0, 0, 1]
        [0, 0, 1, 0]
        [0, 0, 1, 1]
        [0, 1, 0, 0]
        [0, 1, 0, 1]
        [0, 1, 1, 0]
        [1, 0, 0, 0]
        [1, 0, 0, 1]
        [1, 0, 1, 0]
        [1, 1, 0, 0]
        5
        [0, 0, 0, 1, 1]
        [0, 0, 1, 0, 1]
        [0, 0, 1, 1, 0]
        [0, 1, 0, 0, 1]
        [0, 1, 0, 1, 0]
        [0, 1, 1, 0, 0]
        [1, 0, 0, 0, 1]
        [1, 0, 0, 1, 0]
        [1, 0, 1, 0, 0]
        [1, 1, 0, 0, 0]
        6
c                   S   s   t tdddS )Nrc   rZ   r   )rO   r*   rT   rT   rT   rU   re     rf   )	r*   rR   r'   rO   r   r   r   rH   ro   )r   nulrT   r  rU   test_multiset_permutations  s6       "     
(r  c               	   C   s  i gdi fgg} t dD ]}ttd|d| | ks8tttdd|d| | ksVtttddd|d| | ksvtttddd |d| | kstttdd d|d| | kstttddd|d| | kstqttdddddidddd	ddddigkstttdddddidddd
dddddidddd	ddddigks\tttdd	ddd	diddddddddddg  krdd tdd	ddD ksn ttttdddddidddgkstttd	dddddddiddddd	ig  kr6dd td	D ks<n tt ddD ]L}d}t|D ]&\}}|t||ksrt|d7 }qV|t|ksFtqFd S )Nr   rY   )sizerX   r[   )krc   r`   rt   r   ru   r   )r  r   )rX   rc   rt   ry   rx   c                 S   s2   g | ]*}t d d |D rt| dkr|qS )c                 s   s   | ]}|d kV  qdS )rt   NrT   r   r  rT   rT   rU   r     s     -test_partitions.<locals>.<listcomp>.<genexpr>rc   )allsumvaluesr   rT   rT   rU   r     s    z#test_partitions.<locals>.<listcomp>)r   c                 S   s"   g | ]}t d d |D r|qS )c                 s   s   | ]}|d kV  qdS )rc   NrT   r  rT   rT   rU   r     s     r  )r  r   rT   rT   rU   r     s     )r   rO   r-   rR   rG   r   r   r   )r   r   nr   qrT   rT   rU   test_partitions  sj       "    
     
      
r  c                   C   s   dd t dD ddgdddgdddgddddgddddgdddddgddddddgdddddddgdddddgddddddgdddddddgddddddddgdddddddddg	ddddddddddg
gksttdd t d	D d
kstd S )Nc                 S   s   g | ]}|d d  qS r   rT   r   rT   rT   rU   r      s     z*test_binary_partitions.<locals>.<listcomp>r   r   rY   rX   rt   c                 S   s   g | ]}|d d  qS r   rT   r   jrT   rT   rU   r     s        $   )r   rR   r   rT   rT   rT   rU   test_binary_partitions  s     
 
      
r  c                  C   s   dd t ddD dd t ddD ks,tttdddd	d
ddgksLtt ddD ]<} tt | }t| }|D ]}|t|jkst| }qrqVtt	dd  d S )Nc                 S   s   g | ]}t tt|qS rT   )r   r   r   r   rT   rT   rU   r   
  s     z"test_bell_perm.<locals>.<listcomp>rX   r   c                 S   s   g | ]}t |qS rT   r   r   rT   rT   rU   r   
  s    rc   r   r   r   r   r   r   r\   c                   S   s   t tdS )Nr   )rO   r   rT   rT   rT   rU   re     rf   z test_bell_perm.<locals>.<lambda>)
r   rR   rO   r   r   r   Z
array_formZnext_trotterjohnsonrH   ro   )r  r   r   ZbirT   rT   rU   test_bell_perm	  s$    
     
r  c                  C   s`   ddddddg} t | D ]B\}}tt|d }t||ks@ttdd |D dkstqd S )	NrX   rY   rt   r      L   c                 S   s   h | ]}t |d  qS rr   )r   r  rT   rT   rU   	<setcomp>  s     z#test_involutions.<locals>.<setcomp>)	enumeraterO   r   r   rR   )lengthsr  Nr   rT   rT   rU   test_involutions  s
    r  c                  C   sV  t ttttddks tddd tdD dks@tttdd	d
dgd	ddd
gd	d
ddgd	ddd
gd
ddd	gd
ddd	gd
dd	dgddd	d
gdd
dd	gdd
d	dgg	kstttdd	d
d
gd
d
dd	gd
d
d	dggkstttdtdgkstt} t| dg kstdd | dD dgks:tdd | dD ddgksZtdd | dD dgksxtdd | dD ddddddgkstd d | d!D d"d#d$d%d&d'd(d)d*d+d,d-gkstd.d | d/D d0d1d2d3d4d5d6d7d8d9d:d;gkstttdgd
gd
gd	ggd
gd	gdgd
ggd
gdgd	gd
gggksRtd S )<Nr[   i	  rW   c                 s   s   | ]}d  |V  qdS r   r   r   rT   rT   rU   r   $  s     z$test_derangements.<locals>.<genexpr>abcdeZbadecbaecdbcaedbcdeabceadbdaecbdeacbdecabeacdbedacbedcacabedcadebcaebdcdaebcdbeacdeabcdebaceabdcebadcedabcedbadabecdaebcdaecbdcaebdcbeadceabdcebadeabcdeacbdebacdebcaeabcdeadbceadcbecabdecbadecdabecdbaedabcedacbedbacedbcar   rX   rY   rc   bar   Zabbc                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r   2  s     z%test_derangements.<locals>.<listcomp>c                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r   3  s     r   ZbcaZcabc                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r   4  s     ZaabbZbbaac                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r   5  s     ZaabbccccZccccaabbZccccababZccccabbaZccccbaabZccccbabaZccccbbaac                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r   8  s     ZaabbcccZcccabbaZcccababZcccaabbZccacbbaZccacbabZccacabbZcbccbaaZcbccabaZcbccaabZbcccbaaZbcccabaZbcccaabc                 S   s   g | ]}d  |qS r   r   r   rT   rT   rU   r   <  s     booksZkbsooZksbooZsbkooZskbooZoksboZoskboZokbsoZobksoZoskobZoksobZosbokZobsok)r   rO   r   r   rR   r   rB   )DrT   rT   rU   test_derangements"  s~     
 
 
 

 
 
 
 


 

                       r  c                  C   s   dd } g }t ddD ].}||| |dd| |dd| |ddf qt|tddddgddddgdd	d	d
gd	dddgddddgddddgddddggkstd S )Nc                 S   s   t tt| ||S r   )r   rO   r+   )r  r  frT   rT   rU   countD  s    ztest_necklaces.<locals>.countrX   r   rY   r   rc   r[   rt   r      r\   '         \   r            )r   r   r   rR   )r!  r   r   rT   rT   rU   test_necklacesC  s$     
 
 







r*  c                  C   s   t tdd} t| tddgddgddgddgddgddgddgddgddgddgg
ks^tt tdd} t| tddddgddddgddddgddddgddddgddddggkstd S )NrY   rt   r   rX   rc   )rO   r   r   rR   )bcrT   rT   rU   test_braceletsT  s,    





r,  c                   C   s$  t tddddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddgdddddggksttt tddks td S )	Nr\   r   rX   rY   rc   rt   r   i2  )rO   r    rR   r   rT   rT   rT   rU   test_generate_oriented_forestm  s,                  r-  c                  C   s   t td} t| t t| d d d | dd d ks:tt| dt| d d t| dd  gkshtttdd  ttdd  d S )Nr   rY   rX   r\   c                   S   s   t ttddS )Nr   rc   r:   rO   r   rT   rT   rT   rU   re   {  rf   z test_unflatten.<locals>.<lambda>c                   S   s   t ttddS )Nr   r_   r.  rT   rT   rT   rU   re   |  rf   )rO   r   r:   ziprR   r   rH   ro   )rrT   rT   rU   test_unflattenw  s
    ..r1  c                   C   sd  t g dgg kstt ttddddgks2tt ttdttddddgksZtt dddgdddgddgks|tt dddgdddgdgksttg dgg ksttttddddgksttttdttddddgksttttdttdg ksttdddgdddgddgks>ttdddgdddgdgks`td S )	NrX   rc   r   rY   rt   r\   r   r   )r   rR   rO   r   r   rT   rT   rT   rU   test_common_prefix_suffix  s    (" ($$r2  c                   C   sr   t dddgdkstt ddks&tt ddks6tt ddd	dksJtt d
dksZtt dtddksntd S )NrX   rY   r   r   r   r   r   F)ZdirectedZabaZaab)bbr   r   r   rL   )r   r   r3  r   )r&   rR   r   rT   rT   rT   rU   test_minlex  s    r4  c                      s  t tttftddttgttgfks*tt tttftddt tttftddksZtt tttfttgksvtdddgdddgdddgdgdggdd d	d fg\ t t ddd
dgdgdddgdddgdddggksttt fdd d S )NF)defaultrX   rY   r   rc   c                 S   s   t | S r   )r   r   rT   rT   rU   re     rf   ztest_ordered.<locals>.<lambda>c                 S   s   t | S r   )r	  r   rT   rT   rU   re     rf   r5  warnc                      s   t t dddS )NFTr6  )rO   r   rT   keysseqrT   rU   re     s    )rO   r   rQ   rP   hashrR   rH   ro   rT   rT   r8  rU   test_ordered  s    *""r<  c                  C   s   t g g kstt dgdggks&tt ddgdgdggksBtt dddgdgddggksbtt dddgddgdggkstt dddgdgdgdggkstddlm}  t dddg| ddgdggkstd S )NrX   rY   r   lt)r4   rR   operatorr>  r=  rT   rT   rU   	test_runs  s      "r@  c                  C   s  t tdd} t| dgddddgdddd	ggks6tt| d
ddgksLtt| dddgksbtt| ddgfddddgfdddd	gfgkstt| ddgfdddgfddd	gfgkstt| ddgdfdddgdfdddgd	fgksttt| dgddgfdgddgfdgddgffks*ttt| dgddfdgddfdgddffks^ttt tdddgdhdgdddddgddhdggkstttdd  ttdd  d S )NrX   r   rt   rY   rc   r\   r[   r   r   )rt   )rX   rY   rc   rt   )r\   r[   r   r   r   rr   r`   )r\   r[   r   r   r   )rX   rs   rX   r   )r   )r   r   r   rn   c                   S   s   t ddgdgS )Nr   rX   rZ   r1   rT   rT   rT   rU   re     rf   ztest_reshape.<locals>.<lambda>c                   S   s   t ddgdgS )Nr   rX   rc   rA  rT   rT   rT   rU   re     rf   )rO   r   r1   rR   r   rH   ro   )r:  rT   rT   rU   test_reshape  s<    



rB  c                      s  t tdd tdD ddidddddidddddigksDtt tdd td	D d
dgksjtt tddgkstt tdt dkstt tdgddgdggdgddggkstt ttdd dgddfD dgddfddgdfdddgfgkstt tdddddgdgdgdgdgg	ddddgdgdggksRtdg tt fdd dgg tt fdd d S )Nc                 s   s   | ]
}|V  qd S r   rT   r   rT   rT   rU   r     s     ztest_uniq.<locals>.<genexpr>rt   rX   ru   rY   r`   c                 s   s   | ]}|d  V  qdS )rY   NrT   )r   rQ   rT   rT   rU   r     s     r\   r   r   Zababcr   c                 s   s   | ]
}|V  qd S r   rT   r   rT   rT   rU   r     s     rc   c                      s    fddt  D S )Nc                    s   g | ]}  |qS rT   remover   r   rT   rU   r     s     /test_uniq.<locals>.<lambda>.<locals>.<listcomp>r;   rT   rE  rT   rU   re     rf   ztest_uniq.<locals>.<lambda>c                      s    fddt  D S )Nc                    s   g | ]}  |qS rT   rC  r   rE  rT   rU   r     s     rF  rG  rT   rE  rT   rU   re     rf   )rO   r;   r-   rR   r   r.   rH   RuntimeErrorrT   rT   rE  rU   	test_uniq  s"    $&,  
&
rI  c                      s   t ttdddddkstt ttdddddks<tt ttdddddksZtt ttddd	dd
ksxtt ttddd ddkstdd  t fddtdkstdd tfddtdkstd S )NZ1123rY   rX   r   r   rn   r  r   r   r\   rc   c                  S   s<   dD ]2} t d|  tdddgd| dD ]}t d| q&qd S )NNr   rX   r   rn   	ordered =r   rX   rY   r      )r   r%   Z
orderedvalr   rT   rT   rU   test1  s    
ztest_kbins.<locals>.test1c                      s     S r   rT   rT   )rN  rT   rU   re     rf   ztest_kbins.<locals>.<lambda>a#          ordered = None
            [[0], [0, 1]]
            [[0, 0], [1]]
        ordered = 0
            [[0, 0], [1]]
            [[0, 1], [0]]
        ordered = 1
            [[0], [0, 1]]
            [[0], [1, 0]]
            [[1], [0, 0]]
        ordered = 10
            [[0, 0], [1]]
            [[1], [0, 0]]
            [[0, 1], [0]]
            [[0], [0, 1]]
        ordered = 11
            [[0], [0, 1]]
            [[0, 0], [1]]
            [[0], [1, 0]]
            [[0, 1], [0]]
            [[1], [0, 0]]
            [[1, 0], [0]]
c                  S   s>   dD ]4} t d|  tttdd| dD ]}t d| q(qd S )NrJ  rK  rc   rY   r   rL  )r   r%   rO   r   rM  rT   rT   rU   test2  s    
ztest_kbins.<locals>.test2c                      s     S r   rT   rT   )rO  rT   rU   re     rf   a[          ordered = None
            [[0], [1, 2]]
            [[0, 1], [2]]
        ordered = 0
            [[0, 1], [2]]
            [[0, 2], [1]]
            [[0], [1, 2]]
        ordered = 1
            [[0], [1, 2]]
            [[0], [2, 1]]
            [[1], [0, 2]]
            [[1], [2, 0]]
            [[2], [0, 1]]
            [[2], [1, 0]]
        ordered = 10
            [[0, 1], [2]]
            [[2], [0, 1]]
            [[0, 2], [1]]
            [[1], [0, 2]]
            [[0], [1, 2]]
            [[1, 2], [0]]
        ordered = 11
            [[0], [1, 2]]
            [[0, 1], [2]]
            [[0], [2, 1]]
            [[0, 2], [1]]
            [[1], [0, 2]]
            [[1, 0], [2]]
            [[1], [2, 0]]
            [[1, 2], [0]]
            [[2], [0, 1]]
            [[2, 0], [1]]
            [[2], [1, 0]]
            [[2, 1], [0]]
)r   rO   r%   rR   r   r   rT   rT   )rN  rO  rU   
test_kbins  s    rP  c                   C   st   t t dkstt ttddks*tt dddgdks@tt dgdggdksXtt dgdggdksptd S )NFrc   rX   rY   T)r"   r   rR   rO   r   rT   rT   rT   rU   test_has_dups'  s
    rQ  c                  C   s   t ddddddgddgddgd	ggks,tt ddddddgd
ddgddgd	ggksZtd
dddddgf} t d|  ddgddgd	ggkstd S )Nr  rX   r   rY   r   er   r   drc   )r  )r   rR   )outputrT   rT   rU   test__partition/  s      
  
rU  c               	   C   s   ddl m}  t}t|ddg gks(tt|ddg gks@ttddD ]j}d gttd| D ]P}tdd |||dD tdd |||dD   kr| ||ksbn tqbqJd S )Nr   )nTrX   r   c                 s   s   | ]
}d V  qdS rX   NrT   r   rT   rT   rU   r   @  s     z*test_ordered_partitions.<locals>.<genexpr>c                 s   s   | ]
}d V  qdS rW  rT   r   rT   rT   rU   r   A  s     )Z%sympy.functions.combinatorial.numbersrV  r=   rO   rR   r   r	  )rV  r   r   r  rT   rT   rU   test_ordered_partitions8  s    rX  c                   C   s   t tdddgddggks tt ttddddgdddgdddggksPtt ttddd	dddgdddgdddggkstd S )
Nr   r   r   rc   r   rX   rY   rZ   )dir)rO   r>   rR   r   rT   rT   rT   rU   test_rotationsE  s     0rZ  c                   C   s   t dddgkstt dddddgks,tt ddddks@tt dddddksVttt dd	d
dddgkstttt ddddddddgkstttdd  ttdd  d S )Nrc   rX   r   T)strZ11Z011rY   r  ra   r   r   r   rW   Z00Z0110c                   S   s   t dS )Ng      ࿩r#   rT   rT   rT   rU   re   R  rf   ztest_ibin.<locals>.<lambda>c                   S   s
   t ddS )NrY   rX   r]  rT   rT   rT   rU   re   S  rf   )r#   rR   rO   rH   ro   rT   rT   rT   rU   	test_ibinK  s    "r^  c                  C   s   t ddkstt ddks tt d dks0tG dd dt} t |  dksRtG dd dt}t | dksttG d	d
 d
}t | dkstG dd d}t | dkstG dd d}t | dkstG dd d|}t | dkstd S )Nr   FrX   c                   @   s   e Zd ZdS )ztest_iterable.<locals>.Test1Nrg   rT   rT   rT   rU   Test1[  s   r_  c                   @   s   e Zd ZdZdS )ztest_iterable.<locals>.Test2TNrh   ri   rj   	_iterablerT   rT   rT   rU   Test2`  s   rb  Tc                   @   s   e Zd ZdS )ztest_iterable.<locals>.Test3Nrg   rT   rT   rT   rU   Test3e  s   rc  c                   @   s   e Zd ZdZdS )ztest_iterable.<locals>.Test4TNr`  rT   rT   rT   rU   Test4j  s   rd  c                   @   s   e Zd Zdd ZdS )ztest_iterable.<locals>.Test5c                 s   s
   dV  d S )NrX   rT   )selfrT   rT   rU   __iter__p  s    z%test_iterable.<locals>.Test5.__iter__N)rh   ri   rj   rf  rT   rT   rT   rU   Test5o  s   rg  c                   @   s   e Zd ZdZdS )ztest_iterable.<locals>.Test6FNr`  rT   rT   rT   rU   Test6u  s   rh  )r@   rR   rA   )r_  rb  rc  rd  rg  rh  rT   rT   rU   test_iterableV  s    ri  c                   C   sR  t tdgddgggkstt tddgdddgggks@tt tddgddgdgggksdtt tdddgddddgggkstt tdddgddgddggddgdgggkstt tdddgddgdgdgggkstt tg dg kstt tg dg kstt tddgdg ks2tt tddgdg ksNtd S NrX   rY   rc   r   )rO   rC   rR   rT   rT   rT   rU   test_sequence_partitions{  s    "$&*rk  c                   C   s  t tg dg ggkstt tg dg g ggks6tt tg dg g g ggksTtt tdgddgggksrtt tdgdg dggdgg ggkstt tdgdg g dggg dgg gdgg g ggkstt tddgdddgggkstt tddgdg ddggdgdggddgg ggks,tt tddgdg g ddggg dgdggg ddgg gdgg dggdgdgg gddgg g ggkstt tdddgddddgggkstt tdddgdg dddggdgddggddgdggdddgg ggkstt tdddgdg g dddggg dgddggg ddgdggg dddgg gdgg ddggdgdgdggdgddgg gddgg dggddgdgg gdddgg g gg
kstt tg dg kstt tdgdg kstt tddgdg kstd S rj  )rO   rD   rR   rC   rT   rT   rT   rU   test_sequence_partitions_empty  sN    ( " 
    (2
     	rl  N)textwrapr   	itertoolsr   r   Zsympy.core.basicr   Zsympy.core.numbersr   Zsympy.core.sortingr   Zsympy.core.symbolr	   r
   Z(sympy.functions.combinatorial.factorialsr   Zsympy.matrices.denser   Zsympy.combinatoricsr   r   r   rN   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-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   Zsympy.utilities.enumerativerE   rF   Zsympy.core.singletonrG   Zsympy.testing.pytestrH   rI   wrQ   rP   rp   rV   r]   rq   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-  r1  r2  r4  r<  r@  rB  rI  rP  rQ  rU  rX  rZ  r^  ri  rk  rl  rT   rT   rT   rU   <module>   sv   (				BA+
!
	N	%