HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_itertools.cpython-37.opt-1.pyc
B

��g���@snddlZddlmZddlTddlZddlmZddlmZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlZddlZejZedZdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�d�Zdd�Zdd�Zdd�Z d d!�Z!d"d#�Z"d$d%�Z#d&d'�e$ej%d�D�Z&Gd(d)�d)ej'�Z(Gd*d+�d+ej'�Z)Gd,d-�d-ej'�Z*Gd.d/�d/ej'�Z+d0d1�Z,Gd2d3�d3�Z-Gd4d5�d5�Z.Gd6d7�d7�Z/Gd8d9�d9�Z0Gd:d;�d;�Z1Gd<d=�d=�Z2Gd>d?�d?�Z3d@dA�Z4GdBdC�dCej'�Z5GdDdE�dEej'�Z6GdFdG�dGej'�Z7GdHdI�dIej'�Z8ej9GdJdK�dKej'��Z:dLZ;dMe;iZ<dSdNdO�Z=e>dPk�rje=dQdR�dS)T�N)�support)�*)�Decimal)�Fraction)�reduce�cGstt|��S)N)�list�zip)�args�r�//usr/local/lib/python3.7/test/test_itertools.py�lzipsr
cCsd|S)zTest function of one argument�r)�xrrr�oneargsrcGst�dS)z"Test function that raises an errorN)�
ValueError)r
rrr�errfuncsrccsxdD]
}|VqWdS)zNon-restartable source sequence)rrrNr)�irrr�gen3s
rcCs|ddkS)zTest predicaterrr)rrrr�isEven"srcCs|ddkS)zTest predicaterrr)rrrr�isOdd&srcGs|S)Nr)r
rrr�tupleize*srccsxt|�D]
}|Vq
WdS)N)�range)�nrrrr�irange-src@s eZdZdZdd�Zdd�ZdS)�StopNowz"Class emulating an empty iterable.cCs|S)Nr)�selfrrr�__iter__3szStopNow.__iter__cCst�dS)N)�
StopIteration)rrrr�__next__5szStopNow.__next__N)�__name__�
__module__�__qualname__�__doc__rrrrrrr1srcCstt||��S)zHConvenience function for partially consuming a long of infinite iterable)r�islice)r�seqrrr�take8sr&cCsttj|d�S)Nr)r�operator�mul)�iterablerrr�prod<sr*cCsttd|d��S)Z	Factorialr)r*r)rrrr�fact?sr+cCs|dS)Nrr)�rrrr�testRDsr-cCs|dS)Nrr)r,rrr�testR2Gsr.cCs|dkS)N�
r)rrrr�undertenJsr0cCsg|]}|fdd��qS)cSst�t�||��S)N)�pickle�loads�dumps)�s�protorrr�<lambda>M�z<listcomp>.<lambda>r)�.0r5rrr�
<listcomp>Msr9c@s�eZdZdcdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	e
jdd��Ze
�
d�dd��Zdd�Ze
jdd��Ze
�
d�dd��Zdd�Ze
jdd ��Ze
�
d�d!d"��Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Ze
�
d�d7d8��Zd9d:�Z e
�
d�d;d<��Z!d=d>�Z"d?d@�Z#dAdB�Z$e
jdCdD��Z%e
�
d�dEdF��Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2d_d`�Z3dadb�Z4dS)d�TestBasicOps�rNcsd��fdd�	�t�||�}t�|�}|�t|�t|���|��|�}}	|�||	�|rp�|�}
|�||
�t�|�}d}y&x t|�D]}
t|�|d7}q�WWntk
r�YnXt�||�}t�|�}�|��|�}}	|�||	�|�r�||d��}
|�||
�dS)zITest that an iterator is the same after pickling, also when part-consumedrcsZ�dkrtd��t|t�r|Sytt|���}Wntk
rD|SX��fdd�|D�S)Nr/zinfinite recursion encounteredcsg|]}�|�d��qS)rr)r8�e)�expandrrrr9^sz;TestBasicOps.pickletest.<locals>.expand.<locals>.<listcomp>)�RuntimeError�
isinstance�strrr$�	TypeError)�itr�l)r=�stop)rrr=Ts
z'TestBasicOps.pickletest.<locals>.expandrN)r)r1r3r2�assertEqual�typer�nextr)rZprotocolrBrDr&�compare�dumpZi2�a�b�cZi3ZtookrZi4r)r=rDr�
pickletestRs0



zTestBasicOps.pickletestcCs,|�tttd���ddddddddd	d
g
�|�tttd�d��ddddddddd	d
g
�xPttttfD]@}|�ttt|td����tt|ddddddddd	d
g
���qhW|�ttd��d
ddg�|�ttg��g�|�ttdg��dg�|�	t
ttd�dd�|�	t
t�|j	t
ttd�d�|�	t
ttdgg��ddddddddddg
}|�tt|t��ddddddddddg
�|�tt|t��ddddddddddg
�|�tt|t
j��ddddddddddg
�|�	t
��tt|t��WdQRXx,ttjd�D]}|�|ttd����q
WdS)Nr/rr������$�-)r)�abcrJ�ab��)rr��	r;��i�i�)rEr�
accumulater�int�complexrr�map�assertRaisesrA�min�maxr'r(�chrr1�HIGHEST_PROTOCOLrM)r�typr4r5rrr�test_accumulate{s4(zTestBasicOps.test_accumulatecCs�dd�}x�t|fD]z}|�t|dd��td��|�t|d��td��|�t|d��g�|�td|dd��td��|�tt|d	d
��qWdS)Ncws&x |D]}x|D]
}|VqWqWdS)zPure python version in the docsNr)�	iterablesrB�elementrrr�chain2�s

z'TestBasicOps.test_chain.<locals>.chain2rU�def�abcdef�r;�abcdrrN)�chainrErr&rarA)rrjrLrrr�
test_chain�szTestBasicOps.test_chaincCs�|�tt�ddg��td��|�tt�dg��td��|�tt�dg��g�|�tdt�ddg��td��|�ttt�ddg��dS)	NrUrkrlrmr;rnrrN)rErro�
from_iterabler&rarA)rrrr�test_chain_from_iterable�s
 z%TestBasicOps.test_chain_from_iterablec	Cs�x�tjgtD]�}tdd�}|�t||��td��|�t|�d�|�t||��td��|�t|td���g�|�td|tdd���td��|�t	t|td	d
���qWx0t
tjd�D]}|j
|tdd�td�d�q�WdS)
NrUrkrlrJZbcdefrmr;rnrrNr)rH)�copy�deepcopy�
picklecopiersrorErrGr&rarArr1rerM)rZoperrBr5rrr�test_chain_reducible�s
 z!TestBasicOps.test_chain_reduciblec
Cs�|�tt�jd�|�tt�jg�|�tt�jd�|�tt�jgf�|�tt�jtg�gf�t�}|�tddg�f�|�t|�ddddd	d
g�t�}|�tddg�tdg�f�|�t|�dddddd	d
g�dS)NrrrUrkrJrKrL�dr<�fZghi)rarAro�__setstate__�iterrEr)rrBrrr�test_chain_setstate�sz TestBasicOps.test_chain_setstatec

s�|�ttd�|�ttddd�|�ttd�|�ttdd�x�dd�gtD]�}|�t|tdd���g�|�t|tdd���d	d
ddd
dg�tdd�}t|�|�t||��d
ddd
dg�|�t|ttd�d���ddddg�ttd�d�}t|�|�t||��dddg�qNWdd�}dd�}dd�}�x�td�D�]�}dd�t|�D���xtt|d�D�]b}tt�|��}|�t	|�||k�r�dnt
|�t
|�t
||��|�t	|�t	t|���|�|t|��x�|D]x�|�t	��|�|�t	t���|�|�t��t���|�
t�fdd ��D���|�t���fd!d��D���q�W|�|t|�|���|�|t|�|���|�|t|�|���x*ttjd�D]}	|�|	t�|���q�W�qhW�q@WdS)"NrUrr���cSs|S)Nr)rJrrrr6�r7z0TestBasicOps.test_combinations.<locals>.<lambda>� �ABCD)�A�B)r�C)r�D)r�r�)r�r�)r�r�r;rN)rrr)rrrN)rrrN)rrrNc3s�t|��t��}||krdStt|��}t�fdd�|D��Vx�x.tt|��D]}|||||krPPqPWdS||d7<x*t|d|�D]}||dd||<q�Wt�fdd�|D��VqBWdS)z%Pure python version shown in the docsNc3s|]}�|VqdS)Nr)r8r)�poolrr�	<genexpr>�szHTestBasicOps.test_combinations.<locals>.combinations1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r8r)r�rrr��s)�tuple�lenrr�reversed)r)r,r�indicesr�jr)r�r�
combinations1�sz5TestBasicOps.test_combinations.<locals>.combinations1c3sTt|��t��}x>tt|�|�D],}t|�t|�kr t�fdd�|D��Vq WdS)z%Pure python version shown in the docsc3s|]}�|VqdS)Nr)r8r)r�rrr��szHTestBasicOps.test_combinations.<locals>.combinations2.<locals>.<genexpr>N)r�r��permutationsr�sortedr)r)r,rr�r)r�r�
combinations2�s
z5TestBasicOps.test_combinations.<locals>.combinations2c3sTt|��t��}x>tt|�|�D],}tt|��|kr t�fdd�|D��Vq WdS)zPure python version from cwr()c3s|]}�|VqdS)Nr)r8r)r�rrr�szHTestBasicOps.test_combinations.<locals>.combinations3.<locals>.<genexpr>N)r�r��combinations_with_replacementr�set)r)r,rr�r)r�r�
combinations3�s
z5TestBasicOps.test_combinations.<locals>.combinations3rWcSsg|]}d|d�qS)rX�r)r8rrrrr9sz2TestBasicOps.test_combinations.<locals>.<listcomp>rc3s|]}|�kVqdS)Nr)r8r<)�valuesrrr�sz1TestBasicOps.test_combinations.<locals>.<genexpr>csg|]}|�kr|�qSrr)r8r<)rLrrr9s)rarA�combinationsrrurErrGrr�r+r�r��
assertTrue�allr1rerM)
r�op�testIntermediater�r�r�rr,�resultr5r)rLr�r�test_combinations�sP
6

zTestBasicOps.test_combinationsc	Cs(|�ttf��tdd�WdQRXdS)N�AAi )ra�
OverflowError�MemoryErrorr�)rrrr�test_combinations_overflowsz'TestBasicOps.test_combinations_overflowz"tuple reuse is specific to CPythonc
CsH|�tttttdd����d�|�ttttttdd�����d�dS)N�abcderNr)rEr�r�r`�idr��assertNotEqualr)rrrr�test_combinations_tuple_reuses z*TestBasicOps.test_combinations_tuple_reusec

