AlkantarClanX12

Your IP : 18.221.192.248


Current Path : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/random.cpython-38.opt-2.pyc

U

i�f�p�@sddlmZddlmZmZmZ	m
ZmZ
ddlmZmZmZmZddlmZddlmZmZddlmZ m!Z"ddl#m#Z$ddlZ%zdd	l&m'Z&Wn e(k
r�dd	l)m'Z&YnXd
ddd
ddddddddddddddddddd d!gZ*d"ed#�ed$�Z+d$e	Z,ed%�Z-d&ed'�Z.d(Z/d)e/Z0ddl1Z1Gd*d
�d
e1j2�Z2Gd+d!�d!e2�Z3d,d-�Z4d4d/d0�Z5e2�Z6e6j7Z7e6j8Z8e6j9Z9e6j:Z:e6j;Z;e6j<Z<e6j=Z=e6j>Z>e6j?Z?e6j@Z@e6jAZAe6jBZBe6jCZCe6jDZDe6jEZEe6jFZFe6jGZGe6jHZHe6jIZIe6jJZJe6jKZKe6jLZLeMe%d1��re%jNe6j7d2�eOd3k�re5�dS)5�)�warn)�log�exp�pi�e�ceil)�sqrt�acos�cos�sin)�urandom)�Set�Sequence)�
accumulate�repeat)�bisectN)�sha512�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��@�@��?�@�5�cs eZdZdZd>dd�Zdd�Zd?�fdd	�	Z�fd
d�Z�fdd
�Zdd�Z	dd�Z
dd�Zddefdd�Z
dd�Zdd�Zede>fdd�ZeZdd�Zd@dd �Zd!d"�ZdAddd#�d$d%�Zd&d'�ZdBd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!�Z"S)Cr�NcCs|�|�d|_dS�N)r�
gauss_next)�self�x�r7�+/opt/alt/python38/lib64/python3.8/random.py�__init__^s
zRandom.__init__cKsJ|jD]>}d|jkrqFd|jkr.|j|_qFd|jkr|j|_qFqdS)N�
_randbelowr(r)�__mro__�__dict__�_randbelow_with_getrandbitsr:�_randbelow_without_getrandbits)�cls�kwargs�cr7r7r8�__init_subclass__gs	



