AlkantarClanX12

Your IP : 18.117.158.10


Current Path : /proc/self/root/usr/lib64/python3.6/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib64/python3.6/__pycache__/random.cpython-36.opt-2.pyc

3


 \2k�@s�ddlmZddlmZmZddlm	Z
mZm
ZmZmZddlmZmZmZmZddlmZddlmZ m!Z"ddl#m$Z%ddl&Z'ddl(Z)d	d
ddd
ddddddddddddddddddd gZ*d!ed1�ed#�Z+d#eZ,e
d$�Z-d%e
d&�Z.d'Z/d(e/Z0ddl1Z1Gd)d	�d	e1j2�Z2Gd*d �d e2�Z3d+d,�Z4d2d.d/�Z5e2�Z6e6j7Z7e6j8Z8e6j9Z9e6j:Z:e6j;Z;e6j<Z<e6j=Z=e6j>Z>e6j?Z?e6j@Z@e6jAZAe6jBZBe6jCZCe6jDZDe6jEZEe6jFZFe6jGZGe6jHZHe6jIZIe6jJZJe6jKZKe6jLZLeMd0k�r�e5�dS)3�)�warn)�
MethodType�BuiltinMethodType)�log�exp�pi�e�ceil)�sqrt�acos�cos�sin)�urandom)�Set�Sequence)�sha512N�Random�seed�random�uniform�randint�choice�sample�	randrange�shuffle�
normalvariate�lognormvariate�expovariate�vonmisesvariate�gammavariate�
triangular�gauss�betavariate�
paretovariate�weibullvariate�getstate�setstate�getrandbits�choices�SystemRandom�g�?g@g@g�?g@�5�cseZdZdZd:dd�Zd;�fdd�	Z�fdd	�Z�fd
d�Zdd
�Zdd�Z	dd�Z
ddefdd�Zdd�Z
ede>eeefdd�Zdd�Zd<dd�Zdd�Zd=ddd�d d!�Zd"d#�Zd>d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z d8d9�Z!�Z"S)?r�NcCs|j|�d|_dS)N)r�
gauss_next)�self�x�r1�/usr/lib64/python3.6/random.py�__init__Ws
zRandom.__init__r,cs�|dkr�t|ttf�r�t|t�r*|jd�n|}|rBt|d�d>nd}x"tt|�D]}d||Ad@}qRW|t|�N}|d	kr�d
n|}|dkr�t|tttf�r�t|t�r�|j�}|t	|�j
�7}tj|d�}t
�j|�d|_dS)N�zlatin-1r�iCBl����r,�big������)�
isinstance�str�bytes�decode�ord�map�len�	bytearray�encode�_sha512Zdigest�int�
from_bytes�superrr.)r/�a�versionr0�c)�	__class__r1r2r`s
zRandom.seedcs|jt�j�|jfS)N)�VERSIONrEr%r.)r/)rIr1r2r%�szRandom.getstatecs�|d}|dkr*|\}}|_t�j|�nt|dkr�|\}}|_ytdd�|D��}Wn(tk
r|}zt|�WYdd}~XnXt�j|�ntd||jf��dS)Nrr-r,css|]}|dVqdS)r,� Nlr1)�.0r0r1r1r2�	<genexpr>�sz"Random.setstate.<locals>.<genexpr>z?state with version %s passed to Random.setstate() of version %s)r.rEr&�tuple�
ValueError�	TypeErrorrJ)r/�staterGZ
internalstater)rIr1r2r&�szRandom.setstatecCs|j�S)N)r%)r/r1r1r2�__getstate__�szRandom.__getstate__cCs|j|�dS)N)r&)r/rQr1r1r2�__setstate__�szRandom.__setstate__cCs|jf|j�fS)N)rIr%)r/r1r1r2�
__reduce__�szRandom.__reduce__r4c
Cs||�}||krtd��|dkr:|dkr2|j|�Std��||�}||krRtd��||}|dkrx|dkrx||j|�S|dkr�td|||f��||�}||kr�td��|dkr�||d|}	n"|dkr�||d|}	ntd��|	dkr�td��|||j|	�S)	Nz!non-integer arg 1 for randrange()rzempty range for randrange()z non-integer stop for randrange()r4z'empty range for randrange() (%d,%d, %d)z non-integer step for randrange()zzero step for randrange())rO�
_randbelow)
r/�start�stop�step�_intZistartZistop�widthZistep�nr1r1r2r�s4

zRandom.randrangecCs|j||d�S)Nr4)r)r/rF�br1r1r2r�szRandom.randintc
Cs�|j}|j}||�|ks$||�|krN|j�}	||	�}
x|
|krH||	�}
q6W|
S||krltd�||�|�S|dkr|td��||}|||}|�}
x|
|kr�|�}
q�W||
|�|S)Nz�Underlying random() generator does not supply 
enough bits to choose from a population range this large.
To remove the range limitation, add a getrandbits() method.rzBoundary cannot be zero)rr'�
bit_length�_warnrO)
r/r[rC�maxsize�typeZMethodZ
BuiltinMethodrr'�k�rZrem�limitr1r1r2rU�s&


zRandom._randbelowcCs:y|jt|��}Wntk
r0td�d�YnX||S)Nz$Cannot choose from an empty sequence)rUr?rO�
IndexError)r/�seq�ir1r1r2r�s
z
Random.choicecCs�|dkrR|j}x�ttdt|���D]*}||d�}||||||<||<q"WnLt}xFttdt|���D]0}||�|d�}||||||<||<qjWdS)Nr4)rU�reversed�ranger?rC)r/r0r�	randbelowrf�jrYr1r1r2rs	 zRandom.shufflecCs(t|t�rt|�}t|t�s$td��|j}t|�}d|koD|knsRtd��dg|}d}|dkr�|dtt	|dd��7}||kr�t
|�}x�t|�D]0}|||�}	||	||<|||d||	<q�WnRt�}
|
j
}xDt|�D]8}||�}	x|	|
k�r
||�}	q�W||	�||	||<q�W|S)	Nz>Population must be a sequence or set.  For dicts, use list(d).rz,Sample larger than population or is negative��r*r-r4)r9�_SetrN�	_SequencerPrUr?rO�_ceil�_log�listrh�set�add)r/�
populationrarir[�resultZsetsizeZpoolrfrjZselectedZselected_addr1r1r2rs6


z
Random.sample)�cum_weightsracs�|j��dkrN|dkr>t�t�������fdd�t|�D�Sttj|���n|dk	r^td��t��t��krvtd��t	j
��d�t��d�������fdd�t|�D�S)Ncsg|]}�������qSr1r1)rLrf)rYrtr�totalr1r2�
<listcomp>csz"Random.choices.<locals>.<listcomp>z2Cannot specify both weights and cumulative weightsz3The number of weights does not match the populationr4cs$g|]}������d���qS)rr1)rLrf)�bisectrv�hirtrrwr1r2rxlsr7)rrCr?rhrq�
_itertools�
accumulaterPrO�_bisectry)r/rtZweightsrvrar1)rYryrvrzrtrrwr2r(Ws zRandom.choicescCs||||j�S)N)r)r/rFr\r1r1r2rsszRandom.uniform���?cCsx|j�}y |dkrdn||||}Wntk
r<|SX||kr`d|}d|}||}}|||||dS)Ng�?g�?)r�ZeroDivisionError)r/ZlowZhigh�mode�urHr1r1r2r ys	 
zRandom.triangularcCsT|j}x@|�}d|�}t|d|}||d}|t|�krPqW|||S)Ng�?g�?g@)r�
NV_MAGICCONSTrp)r/�mu�sigmar�u1�u2�zZzzr1r1r2r�s