s�t}|�t|d�|�t|ddd�|�t|d�|�t|dd�xldd�gtD]Z}|�t||dd���dd	d
ddd
g�|dd�}t|�|�t||��d	d
ddd
g�qRWdd�}dd�}dd�}�x�td�D�]�}dd�t|�D���x�t|d�D�]�}t|�|��}	|�t	|	�|||��|�t	|	�t	t
|	���|�|	t|	��tt�|��}
|dk�sp|dk�r~|�|	|
�n|�
t
|	�t
|
�k�x�|	D]��|�t	��|�dd�t��D�}|�t	|�t	t
|���|�t��t���|�
t�fdd��D���|�|�fdd��D���q�W|�|	t|�|���|�|	t|�|���x*ttjd�D]}|�||�|���qdWq�Wq�WdS)NrUrrr|cSs|S)Nr)rJrrrr6*r7zATestBasicOps.test_combinations_with_replacement.<locals>.<lambda>�ABC)rr)rr�)rr�)r�r�)r�r�)r�r�c3s�t|��t��}|s|rdSdg|}t�fdd�|D��Vxfx*tt|��D]}|||dkrNPqNWdS||dg||||d�<t�fdd�|D��Vq@WdS)z%Pure python version shown in the docsNrc3s|]}�|VqdS)Nr)r8r)r�rrr�;szPTestBasicOps.test_combinations_with_replacement.<locals>.cwr1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r8r)r�rrr�Cs)r�r�r�r)r)r,rr�rr)r�r�cwr13s
z=TestBasicOps.test_combinations_with_replacement.<locals>.cwr1c3sVt|��t��}x@tt|�|d�D],}t|�t|�kr"t�fdd�|D��Vq"WdS)z%Pure python version shown in the docs)�repeatc3s|]}�|VqdS)Nr)r8r)r�rrr�KszPTestBasicOps.test_combinations_with_replacement.<locals>.cwr2.<locals>.<genexpr>N)r�r��productrr�r)r)r,rr�r)r�r�cwr2Es
z=TestBasicOps.test_combinations_with_replacement.<locals>.cwr2cSs4|s|rdSdSt||d�t|�t|d�S)Nrr)r+)rr,rrr�numcombsMszATestBasicOps.test_combinations_with_replacement.<locals>.numcombsrWcSsg|]}d|d�qS)rXr�r)r8rrrrr9SszCTestBasicOps.test_combinations_with_replacement.<locals>.<listcomp>rcSsg|]\}}|�qSrr)r8�k�vrrrr9csc3s|]}|�kVqdS)Nr)r8r<)r�rrr�fszBTestBasicOps.test_combinations_with_replacement.<locals>.<genexpr>csg|]}|�kr|�qSrr)r8r<)rLrrr9hs)r�rarArrurErrGrr�r�r�r�r��groupbyr�r1rerM)
r�cwrr�r�r�r�r�rr,r�Z
regular_combsZnorunsr5r)rLr�r�"test_combinations_with_replacement#sL

z/TestBasicOps.test_combinations_with_replacementc	Cs(|�ttf��tdd�WdQRXdS)Nr�i@)rar�r�r�)rrrr�+test_combinations_with_replacement_overflowosz8TestBasicOps.test_combinations_with_replacement_overflowc
CsLt}|�tttt|dd����d�|�ttttt|dd�����d�dS)Nr�rNr)r�rEr�r�r`r�r�r)rr�rrr�.test_combinations_with_replacement_tuple_reuseus z;TestBasicOps.test_combinations_with_replacement_tuple_reusec	s |�tt�|�ttddd�|�ttd�|�ttdd�|�ttdd��g�|�ttdd�|�tttd�d��dd	d
ddd
g�ddd�}ddd�}�x|td�D�]n}dd�t|�D���xTt|d�D�]B}tt�|��}|�t|�||kr�dnt|�t||��|�t|�tt	|���|�|t
|��xN|D]F}|�t|�|�|�tt	|��|�|�t�fdd�|D����q>W|�|t|�|���|�|t|�|���||k�r�|�|tt�d���|�|tt����x*tt
jd�D]}|�|t�|���q�Wq�Wq�WdS)NrUrrr|r}r4rN)rr)rr)rr)rr)rr)rrc3s@t|��t��}|dkr|n|}||kr,dStt|��}tt||d|d��ddd�}t�fdd�|d|�D��Vx�|�r:x�tt|��D]�}||d8<||dkr�||dd�|||d�||d�<||||<q�||}||||||<||<t�fdd�|d|�D��VPq�WdSq~WdS)z%Pure python version shown in the docsNr���c3s|]}�|VqdS)Nr)r8r)r�rrr��szHTestBasicOps.test_permutations.<locals>.permutations1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r8r)r�rrr��s)r�r�rrr�)r)r,rr�Zcyclesrr�r)r�r�
permutations1�s&$ ( z5TestBasicOps.test_permutations.<locals>.permutations1c3sft|��t��}|dkr|n|}x@tt|�|d�D],}tt|��|kr2t�fdd�|D��Vq2WdS)z%Pure python version shown in the docsN)r�c3s|]}�|VqdS)Nr)r8r)r�rrr��szHTestBasicOps.test_permutations.<locals>.permutations2.<locals>.<genexpr>)r�r�r�rr�)r)r,rr�r)r�r�
permutations2�sz5TestBasicOps.test_permutations.<locals>.permutations2rWcSsg|]}d|d�qS)rXr�r)r8rrrrr9�sz2TestBasicOps.test_permutations.<locals>.<listcomp>rc3s|]}|�kVqdS)Nr)r8r<)r�rrr��sz1TestBasicOps.test_permutations.<locals>.<genexpr>)N)N)rarAr�rrErrr�r+r�r�r�r�r1rerM)rr�r�rr,r��pr5r)r�r�test_permutations{s8

	,
"
zTestBasicOps.test_permutationsc	Cs(|�ttf��tdd�WdQRXdS)Nri@)rar�r�r�)rrrr�test_permutations_overflow�sz'TestBasicOps.test_permutations_overflowc
CsH|�tttttdd����d�|�ttttttdd�����d�dS)Nr�rNr)rEr�r�r`r�r�r�r)rrrr�test_permutations_tuple_reuse�s z*TestBasicOps.test_permutations_tuple_reusec	s(�x td�D�]}dd|�}�x�td�D�]�tt|�d��}tt|���}tt|���}tt|���}|�t|�|��|�t|�|r�t|�d�t��t|d�n��|�t|��|kr�dnt|�t|���|�t|��|kr�dnt|�t��t|���|�|t	t
|���|�|t	t
|���|�|t	t
|���|�|t	t
|���|�|dd�|D��|�|�fd	d�|D��|�|d
d�|D��|�|�fdd�|D��|�|ttt
|�j|���|�|ttt
|�j|���|�|t	t
|�t
|�@��q*WqWdS)NrO�ABCDEFGrY)r�rrcSs g|]}t|�t|�kr|�qSr)r�r)r8�trrrr9�sz3TestBasicOps.test_combinatorics.<locals>.<listcomp>cs g|]}tt|���kr|�qSr)r�r�)r8r�)r,rrr9�scSs g|]}t|�t|�kr|�qSr)r�r)r8r�rrrr9�scs g|]}tt|���kr|�qSr)r�r�)r8r�)r,rrr9�s)
rrr�r�r�r�rEr�r+r�r��filter�__contains__)rrr4r*r�ZpermZcombr)r,r�test_combinatorics�s,:,4zTestBasicOps.test_combinatoricscCs�|�ttdddddddgd��td��|�ttdddddddg��td��|�ttdddddddg��td��|�ttdddddddg��td��|�ttddddg��td��|�ttdddddddg��td	��d
}t�ttd�|��}t�td��}|�tt||��dd
dg|�|�ttdtd��|�tttd�d�|�tttd��|�tttd�d��xdd�dd�gt	D]�}x�dddddddgddfdddddddgddfdddddddgddfddddgddfdddddddgd	dfgD]|\}}}}|�t|t||d���t|��|�t|t||���t|��t||�}|�r�t
|�|�t||��t|���q�W�q�WdS)N�ABCDEFrr)�data�	selectors�ACEFrmZACr�ZBCi'rO)rrrNrXcSs
t�|�S)N)rs)rJrrrr6�r7z,TestBasicOps.test_compress.<locals>.<lambda>cSs
t�|�S)N)rsrt)rJrrrr6�r7ZCEFZBCDEFr�)rEr�compressrorqr�rrarArurG)rrr�r�r�Zresult1Zresult2r�rrr�
test_compress�s6(&&& & & 
zTestBasicOps.test_compressc	Csn|�tdt��dddg�|�tdtd��dddg�|�td	tdtd���ddg�|�td	tdtd
���ddg�|�td	tdtd
���ddg�|�ttd	dd�|�ttd�|�tdttd��tt	tdtd���|�tdttd��tt	tdtd���|�tdtd��dddg�|�tdtd��dddg�|�tdtt
d���t
d�t
d�t
d�g�|�tdttd	d���td	d�tdd�tdd�g�dd>}|�tdt|��||d|d	g�td�}|�t|�d �t
|�|�t|�d!�td"�}|�t|�d#�t
|�|�t
|�d$�|�ttd%��d&�|�ttd'��d(�|�tt
td'���t�x\tjdtjdd)d
d*dtjdtjdfD](}tt|��}d+�|�}|�||��q�Wx|d
dtdtdfD]d}t|�}|�t
t�|��|�|�t
t�|��|�x(t	tjd�D]}|�|t|���q4W�q�Wtdtd�t��dS),NrU)rJr)rKr)rLrrN)rJrN)rKr;)rLrXrr�)rJr�)rKr���)rJr�)rKr|r;rJr/rXg
@g@g@y
@�y@�y@�z1.1z2.1z3.1rYri�zcount(3)zcount(4)i����z	count(-9)i����g�$@zcount(10.25)g$@zcount(10.0)i����rz	count(%r))rEr
�countr&r	rarA�maxsizerrrr�reprrGrF�float�sys�__mod__rsrtr1rerM�exc_info)r�BIGINTrLr�r1�r2�valuer5rrr�
test_countsT   $6
zTestBasicOps.test_countcCsv|�tdtdd��dddg�|�tdtddd��dddg�|�tdtdd	��d
ddg�|�ttd
d�|�tdtdd��dddg�|�tdtdd��dddg�|�tdtdd��dddg�|�tdttdd��tdttdtdd���|�tdttdd��tdttdtdd���|�tdtdtd��ttdddtdtd���|�tdtdd��dddg�|�tdtdd��dddg�|�tdtt	d �t	d!���t	d �t	d"�t	d#�g�|�tdtt
dd�t
dd$���t
dd�t
d%d&�t
dd&�g�dd'>}|�tdt|d	��d|d|g�|�ttdtdd(���tdd)d*g��tdd�}|�t|�d+�t|�|�t|�d,�td-d�}|�t|�d.�t|�|�t|�d.�td-d/�}|�t|�d0�t|�|�t|�d1�|�t|�d1�|�ttd2d��d3�|�ttd2d��d4�|�ttd2d5��d6�|�ttdd5��d7�tdd5�}|�t
t|��t�|�t
t|��t�x�tjdtjdd8dddtjdtjdfD]�}x�tjdtjdd8ddddtjdtjdf	D]l}tt||��}|dk�r"d9|}nd:||f}|�||�x*ttjd�D]}|�|t||���qJW�q�W�q�WdS);NrUrrN)rJr)rKrX)rLrY)�start�stepr�)r�)rJr)rKr�)rLr|rJrKr)rKr)rLrr)rKrN)rLr;�rP�dr/rXg�?g
@g@y
@�y@�y!@ �z1.1z.1z1.2z1.3rW�rQi�g@g)@g.@zcount(3, 5)zcount(8, 5)i����zcount(-9, 0)r�z
count(-9, -3)zcount(-12, -3)g%@zcount(10.5, 1.25)zcount(10.5)g�?zcount(10.5, 1.0)zcount(10, 1.0)i����z	count(%r)z
count(%r, %r))rEr
r�rarAr&r�rrrrr�rGrFr^r�r�r1rerM)rr�rLrr�r�r�r5rrr�test_count_with_stride7sf28""&