zRandom.__init_subclass__r1cs�|dkr�t|ttf�r�t|t�r*|�d�n|}|rBt|d�d>nd}tt|�D]}d||Ad@}qP|t|�N}|dkr~dn|}|d	kr�t|tttf�r�t|t�r�|��}|t	|��
�7}t�|d
�}t
��|�d|_dS)N�zlatin-1r�iCBl����������r1�big)�
isinstance�str�bytes�decode�ord�map�len�	bytearray�encode�_sha512Zdigest�int�
from_bytes�superrr4)r5�a�versionr6rA��	__class__r7r8r{s
zRandom.seedcs|jt���|jfSr3)�VERSIONrTr&r4�r5rWr7r8r&�szRandom.getstatec
s�|d}|dkr*|\}}|_t��|�nt|dkr�|\}}|_ztdd�|D��}Wn(tk
r|}z
t|�W5d}~XYnXt��|�ntd||jf��dS)Nrr2r1css|]}|dVqdS)lNr7)�.0r6r7r7r8�	<genexpr>�sz"Random.setstate.<locals>.<genexpr>z?state with version %s passed to Random.setstate() of version %s)r4rTr'�tuple�
ValueError�	TypeErrorrY)r5�staterVZ
internalstaterrWr7r8r'�s�zRandom.setstatecCs|��Sr3)r&rZr7r7r8�__getstate__�szRandom.__getstate__cCs|�|�dSr3)r')r5r`r7r7r8�__setstate__�szRandom.__setstate__cCs|jd|��fS)Nr7)rXr&rZr7r7r8�
__reduce__�szRandom.__reduce__rCc
Cs||�}||krtd��|dkr:|dkr2|�|�Std��||�}||krRtd��||}|dkrx|dkrx||�|�S|dkr�td|||f��||�}||kr�td��|dkr�||d|}	n"|dkr�||d|}	ntd��|	dkr�td��|||�|	�S)	Nz!non-integer arg 1 for randrange()rzempty range for randrange()z non-integer stop for randrange()rCz(empty range for randrange() (%d, %d, %d)z non-integer step for randrange()zzero step for randrange())r^r:)
r5�start�stop�step�_intZistartZistop�widthZistep�nr7r7r8r�s4

zRandom.randrangecCs|�||d�S�NrC)r�r5rU�br7r7r8r�szRandom.randintcCs,|j}|��}||�}||kr(||�}q|Sr3)r(�
bit_length)r5rir(�k�rr7r7r8r=�s
z"Random._randbelow_with_getrandbitscCsn|j}||kr$td�||�|�S|dkr4td��||}|||}|�}||kr^|�}qN|||�|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)r�_warnr^)r5rirR�maxsizerZrem�limitror7r7r8r>sz%Random._randbelow_without_getrandbitscCs:z|�t|��}Wntk
r0td�d�YnX||S)Nz$Cannot choose from an empty sequence)r:rNr^�
IndexError)r5�seq�ir7r7r8rs
z
Random.choicecCs�|dkrN|j}ttdt|���D]*}||d�}||||||<||<q nHt}ttdt|���D]0}||�|d�}||||||<||<qddSrj)r:�reversed�rangerNrR)r5r6r�	randbelowru�jrgr7r7r8r%s	zRandom.shufflecCst|t�rt|�}t|t�s$td��|j}t|�}d|krF|ksPntd��dg|}d}|dkr�|dtt	|dd��7}||kr�t
|�}t|�D]0}|||�}	||	||<|||d||	<q�nHt�}
|
j
}t|�D]2}||�}	|	|
kr�||�}	q�||	�||	||<q�|S)	Nz>Population must be a sequence or set.  For dicts, use list(d).rz,Sample larger than population or is negative��r+r2rC)rH�_Setr]�	_Sequencer_r:rNr^�_ceil�_log�listrw�set�add)r5�
populationrnrxri�resultZsetsizeZpoolruryZselectedZselected_addr7r7r8r;s6)



z
Random.sample)�cum_weightsrncs�|j�t����dkrV|dkrHt��d7�����fdd�td|�D�Stt|���n|dk	rftd��t���krztd��t��dd��d�������fdd�td|�D�S)	N�csg|]}�������qSr7r7�r[ru)rgrir�rr7r8�
<listcomp>�sz"Random.choices.<locals>.<listcomp>z2Cannot specify both weights and cumulative weightsz3The number of weights does not match the populationrErCcs$g|]}������d���qS)rr7r�)rr��hir�r�totalr7r8r��s�)	rrNrR�_repeatr��_accumulater_r^�_bisect)r5r�Zweightsr�rnr7)rgrr�r�rir�rr�r8r)�s$�zRandom.choicescCs||||��Sr3�rrkr7r7r8r�szRandom.uniformr�r.cCs||��}z |dkrdn||||}Wntk
r@|YSX||krdd|}d|}||}}|||t||�S)N��?r.)r�ZeroDivisionError�_sqrt)r5ZlowZhigh�mode�urAr7r7r8r!�s	 

zRandom.triangularcCsP|j}|�}d|�}t|d|}||d}|t|�krqDq|||S)Nr.r�r-)r�
NV_MAGICCONSTr)r5�mu�sigmar�u1�u2�zZzzr7r7r8r�s

zRandom.normalvariatecCst|�||��Sr3)�_expr)r5r�r�r7r7r8r�szRandom.lognormvariatecCstd|���|S�Nr.)rr)r5Zlambdr7r7r8r�szRandom.expovariatecCs�|j}|dkrt|�Sd|}|td||�}|�}tt|�}|||}|�}	|	d||ks�|	d|t|�kr4q�q4d|}
|
|d|
|}|�}|dkr�|t|�t}
n|t|�t}
|
S)Ng���ư>r�r.)r�TWOPIr��_cos�_pir��_acos)r5r�Zkappar�sror�r��dr��q�fZu3Zthetar7r7r8r�s$
$zRandom.vonmisesvariatecCs~|dks|dkrtd��|j}|dkr�td|d�}|t}||}|�}d|kr`dksdqFqFd|�}t|d|�|}	|t|	�}
|||}|||	|
}|td|dks�|t|�krF|
|SqFn�|dkr�td|��|S|�}
t|t}||
}|dk�r$|d|}
nt|||�}
|�}|dk�r^||
|dk�rp�qrq�|t|
�kr�qrq�|
|SdS)Nr�z*gammavariate: alpha and beta must be > 0.0r.r,gH�����z>g�P���?r/)r^rr��LOG4rr��
SG_MAGICCONST�_e)r5�alpha�betarZainvZbbbZcccr�r��vr6r�ror�rl�pr7r7r8r #s@
 

