AlkantarClanX12

Your IP : 3.14.134.18


Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/random.cpython-37.opt-2.pyc

B

YI~d�k�@s�ddlmZddlmZmZddlm	Z
mZm
ZmZmZddlmZmZmZmZddlmZddlmZ m!Z"ddl#m$Z%ddl&Z'ddl(Z)ddlZ*d	d
ddd
ddddddddddddddddddd gZ+d!ed"�ed#�Z,d#eZ-e
d$�Z.d%e
d&�Z/d'Z0d(e0Z1ddl2Z2Gd)d	�d	e2j3�Z3Gd*d �d e3�Z4d+d,�Z5d3d.d/�Z6e3�Z7e7j8Z8e7j9Z9e7j:Z:e7j;Z;e7j<Z<e7j=Z=e7j>Z>e7j?Z?e7j@Z@e7jAZAe7jBZBe7jCZCe7jDZDe7jEZEe7jFZFe7jGZGe7jHZHe7jIZIe7jJZJe7jKZKe7jLZLe7jMZMeNe*d0��r�e*jOe7j8d1�ePd2k�r�e6�dS)4�)�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|�|�d|_dS)N)r�
gauss_next)�self�x�r1�+/opt/alt/python37/lib64/python3.7/random.py�__init__Xs
zRandom.__init__r,cs�|dkr�t|ttf�r�t|t�r*|�d�n|}|rBt|d�d>nd}x"tt|�D]}d||Ad@}qRW|t|�N}|dkr�dn|}|d	kr�t|tttf�r�t|t�r�|��}|t	|��
�7}t�|d
�}t
��|�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__r1r2ras
zRandom.seedcs|jt���|jfS)N)�VERSIONrEr%r.)r/)rIr1r2r%�szRandom.getstatec
s�|d}|dkr*|\}}|_t��|�nt|dkr�|\}}|_ytdd�|D��}Wn(tk
r|}z
t|�Wdd}~XYnXt��|�ntd||jf��dS)Nrr-r,css|]}|dVqdS)lNr1)�.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|��S)N)r%)r/r1r1r2�__getstate__�szRandom.__getstate__cCs|�|�dS)N)r&)r/rPr1r1r2�__setstate__�szRandom.__setstate__cCs|jd|��fS)Nr1)rIr%)r/r1r1r2�
__reduce__�szRandom.__reduce__r4c
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()r4z'empty range for randrange() (%d,%d, %d)z non-integer step for randrange()zzero step for randrange())rN�
_randbelow)
r/�start�stop�step�_intZistartZistop�widthZistep�nr1r1r2r�s4

zRandom.randrangecCs|�||d�S)Nr4)r)r/rF�br1r1r2r�szRandom.randintc
Cs�|j}|j}||�|ks$||�|krN|��}	||	�}
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�_warnrN)
r/rZrC�maxsize�typeZMethodZ
BuiltinMethodrr'�k�rZrem�limitr1r1r2rT�s&


zRandom._randbelowcCs:y|�t|��}Wntk
r0td�d�YnX||S)Nz$Cannot choose from an empty sequence)rTr?rN�
IndexError)r/�seq�ir1r1r2rs
z
Random.choicecCs�|dkrR|j}x�ttdt|���D]*}||d�}||||||<||<q"WnLt}xFttdt|���D]0}||�|d�}||||||<||<qjWdS)Nr4)rT�reversed�ranger?rC)r/r0r�	randbelowre�jrXr1r1r2rs	 zRandom.shufflecCs&t|t�rt|�}t|t�s$td��|j}t|�}d|krF|ksPntd��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�_SetrM�	_SequencerOrTr?rN�_ceil�_log�listrg�set�add)r/�
populationr`rhrZ�resultZsetsizeZpoolreriZselectedZselected_addr1r1r2rs6


z
Random.sample)�cum_weightsr`cs�|j��dkrN|dkr>t�t�������fdd�t|�D�Stt�|���n|dk	r^td��t��t��krvtd��t	j
��d�t��d�������fdd�t|�D�S)Ncsg|]}�������qSr1r1)rKre)rXrsr�totalr1r2�
<listcomp>dsz"Random.choices.<locals>.<listcomp>z2Cannot specify both weights and cumulative weightsz3The number of weights does not match the populationr6r4cs$g|]}������d���qS)rr1)rKre)�bisectru�hirsrrvr1r2rwms)rrCr?rgrp�
_itertools�
accumulaterOrN�_bisectrx)r/rsZweightsrur`r1)rXrxruryrsrrvr2r(Xs zRandom.choicescCs||||��S)N)r)r/rFr[r1r1r2rtszRandom.uniform���?cCsx|��}y |dkrdn||||}Wntk
r<|SX||kr`d|}d|}||}}|||t||�S)Ng�?g�?)r�ZeroDivisionError�_sqrt)r/ZlowZhigh�mode�urHr1r1r2r zs	 
zRandom.triangularcCsT|j}x@|�}d|�}t|d|}||d}|t|�krPqW|||S)Ng�?g�?g@)r�
NV_MAGICCONSTro)r/�mu�sigmar�u1�u2�zZzzr1r1r2r�s