68

z#TestBasicOps.test_count_with_stridec
s|�tdtd��td��|�ttd��g�|�tt�|�ttd�|�tttt��d��ddddddddddg
�td��|�t��d	�|�tdt	�
���td
��xvttj
d�D]d}|�tdt�t��|���td
��t��|�tdt�t��|���td��t��t��q�Wx(ttj
d�D]}|�|td���q4Wx�ttj
d�D]�}td�}t|���fd
d�td�D�}t��|�}t�|�}|�td|�td��td�}t|���fdd�td�D�}t��|�}t�|�}|�td|�td���q^WdS)Nr/rUZ
abcabcabcarmrXrrrrJZ
bcabcabcabZ
cabcabcabcr�csg|]}t���qSr)rG)r8r)rLrrr9�sz+TestBasicOps.test_cycle.<locals>.<listcomp>r�Zcdeabcdeabcdeabcdeabcsg|]}t���qSr)rG)r8r)rLrrr9�srW)rEr&�cyclerrarAr$rrGrsrtrr1rer2r3rMrz)rr5rB�_r�rwr)rLr�
test_cyclens>0



zTestBasicOps.test_cyclec	Cs td�}|�td�df�|�td|�td��td�}|�td�df�|�td|�td��|�t��td��td�dg�WdQRX|�t�� td�}|�td�df�WdQRXtd|�|�t��td��td�df�WdQRX|�ttd	�jd
�|�ttd	�jgf�dS)N�defgrUrr�Zdefgabcdefgabcdefgab�abcdefgrrrmr)r�ryrrEr&rarAr�)rrLrrr�test_cycle_setstate�s  
 z TestBasicOps.test_cycle_setstatec
s6|�gttg���|�gttgtd���|�tttdg��|�ttd�|�ttddd�d�dddd	d
ddd
g}g}xBt|dd��D]0\}}x&|D]}|�||d�|�|�q�Wq�W|�||�xvttj	d�D]d}g}xNt�
t�t|t�|��D]2\}}x(|D] }|�||d�|�|��qWq�W|�||�q�Wg}xlt|t�D]^\}}xRt|t
�D]D\}}x8|D]0}|�||d�|�||d�|�|��qvW�qhW�qTW|�||�x�ttj	d�D]�}g}x�t�
t�t|t�|��D]l\}}x`t�
t�t|t
�|��D]D\}}x8|D]0}|�||d�|�||d�|�|��q$W�qW�q�W|�||��q�Wdd�t|t�D�}	tdd�|D��}
|�t|	�|
�|�t|	�t|
��ttdtd���}t|t�}t|�\}}
t|�\}}t|�\}}|�t|
�g�|�t|�g�|�t|�d�t|�|�t|�g�x\ttj	d�D]J}t|t�}t|�\}}t|�t|�|�tt�
t�||���g��qXWd}dd�tt|��D�}|�|dddddg�dd�tt|��D�}|�|dddg�d d�tt|��D�}|�|d!d"d#d$d%g�td&d�tt|��D�d'd(�dd)�}|�|d!d%d"g�Gd*d+�d+t��d5�fd,d-�	}dtfd.d/�}|��||d��|��||d��G�fd0d1�d1�}|�|�dg}|j�||td2�|��||���fd3d4��d�_|��|dg��d�_|��|ddg��dS)6N)�keyrUcSs|S)Nr)rrrrr6�r7z+TestBasicOps.test_groupby.<locals>.<lambda>r/)rr/r�)r�rQ)rr�rQ)r�
rQ)r��)rrPr�)rNr[�)rNr�r�cSs|dS)Nrr)r,rrrr6�r7rrrcSsg|]\}}|�qSrr)r8r��grrrr9�sz-TestBasicOps.test_groupby.<locals>.<listcomp>cSsg|]}|d�qS)rr)r8r,rrrr9�sZ	AABBBAAAArZ)rrXZabracadabracSsg|]\}}|�qSrr)r8r�r�rrrr9
srJrKrLrwr,cSs$g|]\}}tt|dd��r|�qS)rr)rr$)r8r�r�rrrr9
scSs g|]\}}tt|��|f�qSr)r�r)r8r�r�rrrr9s)rXrJ)rrK)rrL)rrw)rr,cSs g|]\}}tt|��|f�qSr)r�r)r8r�r�rrrr9sT)�reverserNc@seZdZdS)z0TestBasicOps.test_groupby.<locals>.ExpectedErrorN)r r!r"rrrr�
ExpectedErrorsr�c3s xt|�D]
}dVq
W��dS)NZyo)r)rr)r�rr�
delayed_raises
z0TestBasicOps.test_groupby.<locals>.delayed_raisecs�fdd�t||�D�S)Ncsg|]\}}�|��qSrr)r8r�r�)�funcrrr9sz;TestBasicOps.test_groupby.<locals>.gulp.<locals>.<listcomp>)r�)r)Zkeypr�r)r�r�gulpsz'TestBasicOps.test_groupby.<locals>.gulpcseZdZ�fdd�ZdS)z+TestBasicOps.test_groupby.<locals>.DummyCmpcs��dS)Nr)r�dst)r�rr�__eq__'sz2TestBasicOps.test_groupby.<locals>.DummyCmp.__eq__N)r r!r"r�r)r�rr�DummyCmp&sr�)r�cs$�jdkr�jd8_|S��dS)Nrr)�skip)�obj)r��keyfuncrrr�1s
z*TestBasicOps.test_groupby.<locals>.keyfunc)r)rErr�r�rarA�appendrr1rer2r3r-r.r�r�r	rGr��	Exceptionr�)rr4�dupr�r��elemr5ZikZig�keysZexpectedkeysrBr�Zg1Zg2Zg3r,r�r�r�r)r�r�r�test_groupby�s�


"

""


$&zTestBasicOps.test_groupbyc
Cs�|�ttttd���dddg�|�ttddddddg��ddg�|�tttdddddg��ddg�|�tdttt���ddddg�|�t	t�|�t	tdd��|�t	tdd�td�d	�|�t	ttd
�|�t	t
ttd�td���dddg}tttd��}|�tt�|��|�tttd��}|�tt�|��|�xrtt
jd�D]`}tttd��}|�tt
�t
�||���|�t
|�|�tt
�t
�||���|dd���qPWx2tt
jd�D] }tttd��}|�||��q�WdS)NrOrrr;rcSs|S)Nr)rrrrr6Dr7z*TestBasicOps.test_filter.<locals>.<lambda>cSs|S)Nr)rrrrr6Er7rWrN)rErr�rr�boolr&r�rarArGrsrtr1rer2r3rM)r�ansrLr5rrr�test_filter>s, $$"
,zTestBasicOps.test_filterc
Cs&|�ttttd���dddg�|�ttddddddg��dddg�|�tttdddddg��dddg�|�tdttt���ddddg�|�t	t�|�t	td	d
��|�t	tdd
�td�d�|�t	ttd�|�t	t
ttd�td���x.ttjd�D]}|�
|tttd����qWdS)NrOrrNrXrrr;rWcSs|S)Nr)rrrrr6_r7z/TestBasicOps.test_filterfalse.<locals>.<lambda>cSs|S)Nr)rrrrr6`r7)rEr�filterfalserrr�r&r�rarArGr1rerM)rr5rrr�test_filterfalseYs &&"zTestBasicOps.test_filterfalsecCs*dd�tdt��D�}|�|dddg�|�ttdtd���tdtd���|�ttdtd	���tdtd	���|�td	tdt���tdtd	���|�ttd��td��|�tt��t��|�ttd	�|�tttd	�d	�|�d
d�tdd�D�tdd��|�dd�tdd�D�tdd��dS)
NcSsg|]\}}||f�qSrr)r8r�yrrrr9hsz)TestBasicOps.test_zip.<locals>.<listcomp>rU)rJr)rKr)rLrrOrlrNcSsg|]}tt|���qSr)r�r)r8�pairrrrr9qsrkcSsg|]}|�qSrr)r8r�rrrr9ss)	r	r�rErrr
r&rarA)rr�rrr�test_zipfs$$$zTestBasicOps.test_zipc	Cs�ttttdd���}|�t|�t|��tttttdd����}|�tt�	|��t|��dd�t
�
tdt���D�}|�|dddg�dd�t
�tdt���D�}|�|dddg�xLt
tjd	�D]:}d
d�t�t�tdt��|��D�}|�|dddg�q�WxXt
tjd	�D]F}tdt��}t|�dd�t�t�||��D�}|�|ddg��qWx,t
tjd	�D]}|�|tdt����qnWdS)NrUrkcSsg|]\}}||f�qSrr)r8rr�rrrr9~sz5TestBasicOps.test_zip_tuple_reuse.<locals>.<listcomp>)rJr)rKr)rLrcSsg|]\}}||f�qSrr)r8rr�rrrr9�srcSsg|]\}}||f�qSrr)r8rr�rrrr9�scSsg|]\}}||f�qSrr)r8rr�rrrr9�s)rr`r�r	rErbrcr��dict�fromkeysrsr�rtrr1rer2r3rGrM)r�idsr�r5r�rrr�test_zip_tuple_reusevs$$z!TestBasicOps.test_zip_tuple_reusecsVx�dtd�gtd�dgtd�tdd�tdd�gtd�td�tdd�td	�td
�gtd�td�tdd�td	�td
�td�ggD]x��fdd�tttt����D�}|�tt���|�|�tt�i��|�d
d�|D�}|�tt�tdd���|�q|W|�tdtdt	���tt
dtd����|�tt��tt
���|�ttg��tt
g���|�ttd��tt
d���|�ttdi��tt
td�dgd���|�ttd�|�tttd�d�xHdD]@}yt
|t�t��Wntk
�r�YnX|�d|��q�W|�dd�tdd�D�tt
dd���|�dd�tdd�D�tt
dd���dS)NrUrOi�i�i4i�i�ri�i�cs"g|]�t�fdd��D���qS)cs$g|]}�t|�kr|�nd�qS)N)r�)r8�arg)rrrr9�sz;TestBasicOps.test_ziplongest.<locals>.<listcomp>.<listcomp>)r�)r8)r
)rrr9�sz0TestBasicOps.test_ziplongest.<locals>.<listcomp>cSsg|]}tdd�|D���qS)css|]}|dkrdp|VqdS)N�Xr)r8r<rrrr��sz:TestBasicOps.test_ziplongest.<locals>.<listcomp>.<genexpr>)r�)r8r�rrrr9�sr�)�	fillvaluerNrlr�)zzip_longest('abc', fv=1)z3zip_longest('abc', fillvalue=1, bogus_keyword=None)zDid not raise Type in:  cSsg|]}tt|���qSr)r�r)r8r�rrrr9�srkcSsg|]}|�qSrr)r8r�rrrr9�s)rUr�)rrcr`r�rEr�zip_longestr�r&r�r	rarA�eval�globals�localsZfail)r�targetZstmtr)r
r�test_ziplongest�s<

"0
 (
zTestBasicOps.test_ziplongestcCs^ttttdd���}|�t|�t|��tttttdd����}|�tt�	|��t|��dS)NrUrk)
rr`r�rrErbrcr�r�r�)rr�rrr�test_zip_longest_tuple_reuse�sz)TestBasicOps.test_zip_longest_tuple_reusec	Cshxbttjd�D]P}|�|tdd��|�|tdd��|�|tdddd��|�|tdd��qWdS)NrrUrkZdefgh)rrm)rr1rerMr)rr5rrr�test_zip_longest_pickling�s
z&TestBasicOps.test_zip_longest_picklingcCs�Gdd�d�}|ddt�}|ddt�}dd�}|�|||�d	d	d	d
g�|ddt�}|ddt�}t||dd�}|�t|�d	�|�t|�d	�|�t|�d	�|�tt|�dS)
Nc@s$eZdZdd�Zdd�Zdd�ZdS)z,TestBasicOps.test_bug_7244.<locals>.RepeatercSs||_t|�|_||_dS)N)�or^r�r<)rr	r�r<rrr�__init__�s
z5TestBasicOps.test_bug_7244.<locals>.Repeater.__init__cSs|S)Nr)rrrrr�sz5TestBasicOps.test_bug_7244.<locals>.Repeater.__iter__cSs(|jdkr|jd8_|jS|j�dS)Nrr)r�r	r<)rrrrr�s
z5TestBasicOps.test_bug_7244.<locals>.Repeater.__next__N)r r!r"r
rrrrrr�Repeater�srrrNrr;c
SsTg}xJt||dd�D]8\}}t�d��t||f�WdQRX|�||f�qW|S)Nr)r�stdout)rrZcaptured_output�printr�)r�r�r�rr�rrr�run�sz'TestBasicOps.test_bug_7244.<locals>.run)rr)rrr)r)rrEr>rrGra)rrr�r�rrBrrr�
test_bug_7244�szTestBasicOps.test_bug_7244csx�gdgfdgddgftd�td�gddd	d
ddgftd
�td�td�ggftd�td
�td�ggftd�td�td
�ggfgD]V\}}|�tt|��|�x8td�D],}|�tt||��tt|t|d����q�Wq�W|�ttttd�gd���d�|�tttd�d�dd�}dd�}dddtd
�td�tdddd�td�td�t	td��g	�x�td�D]�}�fdd �tt
�d!��D�}tt
t|��}|�ttt|���|�|�tt|��t||���|�tt|��t||���t
t|�}|�ttt|���|��qbWdS)"NrrV)rJ)rKrrN)rr)rr)rr)rr)rr)rrrr;)r�rWrOi��cs�ttt|��|�dd�}t|�}|dkr4dVdStdd�|D��rJdSdg|}tdd�t||�D��Vx�x~tt|��D]j}||t||�dkr�q~||d7<xt|d|�D]}d||<q�Wtdd�t||�D��VPq~WdSqpWdS)	Nr�rrrcss|]}t|�dkVqdS)rN)r�)r8r�rrrr�sz>TestBasicOps.test_product.<locals>.product1.<locals>.<genexpr>css|]\}}||VqdS)Nr)r8r�rrrrr�
scss|]\}}||VqdS)Nr)r8r�rrrrr�s)	rr`r��getr��anyr	r�r)r
�kwds�poolsrr�rr�rrr�product1s&
z+TestBasicOps.test_product.<locals>.product1c?s\ttt|��|�dd�}gg}x|D]��fdd�|D�}q&Wx|D]}t|�VqFWdS)z Pure python version used in docsr�rcs g|]}�D]}||g�qqSrr)r8rr�)r�rrr9sz?TestBasicOps.test_product.<locals>.product2.<locals>.<listcomp>N)rr`r�r)r
rrr�r*r)r�r�product2s