zRandom.normalvariatecCst|j||��S)N)�_expr)r/r�r�r1r1r2r�szRandom.lognormvariatecCstd|j��|S)Ng�?)rpr)r/Zlambdr1r1r2r�szRandom.expovariatecCs�|j}|dkrt|�Sd|}|td||�}xN|�}tt|�}|||}|�}	|	d||ks~|	d|t|�kr6Pq6Wd|}
|
|d|
|}|�}|dkr�|t|�t}
n|t|�t}
|
S)Ng���ư>g�?g�?)r�TWOPI�_sqrt�_cos�_pir��_acos)r/r�Zkappar�srbr�r��dr��q�fZu3Zthetar1r1r2r�s&
$zRandom.vonmisesvariatecCs�|dks|dkrtd��|j}|dkr�td|d�}|t}||}x�|�}d|ko`dknshqHd|�}t|d|�|}	|t|	�}
|||}|||	|
}|td|dks�|t|�krH|
|SqHWn�|dk�r|�}
x|
dk�r|�}
q�Wt|
�|Sx�|�}
t|t}||
}|dk�rD|d|}
nt|||�}
|�}|dk�r|||
|dk�r�Pn|t|
�k�rP�qW|
|SdS)Ngz*gammavariate: alpha and beta must be > 0.0g�?g@gH�����z>g�P���?g@)rOrr��LOG4rpr��
SG_MAGICCONST�_e)r/�alpha�betarZainvZbbbZcccr�r��vr0r�rbr�r\�pr1r1r2r�sJ
 



zRandom.gammavariatecCs`|j}|j}d|_|dkrT|�t}tdtd|���}t|�|}t|�||_|||S)Ng@g�?g�)rr.r�r�rpr��_sin)r/r�r�rr�Zx2piZg2radr1r1r2r!?s
zRandom.gausscCs0|j|d�}|dkrdS|||j|d�SdS)Ng�?rg)r)r/r�r��yr1r1r2r"ts
zRandom.betavariatecCsd|j�}d|d|S)Ng�?)r)r/r�r�r1r1r2r#�szRandom.paretovariatecCs"d|j�}|t|�d|S)Ng�?)rrp)r/r�r�r�r1r1r2r$�szRandom.weibullvariate)N)Nr,)N)N)r~rN)#�__name__�
__module__�__qualname__rJr3rr%r&rRrSrTrCrr�BPFr`�_MethodType�_BuiltinMethodTyperUrrrr(rr rrrrrr!r"r#r$�
__classcell__r1r1)rIr2rGs6
	 ,

:
0H5	c@s4eZdZdd�Zdd�Zdd�Zdd�ZeZZd	S)
r)cCstjtd�d�d?tS)Nr5r6r-)rCrD�_urandom�	RECIP_BPF)r/r1r1r2r�szSystemRandom.randomcCsP|dkrtd��|t|�kr$td��|dd}tjt|�d�}||d|?S)Nrz(number of bits must be greater than zeroz#number of bits should be an integerr5�r6)rOrCrPrDr�)r/raZnumbytesr0r1r1r2r'�szSystemRandom.getrandbitscOsdS)Nr1)r/�args�kwdsr1r1r2r�szSystemRandom.seedcOstd��dS)Nz*System entropy source does not have state.)�NotImplementedError)r/r�r�r1r1r2�_notimplemented�szSystemRandom._notimplementedN)	r�r�r�rr'rr�r%r&r1r1r1r2r)�s

cCs�ddl}t|d|j�d}d}d}d
}|j�}x@t|�D]4}	||�}
||
7}||
|
}t|
|�}t|
|�}q8W|j�}tt||d�ddd�||}t||||�}
td	||
||f�dS)Nr�timesgg _�Br-zsec,� )�endz"avg %g, stddev %g, min %g, max %g
g _��)�time�printr�rh�min�max�roundr�)r[�funcr�r�rwZsqsumZsmallestZlargestZt0rfr0Zt1ZavgZstddevr1r1r2�_test_generator�s&
r���cCs�t|tf�t|td�t|td�t|td
�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td�dS)N���?�{�G�z�?皙�����?�@��?��������?�4@�i@�@)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��UUUUUU�?)r�r�r�)	r�rrrrrr!r"r )�Nr1r1r2�_test�s r��__main__g�)r�)N�warningsrr^�typesrr�rr�Zmathrrprr�rr�rr�r	ror
r�rr�rr�r
r��osrr��_collections_abcrrmrrnZhashlibrrB�	itertoolsr{ryr}�__all__r�r�r�r�r�r�Z_randomrr)r�r�Z_instrrrr rrrrrr(rrrrrr!r"r#r$r%r&r'r�r1r1r1r2�<module>(sl
Y!