zRandom.normalvariatecCst|�||��S)N)�_expr)r/r�r�r1r1r2r�szRandom.lognormvariatecCstd|���|S)Ng�?)ror)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�TWOPIr��_cos�_pir��_acos)r/r�Zkappar�srar�r��dr��q�fZu3Zthetar1r1r2r�s&
$zRandom.vonmisesvariatecCs�|dks|dkrtd��|j}|dkr�td|d�}|t}||}x�|�}d|krbdksfqHqHd|�}t|d|�|}	|t|	�}
|||}|||	|
}|td|dks�|t|�krH|
|SqHWn�|dk�r|�}
x|
dkr�|�}
q�Wt|
�|Sx�|�}
t|t}||
}|dk�r@|d|}
nt|||�}
|�}|dk�rx||
|dk�r�Pn|t|
�k�rP�qW|
|SdS)Ngz*gammavariate: alpha and beta must be > 0.0g�?g@gH�����z>g�P���?g@)rNrr��LOG4ror��
SG_MAGICCONST�_e)r/�alpha�betarZainvZbbbZcccr�r��vr0r�rar�r[�pr1r1r2r�sJ
 




zRandom.gammavariatecCs`|j}|j}d|_|dkrT|�t}tdtd|���}t|�|}t|�||_|||S)Ng�g�?)rr.r�r�ror��_sin)r/r�r�rr�Zx2piZg2radr1r1r2r!@s
zRandom.gausscCs0|�|d�}|dkrdS|||�|d�SdS)Ng�?rg)r)r/r�r��yr1r1r2r"us
zRandom.betavariatecCsd|��}d|d|S)Ng�?)r)r/r�r�r1r1r2r#�szRandom.paretovariatecCs"d|��}|t|�d|S)Ng�?)rro)r/r�r�r�r1r1r2r$�szRandom.weibullvariate)N)Nr,)N)N)r}r~N)#�__name__�
__module__�__qualname__rJr3rr%r&rQrRrSrCrr�BPFr_�_MethodType�_BuiltinMethodTyperTrrrr(rr rrrrrr!r"r#r$�
__classcell__r1r1)rIr2rHs6
	 ,

:
0H5	c@s4eZdZdd�Zdd�Zdd�Zdd�ZeZZd	S)
r)cCst�td�d�d?tS)Nr5r8r-)rCrD�_urandom�	RECIP_BPF)r/r1r1r2r�szSystemRandom.randomcCsP|dkrtd��|t|�kr$td��|dd}t�t|�d�}||d|?S)Nrz(number of bits must be greater than zeroz#number of bits should be an integerr5�r8)rNrCrOrDr�)r/r`Znumbytesr0r1r1r2r'�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}|��}x@t|�D]4}	||�}
||
7}||
|
}t|
|�}t|
|�}q8W|��}tt||d�ddd	�||}t||||�}
td
||
||f�dS)Nr�timesgg _�Bg _��r-zsec,� )�endz"avg %g, stddev %g, min %g, max %g
)	�time�printr�Zperf_counterrg�min�max�roundr�)rZ�funcr�r�rvZsqsumZsmallestZlargestZt0rer0Zt1ZavgZstddevr1r1r2�_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)Nr1)gg�?)g{�G�z�?g�?)g�������?g�?)g�������?g@)g�?g�?)g�������?g�?)g�?g�?)g@g�?)g4@g�?)gi@g�?)g@g@)gg�?gUUUUUU�?)	r�rrrrrr!r"r )�Nr1r1r2�_test�s r��fork)Zafter_in_child�__main__)r�)Q�warningsrr]�typesrr�rr�Zmathrrorr�rr�rr�r	rnr
r�rr�rr�r
r��osrr��_collections_abcrrlrrmZhashlibrrB�	itertoolsrzrxr|�_os�__all__r�r�r�r�r�r�Z_randomrr)r�r�Z_instrrrr rrrrrr(rrrrrr!r"r#r$r%r&r'�hasattr�register_at_forkr�r1r1r1r2�<module>(sr
Y!