z+TestBasicOps.test_product.<locals>.product2rmrUr)rJrKrLr�r�r�r�csg|]}t����qSr)�random�choice)r8r�)�argtypesrrr9#sz-TestBasicOps.test_product.<locals>.<listcomp>rX)rrErr�r�r�rarAr�r�rZ	randranger*r`rz)rr
r�r,rrrZexpected_lenr)rr�test_product�s2$"	
zTestBasicOps.test_productc	Cs2|�ttf��tdgdddi�WdQRXdS)NrVr}r�i)rar�r�r�)rrrr�test_product_overflow+sz"TestBasicOps.test_product_overflowc
CsH|�tttttdd����d�|�ttttttdd�����d�dS)NrUrkr)rEr�r�r`r�r�r�r)rrrr�test_product_tuple_reuse0s z%TestBasicOps.test_product_tuple_reusec	Cs�x�gdgfdgddgftd�td�gddd	d
ddgftd
�td�td�ggftd�td
�td�ggftd�td�td
�ggfgD]d\}}|�tt�t|���|�|�tt�t|���|�x&ttjd�D]}|�|t|��q�Wq�WdS)NrrV)rJ)rKrrN)rr)rr)rr)rr)rr)rrrr)	rrErrsr�rtr1rerM)rr
r�r5rrr�test_product_pickling5s$z"TestBasicOps.test_product_picklingcCsLtdd�}|�d�|�t|�d�tddd�}|�d�|�tt|�dS)N)rr)rN)ri)rrNr)rri)r�ryrErGrar)rr�rrr�test_product_issue_25021Ds


z%TestBasicOps.test_product_issue_25021cCs�|�ttddd��dddg�|�ttd�td��dddg�|�ttdd��dddg�|�tdtd��dddg�|�ttdd��g�|�ttdd��g�|�tt�|�ttddd	�|�ttdd�td
�}|�t|�d�td
d�}|�t|�d
�t|�|�t|�d�tddd�}|�t	|�d�|�tdt
�
|��td��|�tdt
�|��td��x,ttj
d�D]}|�|tddd���q~WdS)NrJrN)�object�times)rrJ)rrJ)rrJrr�r;y�?zrepeat((1+0j))rXzrepeat((1+0j), 5)zrepeat((1+0j), 0)r/rZaar)rErr�r
rr&rarAr�rGrsrtr1rerM)rr,rLr5rrr�test_repeatNs,
zTestBasicOps.test_repeatcCs`|�ttdd��d�|�ttdd��d�|�ttddd��d�|�ttddd��d�dS)NrJr�zrepeat('a', 0)r|)r)rEr�r�)rrrr�test_repeat_with_negative_timeshsz,TestBasicOps.test_repeat_with_negative_timesc	Cs�|�tttjtd�tdd���dddg�|�tttdtd���dd	d
g�|�tttdt���dd	d
g�|�tdttdt���dd	g�|�tttjg��g�|�	t
t�|�	t
ttdtd�td���|�	t
ttj�|�	t
ttdtd���|�	t
tttd
gdg��|�	t
tttd
gdg��dd	d
g}ttdt��}|�tt�|��|�ttdt��}|�tt�|��|�x2ttjd�D] }ttdt��}|�||��q�WdS)NrNrrWrrYrUrX)rJr)rKr)rLrrr/r;)rErr`r'�powrrr�r&rarA�negrGrrrrsrtr1rerM)rr�rLr5rrr�test_mapns.

zTestBasicOps.test_mapc
Cs�|�tttjttd�tdd����dddg�|�tdttjtt�td����dddg�|�tttjg��g�|�tttjt	ddg�g��dg�|�
ttttjdg��|�
tt�|�
tttjd	gd
�|�
tttdd	g��|�
t
tttd	g��|�
ttttd	g��dddg}ttjttd�tdd���}|�tt�|��|�ttjttd�tdd���}|�tt�|��|�x@ttjd�D].}ttjttd�tdd���}|�||��q�WdS)NrNrrWrrYr;rXi)r;rX�extrar/)rEr�starmapr'r"r	rr&r�rzrarArGrrrrsrtr1rerM)rr�rLr5rrr�test_starmap�s(" $
zTestBasicOps.test_starmapc		CsXx2dD]*}|�tttd�f|���tt|���qWx6dD].\}}|�tttd�f|���tt|���q:W|�tttd�d��ttd���|�tttd�dd��ttd���|�tttd�ddd��ttd���|�tttd�dd��ttdd���|�tttd�ddd��ttddd���ttd��}|�tt|d��ttd���|�t|�ttdd���ttd��}|�tt|dd��g�|�t|�ttdd���td�}|�tt|�|�tt|dddd�|�tt|d	dd�|�tt|dd	d
�|�tt|ddd
�|�tt|ddd�|�tt|d�|�tt|dd�|�tt|dd�|�tt|ddd�|�tt|ddd�|�tttt	�ddt
���d�t	�}|�tt|ddd
��dg�|�t|�d�x�dD]�}|�tt�ttd�f|����tt|���|�tt�
ttd�f|����tt|���x2ttjd�D] }|�|ttd�f|����qFW�q�Wdd�dD�}t�|�}t|d�}|�|��t|�t��|�|��Gdd�dt�}|�tttd�|d���ttd���|�tttd�|d�|d
���ttdd
���|�tttd�|d�|d
�|d���ttdd
d���dS)N))r/r�rN)r/rNr�)r/r�)r/r/)r/rN)r�r�)))r/�nrN)r/r�rN))r/r()r/r�))r()r�r/rrrNr;���r�rrJ�2))r/r�rN)r/rNr�)r/r�)r/rN)r�css|]
}|VqdS)Nr)r8rrrrr��sz+TestBasicOps.test_islice.<locals>.<genexpr>)rrc@seZdZdd�Zdd�ZdS)z)TestBasicOps.test_islice.<locals>.IntLikecSs
||_dS)N)�val)rr+rrrr
�sz2TestBasicOps.test_islice.<locals>.IntLike.__init__cSs|jS)N)r+)rrrr�	__index__�sz3TestBasicOps.test_islice.<locals>.IntLike.__index__N)r r!r"r
r,rrrr�IntLike�sr-rX)rErr$rrzrarArr�r�r�rGrsrtr1rerM�weakref�refZassertIsNotNonerZ
gc_collectZassertIsNoner)	rr
ZtgtargsrBZrarLr5Zwrr-rrr�test_islice�sj
"$&&* 
&

&$zTestBasicOps.test_islicecCsRddddddddg}|�ttt|��dddg�|�tttg��g�|�tt�|�tttj�|�tttjd	gd
�|�tttdd	g��|�t	ttt
d	g��ttddddddg�}|�t|�dddg�|�tt|�|�tt
�
tt|���dddg�|�tt
�tt|���dddg�x*ttjd�D]}|�|tt|���q2WdS)
NrrNrXr�rr;rOrY)r;rXr%r/r)rEr�	takewhiler0rarAr'r"rGrrr�rrsrtrr1rerM)rr�r�r5rrr�test_takewhiles "zTestBasicOps.test_takewhilecCs$ddddddddg}|�ttt|��dddddg�|�tttg��g�|�tt�|�tttj�|�tttjd	gd
�|�tttdd	g��|�t	ttt
d	g��|�tt�tt|���dddddg�|�tt�tt|���dddddg�x*t
tjd�D]}|�|tt|���qWdS)NrrNrXr�rr;rOrY)r;rXr%r/)rEr�	dropwhiler0rarAr'r"rGrrrsrtrr1rerM)rr�r5rrr�test_dropwhiles &zTestBasicOps.test_dropwhilecCsd}tg�\}}|�t|�g�|�t|�g�tt|��\}}|�t||�tt|�t|���tt|��\}}|�t|�tt|���|�t|�tt|���tt|��\}}x td�D]}|�t|�|�q�W~|�t|�tt|���tt|��\}}x"td�D]}|�t|�|��qW~|�t|�ttd|���x�td�D]�}dg|dg|}t�|�ggf}tt|��}x(|D] }t||�}	||�	|	��q�W|�|dtt|���|�|dtt|����qFW|�
tt�|�
ttd�|�
ttddgd�|�
ttddgdd�td	�\}}t|�d
�}
|�t|
�td
��ttd�d�\}}}
x"td�D]}|�t|�|��qjW|�t|�ttd���|�t|
�t|
�gttd���|�t|�ttdd���|�t|
�ttdd���|�
ttd	d�|�
t
tgd
�x\td�D]P}td	|�}|�t|�t�|�t|�|�|�dd�|D�td	�g|��qWtd	�\}}t|�\}
}|�||
k�td	�\}
}t|
�}|�
t|�|�
t|d�||
�}|�t|
�t|�k�o�t|�k�o�td	�kn�ttd��\}}t�|�}|�t|d�t|��~|�
tt|d�td	�}ttd��}td	�\}}|�tt�|��|�|�tt�|��|�tttd���\}}|�tt�|��|�|�tt�|��|�td	�\}}td|�td|�|�tt�|��|dd��|�tt�|��|dd��|�t|�|dd��|�t|�|dd��ttd��\}}td|�td|�|�tt�|��|dd��|�tt�|��|dd��|�t|�|dd��|�t|�|dd��td	�\}}|�tt�|��|�|�tt�|��|�|�t|�|�|�t|�|�ttd��\}}|�tt�|��|�|�tt�|��|�|�t|�|�|�t|�|�td	�\}}td|�td|�|�tt�|��|dd��|�tt�|��|dd��|�t|�|dd��|�t|�|dd��ttd��\}}td|�td|�|�tt�|��|dd��|�tt�|��|dd��|�t|�|dd��|�t|�|dd��xXttjd�D]F}|�|ttd	���td	�\}}|j|||d�|j|||d��q�WdS)N��r�rXrrrNrrrUrki�Zinvalidr�cSsg|]}t|��qSr)r)r8rrrrr9jsz)TestBasicOps.test_tee.<locals>.<listcomp>r/�	__class__i'�<)rH)�teerErrr
rrGrZshuffler�rarArFrr�r�r�r.�proxy�getattr�ReferenceErrorrsr&rtr1rerMrz)rrrJrKrr��orderZlistsZitsr�rLr�rwZt1Zt2ZtnewZt3r�r�Zlong_ansr5rrr�test_tee*s� 

 
&<








zTestBasicOps.test_teecCs8ttdd��\}}yt|�~Wn~~�YnXdS)Ni-1)r8r�r)rZforwardZbackwardrrr�test_tee_del_backward�sz"TestBasicOps.test_tee_del_backwardc	sDG�fdd�d�}t|��\}�|�td��t|�WdQRXdS)Ncs$eZdZdZdd�Z�fdd�ZdS)z(TestBasicOps.test_tee_reenter.<locals>.ITcSs|S)Nr)rrrrr�sz1TestBasicOps.test_tee_reenter.<locals>.I.__iter__cs|j}d|_|rt��SdS)NF)�firstrG)rr?)rKrrr�sz1TestBasicOps.test_tee_reenter.<locals>.I.__next__N)r r!r"r?rrr)rKrr�I�sr@r8)r8�assertRaisesRegexr>rG)rr@rJr)rKr�test_tee_reenter�s
zTestBasicOps.test_tee_reenterc	s�t���t���G��fdd�d�}t|��\}}tjt|gd�}|��z,���|�td��t|�WdQRXWd��	�|�
�XdS)Ncs"eZdZdd�Z��fdd�ZdS)z+TestBasicOps.test_tee_concurrent.<locals>.IcSs|S)Nr)rrrrr�sz4TestBasicOps.test_tee_concurrent.<locals>.I.__iter__cs������dS)N)r��wait)r)�finishr�rrr�sz4TestBasicOps.test_tee_concurrent.<locals>.I.__next__N)r r!r"rrr)rDr�rrr@�sr@)rr
r8)�	threadingZEventr8ZThreadrGr�rCrAr>r��join)rr@rJrKZthreadr)rDr�r�test_tee_concurrent�sz TestBasicOps.test_tee_concurrentcCs,|�ttt��x:ttttfD]*}|�tt|g��|�tt|t���qW|�tttgd��|�tttt�d��t	g�\}}|�tt|�|�tt|�t	t��\}}|�tt|�|�tt|�|�ttt
dd��xJttt
tttfD]6}|�tt|dd�g��|�tt|dd�t���q�WdS)NrcSs|S)Nr)rrrrr6r7z1TestBasicOps.test_StopIteration.<locals>.<lambda>cSs|S)Nr)rrrrr6r7)rarrGr	ror�r�rr$r8r�r�r�r`r1r3r&)rrxr��qrrr�test_StopIteration�s zTestBasicOps.test_StopIteration)r;rN)5r r!r"rMrgrprrrvr{r�rZbigaddrspacetestr�Zimpl_detailr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr r!r$r'r0r2r4r=r>rBrGrIrrrrr:Psb
)