zRandom.gammavariatecCs`|j}|j}d|_|dkrT|�t}tdtd|���}t|�|}t|�||_|||S)Ng�r.)rr4r�r�rr��_sin)r5r�r�rr�Zx2piZg2radr7r7r8r"hs
zRandom.gausscCs0|�|d�}|dkrdS|||�|d�SdS)Nr.rr�)r )r5r�r��yr7r7r8r#�s
zRandom.betavariatecCsd|��}d|d|Sr�r�)r5r�r�r7r7r8r$�szRandom.paretovariatecCs"d|��}|t|�d|Sr�)rr)r5r�r�r�r7r7r8r%�szRandom.weibullvariate)N)Nr1)N)N)r�r.N)#�__name__�
__module__�__qualname__rYr9rBrr&r'rarbrcrRrrr=�BPFr>r:rrrr)rr!rrrrr r"r#r$r%�
__classcell__r7r7rWr8rNs:
	 ,

G
0E5	c@s4eZdZdd�Zdd�Zdd�Zdd�ZeZZd	S)
r*cCst�td�d�d?tS)NrDrGr2)rRrS�_urandom�	RECIP_BPFrZr7r7r8r�szSystemRandom.randomcCs<|dkrtd��|dd}t�t|�d�}||d|?S)Nrz(number of bits must be greater than zerorD�rG)r^rRrSr�)r5rnZnumbytesr6r7r7r8r(�s
zSystemRandom.getrandbitscOsdSr3r7�r5�args�kwdsr7r7r8r�szSystemRandom.seedcOstd��dS)Nz*System entropy source does not have state.)�NotImplementedErrorr�r7r7r8�_notimplemented�szSystemRandom._notimplementedN)	r�r�r�rr(rr�r&r'r7r7r7r8r*�s
cCs�ddl}t|d|j�d}d}d}d}|��}t|�D]4}	||�}
||
7}||
|
}t|
|�}t|
|�}q6|��}tt||d�ddd	�||}t||||�}
td
||
||f�dS)Nr�timesr�g _�Bg _��r2zsec,� )�endz"avg %g, stddev %g, min %g, max %g
)	�time�printr��perf_counterrw�min�max�roundr�)ri�funcr�r�r�ZsqsumZsmallestZlargestZt0rur6�t1ZavgZstddevr7r7r8�_test_generator�s(

�r���cCs�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�t|td
�dS)Nr7)r�r.)g{�G�z�?r.)皙�����?r.)r�r,)r�r.)g�������?r.)r.r.)r,r.)g4@r.)gi@r.)�@r�)r�r.gUUUUUU�?)	r�rrrrr r"r#r!)�Nr7r7r8�_test�s r��fork)Zafter_in_child�__main__)r�)P�warningsrrpZmathrrrr�rr�rr�rr~rr�r	r�r
r�rr��osrr��_collections_abcr
r|rr}�	itertoolsrr�rr�rr��_osrQr�ImportErrorZhashlib�__all__r�r�r�r�r�r�Z_randomrr*r�r�Z_instrrrr!rrrrrr)rrrrr r"r#r$r%r&r'r(�hasattr�register_at_forkr�r7r7r7r8�<module>(s��
{