PL?!"07*$
*(:
^	r:c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0�TestExamplesc	Cs,|�ttdddddg��dddddg�dS)	NrrrNr;rXrOr/rP)rErr])rrrrrgszTestExamples.test_accumulatec
Cs�dddddg}dddddg}xzttjd�D]h}t|�}|�tt�t�||���|dd��|�t|�d�|�tt�t�||���|dd��q,Wt|�}|�t|�d�|�tt	�
|��|dd��|�tt	�	|��|dd��dS)	NrrrNr;rXrOr/rP)rr1rer]rErr2r3rGrsrt)rr�Zaccumulatedr5rBrrr�test_accumulate_reducibles&*z&TestExamples.test_accumulate_reduciblecCs�tdddgtj�}|�t|�d�x<ttjd�D]*}t�t�	||��}|�t
|�ddg�q2W|�t
t�|��ddg�|�t
t�|��ddg�dS)NrTF)
r]r'�is_rErGrr1rer2r3rrsrt)rrBr5Zit_copyrrr�test_accumulate_reducible_nonesz+TestExamples.test_accumulate_reducible_nonecCs|�d�tdd��d�dS)Nrmr��DEFr�)rErFro)rrrrrp!szTestExamples.test_chaincCs |�d�t�ddg��d�dS)Nrmr�rNr�)rErFrorq)rrrrrr$sz%TestExamples.test_chain_from_iterablec	CsH|�ttdd��ddddddg�|�tttd	�d
��ddd
dg�dS)Nr~r)rr�)rr�)rr�)r�r�)r�r�)r�r�r;rN)rrr)rrrN)rrrN)rrrN)rErr�r)rrrrr�'szTestExamples.test_combinationsc	Cs&|�ttdd��ddddddg�dS)	Nr�r)rr)rr�)rr�)r�r�)r�r�)r�r�)rErr�)rrrrr�-sz/TestExamples.test_combinations_with_replacementcCs*|�ttdddddddg��td��dS)Nr�rrr�)rErr�)rrrrr�1szTestExamples.test_compresscCs(|�tttd�d��dddddg�dS)Nr/rXr�r�r�r�)rErr$r�)rrrrr�4szTestExamples.test_countcCs"|�tttd�d��td��dS)Nr~r�ZABCDABCDABCD)rErr$r�)rrrrr�7szTestExamples.test_cyclec
Cs.|�ttdd�dddddg��dddg�dS)NcSs|dkS)NrXr)rrrrr6;r7z-TestExamples.test_dropwhile.<locals>.<lambda>rr;rO)rErr3)rrrrr4:szTestExamples.test_dropwhilecCsT|�dd�td�D�td��|�dd�td�D�td�td�td	�td
�g�dS)NcSsg|]\}}|�qSrr)r8r�r�rrrr9>sz-TestExamples.test_groupby.<locals>.<listcomp>ZAAAABBBCCDAABBBZABCDABcSsg|]\}}t|��qSr)r)r8r�r�rrrr9@sZ
AAAABBBCCDZAAAAZBBBZCCr�)rEr�r)rrrrr�=s
zTestExamples.test_groupbycCs,|�ttdd�td���dddddg�dS)	NcSs|dS)Nrr)rrrrr6Dr7z*TestExamples.test_filter.<locals>.<lambda>r/rrNrXrWrZ)rErr�r)rrrrr�CszTestExamples.test_filtercCs,|�ttdd�td���dddddg�dS)	NcSs|dS)Nrr)rrrrr6Gr7z/TestExamples.test_filterfalse.<locals>.<lambda>r/rrr;rOrY)rErr�r)rrrrr�FszTestExamples.test_filterfalsecCs"|�tttdd��dddg�dS)N)rrNr/)rXrrNr}rZi�)rErr`r")rrrrr$IszTestExamples.test_mapcCst|�ttdd��td��|�ttddd��td��|�ttddd��td��|�ttdddd��td��dS)	Nr�r�ABr;�CD�CDEFGr�ACEG)rErr$)rrrrr0LszTestExamples.test_islicecCs|�ttdd��ddg�dS)Nr~�xy)rr)r�r�)rErr	)rrrrr�RszTestExamples.test_zipcCs&|�ttdddd��ddddg�dS)	Nr~rS�-)r)rr)r�r�)r�rT)r�rT)rErr)rrrr�test_zip_longestUszTestExamples.test_zip_longestc	CsL|�ttdd��tttd�����|�tttd���ddddd	d
g�dS)Nr~rz#AB AC AD BA BC BD CA CB CD DA DB DCrN)rrr)rrr)rrr)rrr)rrr)rrr)rErr�r`r��splitr)rrrrr�YszTestExamples.test_permutationscCsT|�ttdd��tttd�����|�tttd�dd��ddd	d
ddd
dg�dS)Nr~rSzAx Ay Bx By Cx Cy Dx DyrrN)r�)rrr)rrr)rrr)rrr)rrr)rrr)rrr)rrr)rErr�r`r�rVr)rrrrr_s
zTestExamples.test_productcCs |�ttdd��dddg�dS)Nr/rN)rErr�)rrrrr fszTestExamples.test_repeatcCs&|�tttdddg��dddg�dS)N)rrX)rNr)r/rNr}rZi�)rErr&r")rrrr�test_stapmapiszTestExamples.test_stapmapc
Cs,|�ttdd�dddddg��ddg�dS)NcSs|dkS)NrXr)rrrrr6nr7z-TestExamples.test_takewhile.<locals>.<lambda>rr;rO)rErr1)rrrrr2mszTestExamples.test_takewhileN)r r!r"rgrKrMrprrr�r�r�r�r�r4r�r�r�r$r0r�rUr�rr rWr2rrrrrJs.
rJc@s eZdZedd��Zdd�ZdS)�TestPurePythonRoughEquivalentsc
gs�t|�}|jpd|jptj|jp"d}}}tt|||��}yt|�}Wn0t	k
rxxt
t|�|�D]\}}	qhWdSXy0x*t|�D]\}}	||kr�|	Vt|�}q�WWn6t	k
r�x t
t|d|�|�D]\}}	q�WYnXdS)Nrr)�slicer�rDr�r�r�rzrrGrr	�	enumerate)
r)r
r4r�rDr�rBZnextirrirrrr$ss"$z%TestPurePythonRoughEquivalents.islicec	Cs6|�t|�dd��td��|�t|�ddd��td��|�t|�ddd��td��|�t|�dddd��td��ttd	��}|�t|�|d
��ttd
���|�t|�ttd
d	���ttd	��}|�t|�|d
d
��g�|�t|�ttd
d	���t�}|�t|�|dd
d��dg�|�t|�d
�dS)
Nr�rrOr;rPrQrrRr/rNrr*)rErr$rzrr�rG)rrBrLrrr�test_islice_recipe�s  z1TestPurePythonRoughEquivalents.test_islice_recipeN)r r!r"�staticmethodr$r[rrrrrXqsrXc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0�TestGCcCs|�|�t|�~~dS)N)r�rG)r�iterator�	containerrrr�	makecycle�s
zTestGC.makecyclecCs g}|�tdd|dg�|�dS)NrrrN)r`r])rrJrrrrg�szTestGC.test_accumulatecCsg}|�t|�|�dS)N)r`ro)rrJrrrrp�szTestGC.test_chaincCsg}|�t�|g�|�dS)N)r`rorq)rrJrrrrr�szTestGC.test_chain_from_iterablecCs"g}|�tdd|dgd�|�dS)NrrrN)r`r�)rrJrrrr��szTestGC.test_combinationscCs"g}|�tdd|dgd�|�dS)NrrrN)r`r�)rrJrrrr��sz)TestGC.test_combinations_with_replacementc
Cs&g}|�tdddddddg�|�dS)Nr�rr)r`r�)rrJrrrr��szTestGC.test_compresscCs6g}tdtft|d��}|�t|d�|d��|�dS)N�Int)rrr)rFr^r�r`r�)rrJrarrrr��szTestGC.test_countcCsg}|�t|gd�|�dS)Nr)r`r�)rrJrrrr��szTestGC.test_cyclecCs g}|�ttd||g�|�dS)Nr)r`r3r�)rrJrrrr4�szTestGC.test_dropwhilecCs$g}|�t|gddd��|�dS)NrcSs|S)Nr)rrrrr6�r7z%TestGC.test_groupby.<locals>.<lambda>)r`r�)rrJrrrr��szTestGC.test_groupbycCsBd}dd�}x0tt|�|d�D]\}}|j�dg��|�qWdS)Nr/cSs|S)Nr)rrrrr6�r7z'TestGC.test_issue2246.<locals>.<lambda>)r�r)r�r�__dict__�
setdefaultr�)rrr�rr�rrr�test_issue2246�szTestGC.test_issue2246cCs$g}|�tdd�|gd�|�dS)NcSsdS)NTr)rrrrr6�r7z$TestGC.test_filter.<locals>.<lambda>r)r`r�)rrJrrrr��szTestGC.test_filtercCsg}|�tdd�|�|�dS)NcSsdS)NFr)rrrrr6�r7z)TestGC.test_filterfalse.<locals>.<lambda>)r`r�)rrJrrrr��szTestGC.test_filterfalsecCs&g}|�t|gd|gd�|�dS)NrrN)r`r	)rrJrrrr��szTestGC.test_zipcCsPg}|�t|gd|gd�|�|dg}|�t|gd|gd|d�|�dS)NrrN)r)r`r)rrJrKrrrrU�szTestGC.test_zip_longestcCs$g}|�tdd�|gd�|�dS)NcSs|S)Nr)rrrrr6�r7z!TestGC.test_map.<locals>.<lambda>r)r`r`)rrJrrrr$�szTestGC.test_mapcCs g}|�t|gdd�|�dS)Nr)r`r$)rrJrrrr0�szTestGC.test_islicecCs"g}|�tdd|dgd�|�dS)NrrrN)r`r�)rrJrrrr��szTestGC.test_permutationscCs$g}|�tdd|dgdd�|�dS)NrrrN)r�)r`r�)rrJrrrr�szTestGC.test_productcCsg}|�t|�|�dS)N)r`r�)rrJrrrr �szTestGC.test_repeatcCs(g}|�tdd�||fgd�|�dS)NcWs|S)Nr)r�rrrr6�r7z%TestGC.test_starmap.<locals>.<lambda>r)r`r&)rrJrrrr'�szTestGC.test_starmapcCs"g}|�ttdd||g�|�dS)Nrr)r`r1r�)rrJrrrr2�szTestGC.test_takewhileN)r r!r"r`rgrprrr�r�r�r�r�r4r�rdr�r�r�rUr$r0r�rr r'r2rrrrr]�s.r]ccsx|D]
}|VqWdS)zRegular generatorNr)�seqnrrrr�Rs
rfc@s eZdZdZdd�Zdd�ZdS)�GzSequence using __getitem__cCs
||_dS)N)re)rrerrrr
sz
G.__init__cCs
|j|S)N)re)rrrrr�__getitem__	sz
G.__getitem__N)r r!r"r#r
rhrrrrrgsrgc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r@z Sequence using iterator protocolcCs||_d|_dS)Nr)rer)rrerrrr
sz
I.__init__cCs|S)Nr)rrrrrsz
I.__iter__cCs2|jt|j�krt�|j|j}|jd7_|S)Nr)rr�rer)rr�rrrrs
z
I.__next__N)r r!r"r#r
rrrrrrr@sr@c@s eZdZdZdd�Zdd�ZdS)�Igz9Sequence using iterator protocol defined with a generatorcCs||_d|_dS)Nr)rer)rrerrrr
szIg.__init__ccsx|jD]
}|VqWdS)N)re)rr+rrrrszIg.__iter__N)r r!r"r#r
rrrrrrisric@s eZdZdZdd�Zdd�ZdS)r�z Missing __getitem__ and __iter__cCs||_d|_dS)Nr)rer)rrerrrr
$sz
X.__init__cCs2|jt|j�krt�|j|j}|jd7_|S)Nr)rr�rer)rr�rrrr's
z
X.__next__N)r r!r"r#r
rrrrrr�"sr�c@s eZdZdZdd�Zdd�ZdS)�NzIterator missing __next__()cCs||_d|_dS)Nr)rer)rrerrrr
/sz
N.__init__cCs|S)Nr)rrrrr2sz
N.__iter__N)r r!r"r#r
rrrrrrj-srjc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�EzTest propagation of exceptionscCs||_d|_dS)Nr)rer)rrerrrr
7sz
E.__init__cCs|S)Nr)rrrrr:sz
E.__iter__cCsdddS)NrNrr)rrrrr<sz
E.__next__N)r r!r"r#r
rrrrrrrk5srkc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SzTest immediate stopcCsdS)Nr)rrerrrr
Asz
S.__init__cCs|S)Nr)rrrrrCsz
S.__iter__cCst�dS)N)r)rrrrrEsz
S.__next__N)r r!r"r#r
rrrrrrrl?srlcCsttdd�ttt|�����S)z Test multiple tiers of iteratorscSs|S)Nr)rrrrr6Jr7zL.<locals>.<lambda>)ror`rfrirg)rerrr�LHsrmc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�TestVariousIteratorArgscCs�dddddg}dddddg}t|�}x.tttttfD]}|�tt||���|�q4W|�ttt	|���g�|�
ttt|��|�
ttt
|��|�
tttt|���dS)	NrrrNr;rXrOr/rP)r�rgr@rirmrfrErr]rlrarAr�rj�ZeroDivisionErrorrk)rr4r,rr�rrrrgOsz'TestVariousIteratorArgs.test_accumulatec	Cs�x�ddtd�dtddd�fD]�}xjttttttfD]V}|�tt	||���t||���|�tt	||�||���t||��t||���q2W|�
ttt	t|���|�
ttt	t
|���|�
ttt	t|���qWdS)N�123rmi�)�dog333333�?i�i�rX)rrgr@rirlrmrfrErrorarAr�rjrork)rr4r�rrrrpZs  6z"TestVariousIteratorArgs.test_chainc	Cs�x�ddtd�dtddd�fD]�}t|�}x>ttttttfD]*}|�t	t
||�td���t	||���q:W|�t
t
t|�td��|�t
t
t|�td��|�tt	t
t|�td���qWdS)	Nrprmi�)rqg333333�?i�i�rXr)rr�rgr@rirlrmrfrErr�r�rarAr�rjrork)rr4rr�rrrr�cs *z%TestVariousIteratorArgs.test_compresscCs^xXddtd�dtddd�fD]:}|�ttt|��|�ttt|��|�ttt|��qWdS)Nrprmi�)rqg333333�?i�i�rX)rrarAr�r�rjrork)rr4rrrrls z$TestVariousIteratorArgs.test_productcCs�x�ddtd�dtddd�fD]�}xVttttttfD]B}t|�d}t||��d}tt	t
||��|��}|�||�q2W|�t
t
t|��|�t
t
t|��|�ttt
t|���qWdS)	Nrprmi�)rqg333333�?i�i�rXrN)rrgr@rirlrmrfr�rr$r�rErarAr�rjrork)rr4r�ZtgtlenZexpected�actualrrrr�rs z"TestVariousIteratorArgs.test_cyclecCs�x�td�td�td�dtddd�fD]~}x>ttttttfD]*}|�dd	�t||��D�t	||���q:W|�
ttt|��|�
ttt
|��|�
tt	tt|���q$WdS)
Nr/ri�)rWr�i�i�rXcSsg|]\}}|�qSrr)r8r�Zsbrrrr9�sz8TestVariousIteratorArgs.test_groupby.<locals>.<listcomp>)rrgr@rirlrmrfrEr�rrarAr�rjrork)rr4r�rrrr�}s(*z$TestVariousIteratorArgs.test_groupbyc	Cs�x�td�td�td�dtddd�fD]�}x@ttttttfD],}|�tt	t
||���dd	�||�D��q:W|�tt	t
t
|��|�tt	t
t|��|�ttt	t
t|���q$WdS)
Nr/ri�)rWr�i�i�rXcSsg|]}t|�r|�qSr)r)r8rrrrr9�sz7TestVariousIteratorArgs.test_filter.<locals>.<listcomp>)rrgr@rirlrmrfrErr�rrarAr�rjrork)rr4r�rrrr��s(z#TestVariousIteratorArgs.test_filterc	Cs�x�td�td�td�dtddd�fD]�}x@ttttttfD],}|�tt	t
||���dd	�||�D��q:W|�tt	t
t
|��|�tt	t
t|��|�ttt	t
t|���q$WdS)
Nr/ri�)rWr�i�i�rXcSsg|]}t|�r|�qSr)r)r8rrrrr9�sz<TestVariousIteratorArgs.test_filterfalse.<locals>.<listcomp>)rrgr@rirlrmrfrErr�rrarAr�rjrork)rr4r�rrrr��s(z(TestVariousIteratorArgs.test_filterfalsec	Cs�x�ddtd�dtddd�fD]�}xdttttttfD]P}|�tt	||���t
||���|�tt	||�||���t
||�||���q2W|�tt	t
|��|�tt	t|��|�ttt	t|���qWdS)Nrprmi�)rqg333333�?i�i�rX)rrgr@rirlrmrfrErr	r
rarAr�rjrork)rr4r�rrrr��s  0z TestVariousIteratorArgs.test_zipc
Cs�x�ddtd�dtddd�fD]�}xlttttttfD]X}|�tt	||���tt
||����|�tt	||�||���tt
||�||����q2W|�tt	t
|��|�tt	t|��|�ttt	t|���qWdS)Nrprmi�)rqg333333�?i�i�rX)rrgr@rirlrmrfrErrr	rarAr�rjrork)rr4r�rrrr�s $4z'TestVariousIteratorArgs.test_ziplongestc
Cs�x�td�td�td�dtddd�fD]�}xpttttttfD]\}|�tt	t
||���dd	�||�D��|�tt	tj||�||���d
d	�||�D��q:W|�
tt	t
t|��|�
tt	t
t|��|�
ttt	t
t|���q$WdS)Nr/rr�)rWr�r�r*rXcSsg|]}t|��qSr)r)r8rrrrr9�sz4TestVariousIteratorArgs.test_map.<locals>.<listcomp>cSsg|]}||�qSrr)r8rrrrr9�s)rrgr@rirlrmrfrErr`rr'r"rarAr�rjrork)rr4r�rrrr$�s(z TestVariousIteratorArgs.test_mapc
Cs�x�ddtd�dtddd�fD]�}xHttttttfD]4}|�tt	||�ddd	��t||��ddd	��q2W|�
tt	t|�d
�|�
tt	t
|�d
�|�
ttt	t|�d
��qWdS)NZ12345rmi�)rqg333333�?i�i�rXrrr/)rrgr@rirlrmrfrErr$rarAr�rjrork)rr4r�rrrr0�s 4z#TestVariousIteratorArgs.test_islicec	Cs�x�td�td�td�dtddd�fD]�}xLttttttfD]8}t||�}|�t	t
tj||���dd	�||�D��q:W|�
tt
tjt|��|�
tt
tjt|��|�
tt	t
tjt|���q$WdS)
Nr/rr�)rWr�r�r*rXcSsg|]}||�qSrr)r8rrrrr9�sz8TestVariousIteratorArgs.test_starmap.<locals>.<listcomp>)rrgr@rirlrmrfr
rErr&r'r"rarAr�rjrork)rr4r��ssrrrr'�s(
z$TestVariousIteratorArgs.test_starmapc	Cs�x�td�td�td�dtddd�fD]�}x\ttttttfD]H}g}x$||�D]}t|�sZP|�|�qLW|�	t
tt||���|�q:W|�t
ttt|��|�t
ttt|��|�tt
ttt|���q$WdS)Nr/ri�)rWr�i�i�rX)rrgr@rirlrmrfrr�rErr1rarAr�rjrork)rr4r��tgtr�rrrr2�s(z&TestVariousIteratorArgs.test_takewhilec	Cs�x�td�td�td�dtddd�fD]�}x`ttttttfD]L}g}x(||�D]}|s^t|�r^qL|�|�qLW|�	t
tt||���|�q:W|�t
ttt|��|�t
ttt|��|�tt
ttt|���q$WdS)Nr/ri�)rWr�i�i�rX)rrgr@rirlrmrfrr�rErr3rarAr�rjrork)rr4r�rtr�rrrr4�s(z&TestVariousIteratorArgs.test_dropwhilecCs�x�ddtd�dtddd�fD]�}xXttttttfD]D}t||��\}}|�t	|�t	||���|�t	|�t	||���q2W|�
ttt|��|�
ttt
|��|�
tt	tt|��d�qWdS)	Nrprmi�)rqg333333�?i�i�rXr)rrgr@rirlrmrfr8rErrarAr�rjrork)rr4r�Zit1Zit2rrrr=�s z TestVariousIteratorArgs.test_teeN)r r!r"rgrpr�rr�r�r�r�r�rr$r0r'r2r4r=rrrrrnMs 						
rnc@seZdZdd�Zdd�ZdS)�LengthTransparencycCsL|�t�tdd��d�|�t�tdd��d�|�t�td�d�d�dS)Nr*rr�)rEr'�length_hintr�)rrrrr �szLengthTransparency.test_repeatcCsh|�t�tdd��d�|�t�tdd��d�|�t�tddd��d�|�t�tddd��d�dS)Nr�rr|)r)rEr'rvr�)rrrrr!�sz2LengthTransparency.test_repeat_with_negative_timesN)r r!r"r r!rrrrru�sruc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�RegressionTestscs<dd�}�fdd�}g�|d|d�tt�}|��|�dS)NcsTdgf��fdd�	}t|�}t|�|dd�<t||�}t|gt|���t��dS)Nrcs|r|dd�=�t���|S)N)rG)r�r?)rx�zrrr��s
z@RegressionTests.test_sf_793826.<locals>.mutatingtuple.<locals>.g)rr`r	r�rG)Ztuple1rxZtuple2r��items�genr)rxrxr�
mutatingtuple�s
z5RegressionTests.test_sf_793826.<locals>.mutatingtuplecs|att��dd�<dS)N)�Tr)r�)r?rrrx	sz)RegressionTests.test_sf_793826.<locals>.f)rrrN)r;rXrO)rr|rE)rr{rx�secondr)r?r�test_sf_793826�szRegressionTests.test_sf_793826cs��fdd�}�fdd�}g�|�ttt|�|d���|��ddg�g�|�ttt|�|d���|��ddg�g�|�ttt|���|��ddg�dS)	Nc3s,��d�dV��d�t���d�dS)Nrrr)r��AssertionErrorr)�histrr�gen1s


z,RegressionTests.test_sf_950057.<locals>.gen1c3s��d�dV��d�dS)NrNrr;)r�)r)r�rr�gen2s
z,RegressionTests.test_sf_950057.<locals>.gen2FrrT)rarrrorEr�)rr�r�r)r�r�test_sf_950057szRegressionTests.test_sf_950057c	Cs:t�dd�td�D��}|�t��t|�WdQRXdS)Ncss|]
}dVqdS)rNr)r8Zunusedrrrr�4szERegressionTests.test_long_chain_of_empty_iterables.<locals>.<genexpr>i���)rorqrrarrG)rrBrrr�"test_long_chain_of_empty_iterables0sz2RegressionTests.test_long_chain_of_empty_iterablescs4�fdd�}x"ttd�|�D]\}�t��qWdS)Ncs|dkrt��|dkS)NrXrO)r)r)rKrrrx9sz,RegressionTests.test_issue30347_1.<locals>.fr/)r�rr)rrxr�r)rKr�test_issue30347_18sz!RegressionTests.test_issue30347_1csNG��fdd�d�}d�tttd�|��d�xtd�D]}t�d�q8WdS)Ncs"eZdZdd�Z��fdd�ZdS)z,RegressionTests.test_issue30347_2.<locals>.KcSsdS)Nr)rr�rrrr
Bsz5RegressionTests.test_issue30347_2.<locals>.K.__init__cs�d7��dkrt�d�dS)NrT)rG)r�other)r�rrrr�Ds
z3RegressionTests.test_issue30347_2.<locals>.K.__eq__N)r r!r"r
r�r)r�rrr�KAsr�rr/rr)rGr�r)rr�r�r)r�rr�test_issue30347_2@s
	z!RegressionTests.test_issue30347_2N)r r!r"r~r�r�r�r�rrrrrw�s
rwc@seZdZdd�ZdS)�SubclassWithKwargsTestcs�x|tttttttttt	t
tfD]\�G�fdd�d��}y|dd�Wqtk
rx}z|�
d|jd�Wdd}~XYqXqWdS)NcseZdZd�fdd�	ZdS)zBSubclassWithKwargsTest.test_keywords_in_subclass.<locals>.SubclassNcs�j|f|��dS)N)r
)r�newargr
)�clsrrr
VszKSubclassWithKwargsTest.test_keywords_in_subclass.<locals>.Subclass.__init__)N)r r!r"r
r)r�rr�SubclassUsr�r)r�zkeyword argumentsr)r�r	r�r�ror`r&r$r1r3r�r�rAZassertNotInr
)rr��errr)r�r�test_keywords_in_subclassQsz0SubclassWithKwargsTest.test_keywords_in_subclassN)r r!r"r�rrrrr�Psr�c@s:eZdZdd�ZejZdd�Zdd�Zdd�Zd	d
�Z	dS)�
SizeofTestcCst�d�|_dS)Nr)�struct�calcsize�ssize_t)rrrr�setUp`szSizeofTest.setUpcCsFt�d�}|j}|tdd�|d|j�|td�|d|j�dS)NZ3PirVZ12r)
rUrUrUrUrUrUrUrUrUrUr/)r�calcobjsize�check_sizeofr�r�)r�basesize�checkrrr�test_product_sizeofes
zSizeofTest.test_product_sizeofcCsLt�d�}|j}|tdd�|d|j�|ttd�d�|d|j�dS)N�3PnirnrNr/r;)rr�r�r�r�r)rr�r�rrr�test_combinations_sizeofks
z#SizeofTest.test_combinations_sizeofcCsPt}t�d�}|j}||dd�|d|j�||td�d�|d|j�dS)Nr�rnrNr/r;)r�rr�r�r�r)rr�r�r�rrr�)test_combinations_with_replacement_sizeofqs

z4SizeofTest.test_combinations_with_replacement_sizeofcCs�t�d�}|j}|td�|d|jd|j�|tdd�|d|jd|j�|tdd�|d|jd|j�|ttd�d�|d|jd|j�dS)NZ4Pnirnr;rNr�rXr/)rr�r�r�r�r)rr�r�rrr�test_permutations_sizeofxs


z#SizeofTest.test_permutations_sizeofN)
r r!r"r�rr�r�r�r�r�rrrrr�^sr�a�" Doctest for examples in the library reference: libitertools.tex


>>> amounts = [120.15, 764.05, 823.14]
>>> for checknum, amount in zip(count(1200), amounts):
...     print('Check %d is for $%.2f' % (checknum, amount))
...
Check 1200 is for $120.15
Check 1201 is for $764.05
Check 1202 is for $823.14

>>> import operator
>>> for cube in map(operator.pow, range(1,4), repeat(3)):
...    print(cube)
...
1
8
27

>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura', '', 'martin', '', 'walter', '', 'samuele']
>>> for name in islice(reportlines, 3, None, 2):
...    print(name.title())
...
Alex
Laura
Martin
Walter
Samuele

>>> from operator import itemgetter
>>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
>>> di = sorted(sorted(d.items()), key=itemgetter(1))
>>> for k, g in groupby(di, itemgetter(1)):
...     print(k, list(map(itemgetter(0), g)))
...
1 ['a', 'c', 'e']
2 ['b', 'd', 'f']
3 ['g']

# Find runs of consecutive numbers using groupby.  The key to the solution
# is differencing with a range so that consecutive numbers all appear in
# same group.
>>> data = [ 1,  4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
>>> for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]):
...     print(list(map(operator.itemgetter(1), g)))
...
[1]
[4, 5, 6]
[10]
[15, 16, 17, 18]
[22]
[25, 26, 27, 28]

>>> def take(n, iterable):
...     "Return first n items of the iterable as a list"
...     return list(islice(iterable, n))

>>> def prepend(value, iterator):
...     "Prepend a single value in front of an iterator"
...     # prepend(1, [2, 3, 4]) -> 1 2 3 4
...     return chain([value], iterator)

>>> def enumerate(iterable, start=0):
...     return zip(count(start), iterable)

>>> def tabulate(function, start=0):
...     "Return function(0), function(1), ..."
...     return map(function, count(start))

>>> import collections
>>> def consume(iterator, n=None):
...     "Advance the iterator n-steps ahead. If n is None, consume entirely."
...     # Use functions that consume iterators at C speed.
...     if n is None:
...         # feed the entire iterator into a zero-length deque
...         collections.deque(iterator, maxlen=0)
...     else:
...         # advance to the empty slice starting at position n
...         next(islice(iterator, n, n), None)

>>> def nth(iterable, n, default=None):
...     "Returns the nth item or a default value"
...     return next(islice(iterable, n, None), default)

>>> def all_equal(iterable):
...     "Returns True if all the elements are equal to each other"
...     g = groupby(iterable)
...     return next(g, True) and not next(g, False)

>>> def quantify(iterable, pred=bool):
...     "Count how many times the predicate is true"
...     return sum(map(pred, iterable))

>>> def padnone(iterable):
...     "Returns the sequence elements and then returns None indefinitely"
...     return chain(iterable, repeat(None))

>>> def ncycles(iterable, n):
...     "Returns the sequence elements n times"
...     return chain(*repeat(iterable, n))

>>> def dotproduct(vec1, vec2):
...     return sum(map(operator.mul, vec1, vec2))

>>> def flatten(listOfLists):
...     return list(chain.from_iterable(listOfLists))

>>> def repeatfunc(func, times=None, *args):
...     "Repeat calls to func with specified arguments."
...     "   Example:  repeatfunc(random.random)"
...     if times is None:
...         return starmap(func, repeat(args))
...     else:
...         return starmap(func, repeat(args, times))

>>> def pairwise(iterable):
...     "s -> (s0,s1), (s1,s2), (s2, s3), ..."
...     a, b = tee(iterable)
...     try:
...         next(b)
...     except StopIteration:
...         pass
...     return zip(a, b)

>>> def grouper(n, iterable, fillvalue=None):
...     "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
...     args = [iter(iterable)] * n
...     return zip_longest(*args, fillvalue=fillvalue)

>>> def roundrobin(*iterables):
...     "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
...     # Recipe credited to George Sakkis
...     pending = len(iterables)
...     nexts = cycle(iter(it).__next__ for it in iterables)
...     while pending:
...         try:
...             for next in nexts:
...                 yield next()
...         except StopIteration:
...             pending -= 1
...             nexts = cycle(islice(nexts, pending))

>>> def powerset(iterable):
...     "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
...     s = list(iterable)
...     return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

>>> def unique_everseen(iterable, key=None):
...     "List unique elements, preserving order. Remember all elements ever seen."
...     # unique_everseen('AAAABBBCCDAABBB') --> A B C D
...     # unique_everseen('ABBCcAD', str.lower) --> A B C D
...     seen = set()
...     seen_add = seen.add
...     if key is None:
...         for element in iterable:
...             if element not in seen:
...                 seen_add(element)
...                 yield element
...     else:
...         for element in iterable:
...             k = key(element)
...             if k not in seen:
...                 seen_add(k)
...                 yield element

>>> def unique_justseen(iterable, key=None):
...     "List unique elements, preserving order. Remember only the element just seen."
...     # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B
...     # unique_justseen('ABBCcAD', str.lower) --> A B C A D
...     return map(next, map(itemgetter(1), groupby(iterable, key)))

>>> def first_true(iterable, default=False, pred=None):
...     '''Returns the first true value in the iterable.
...
...     If no true value is found, returns *default*
...
...     If *pred* is not None, returns the first item
...     for which pred(item) is true.
...
...     '''
...     # first_true([a,b,c], x) --> a or b or c or x
...     # first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
...     return next(filter(pred, iterable), default)

>>> def nth_combination(iterable, r, index):
...     'Equivalent to list(combinations(iterable, r))[index]'
...     pool = tuple(iterable)
...     n = len(pool)
...     if r < 0 or r > n:
...         raise ValueError
...     c = 1
...     k = min(r, n-r)
...     for i in range(1, k+1):
...         c = c * (n - k + i) // i
...     if index < 0:
...         index += c
...     if index < 0 or index >= c:
...         raise IndexError
...     result = []
...     while r:
...         c, n, r = c*r//n, n-1, r-1
...         while index >= c:
...             index -= c
...             c, n = c*(n-r)//n, n-1
...         result.append(pool[-1-n])
...     return tuple(result)


This is not part of the examples but it tests to make sure the definitions
perform as purported.

>>> take(10, count())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

>>> list(prepend(1, [2, 3, 4]))
[1, 2, 3, 4]

>>> list(enumerate('abc'))
[(0, 'a'), (1, 'b'), (2, 'c')]

>>> list(islice(tabulate(lambda x: 2*x), 4))
[0, 2, 4, 6]

>>> it = iter(range(10))
>>> consume(it, 3)
>>> next(it)
3
>>> consume(it)
>>> next(it, 'Done')
'Done'

>>> nth('abcde', 3)
'd'

>>> nth('abcde', 9) is None
True

>>> [all_equal(s) for s in ('', 'A', 'AAAA', 'AAAB', 'AAABA')]
[True, True, True, False, False]

>>> quantify(range(99), lambda x: x%2==0)
50

>>> a = [[1, 2, 3], [4, 5, 6]]
>>> flatten(a)
[1, 2, 3, 4, 5, 6]

>>> list(repeatfunc(pow, 5, 2, 3))
[8, 8, 8, 8, 8]

>>> import random
>>> take(5, map(int, repeatfunc(random.random)))
[0, 0, 0, 0, 0]

>>> list(pairwise('abcd'))
[('a', 'b'), ('b', 'c'), ('c', 'd')]

>>> list(pairwise([]))
[]

>>> list(pairwise('a'))
[]

>>> list(islice(padnone('abc'), 0, 6))
['a', 'b', 'c', None, None, None]

>>> list(ncycles('abc', 3))
['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']

>>> dotproduct([1,2,3], [4,5,6])
32

>>> list(grouper(3, 'abcdefg', 'x'))
[('a', 'b', 'c'), ('d', 'e', 'f'), ('g', 'x', 'x')]

>>> list(roundrobin('abc', 'd', 'ef'))
['a', 'd', 'e', 'b', 'f', 'c']

>>> list(powerset([1,2,3]))
[(), (1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 2, 3)]

>>> all(len(list(powerset(range(n)))) == 2**n for n in range(18))
True

>>> list(powerset('abcde')) == sorted(sorted(set(powerset('abcde'))), key=len)
True

>>> list(unique_everseen('AAAABBBCCDAABBB'))
['A', 'B', 'C', 'D']

>>> list(unique_everseen('ABBCcAD', str.lower))
['A', 'B', 'C', 'D']

>>> list(unique_justseen('AAAABBBCCDAABBB'))
['A', 'B', 'C', 'D', 'A', 'B']

>>> list(unique_justseen('ABBCcAD', str.lower))
['A', 'B', 'C', 'A', 'D']

>>> first_true('ABC0DEF1', '9', str.isdigit)
'0'

>>> population = 'ABCDEFGH'
>>> for r in range(len(population) + 1):
...     seq = list(combinations(population, r))
...     for i in range(len(seq)):
...         assert nth_combination(population, r, i) == seq[i]
...     for i in range(-len(seq), 0):
...         assert nth_combination(population, r, i) == seq[i]


�
libreftestc	Cs�tttttttttf	}t	j
|�|r|ttd�r|ddl
}dgd}x2tt|��D]"}t	j
|�|��t��||<qNWt|�t	�tjt|�dS)N�gettotalrefcountrrX)r:rnr]rwrur�rJrXr�rZrun_unittest�hasattrr��gcrr�Zcollectr�r
Zrun_doctest�modulesr )�verboseZtest_classesr�Zcountsrrrr�	test_main�	s


r��__main__T)r�)N)?ZunittestZtestr�	itertoolsr.�decimalrZ	fractionsrr'rrsr1�	functoolsrr�r�rEZMAX_Py_ssize_tr�Zminsizer
rrrrrrrrr&r*r+r-r.r0rreruZTestCaser:rJrXr]rfrgr@rir�rjrkrlrmrnrurwr�Zcpython_onlyr�r�Z__test__r�r rrrr�<module>s�
>n*e
	
	
[
_