관리-도구
편집 파일: random.cpython-39.opt-2.pyc
a �����DOg�z����������������������@���s���d�dl�mZ�d�dlmZmZmZ m ZmZ �d�dlmZmZmZmZ�d�dlmZmZ�d�dlmZ�d�dlmZm Z!�d�dl"m#Z$m%Z&�d�dl'm'Z(�d�d lZ)d�d l*Z*zd�d l+m,Z+�W�n�e-y����d�d l.m,Z+�Y�n0�g�d�Z/ded ��ed��Z0ed�Z1ded��Z2dZ3de3��Z4G�dd��de*j5�Z5G�dd��de5�Z6e5��Z7e7j8Z8e7j9Z9e7j:Z:e7j;Z;e7j<Z<e7j=Z=e7j>Z>e7j?Z?e7j@Z@e7jAZAe7jBZBe7jCZCe7jDZDe7jEZEe7jFZFe7jGZGe7jHZHe7jIZIe7jJZJe7jKZKe7jLZLe7jMZMe7jNZNdd��ZOd dd�ZPeQe)d��r�e)jRe7j8d��eSdk�r�eP���d S�)!�����)�warn)�log�exp�pi�e�ceil)�sqrt�acos�cos�sin)�tau�floor)�urandom)�Set�Sequence)� accumulate�repeat)�bisectN)�sha512)�Random�SystemRandom�betavariate�choice�choices�expovariate�gammavariate�gauss�getrandbits�getstate�lognormvariate� normalvariate� paretovariate� randbytes�randint�random� randrange�sample�seed�setstate�shuffle� triangular�uniform�vonmisesvariate�weibullvariate����g���������������@�������@��������?�������@�5�������c�����������������������s&��e�Zd�ZdZdAdd�ZdB��fdd� Z��fdd �Z��fd d�Zdd ��Zdd��Z dd��Z dd��Zdd��Zde >�fdd�ZeZdd��ZdCdd�Zdd��Zdd ��ZdDd!d"�Zdd#�d$d%�ZdEddd&�d'd(�Zd)d*��ZdFd-d.�Zd/d0��Zd1d2��Zd3d4��Zd5d6��Zd7d8��Zd9d:��Zd;d<��Zd=d>��Z d?d@��Z!���Z"S�)Gr�������Nc�����������������C���s���|���|��d�|�_d�S��N)r'���� gauss_next)�self�x��r:����/usr/lib64/python3.9/random.py�__init__u���s���� zRandom.__init__r4���c��������������������s��|dkr�t�|ttf�r�t�|t�r*|�d�n|}|rBt|d��d>�nd}tt|�D�]}d|�|A�d@�}qP|t|�N�}|dkr~dn|}nj|d kr�t�|tttf�r�t�|t�r�|���}t � |t|�����d �}n&t�|t d��t ttttf�s�tdtd ��t���|��d�|�_d�S�)N����zlatin-1r�������iCB�l��������������r4����bigz�Seeding based on hashing is deprecated since Python 3.9 and will be removed in a subsequent version. The only supported seed types are: None, int, float, str, bytes, and bytearray.)� isinstance�str�bytes�decode�ord�map�len� bytearray�encode�int� from_bytes�_sha512�digest�type�float�_warn�DeprecationWarning�superr'���r7���)r8����a�versionr9����c�� __class__r:���r;���r'���~���s"���� �zRandom.seedc��������������������s���|�j�t�����|�jfS�r6���)�VERSIONrS���r���r7����r8���rW���r:���r;���r�������s����zRandom.getstatec�������������� ������s����|d�}|dkr*|\}}|�_�t���|��nv|dkr�|\}}|�_�ztdd��|D���}W�n*�ty~�}�zt|�W�Y�d�}~n d�}~0�0�t���|��ntd||�jf���d�S�)Nr���r5���r4���c�����������������s���s���|�]}|d��V��qdS�)l��������Nr:���)�.0r9���r:���r:���r;���� <genexpr>���������z"Random.setstate.<locals>.<genexpr>z?state with version %s passed to Random.setstate() of version %s)r7���rS���r(����tuple� ValueError� TypeErrorrY���)r8����staterU���� internalstater���rW���r:���r;���r(�������s�����zRandom.setstatec�����������������C���s���|�����S�r6���)r���rZ���r:���r:���r;����__getstate__����s����zRandom.__getstate__c�����������������C���s���|���|��d�S�r6���)r(���)r8���ra���r:���r:���r;����__setstate__����s����zRandom.__setstate__c�����������������C���s���|�j�d|����fS�)Nr:���)rX���r���rZ���r:���r:���r;���� __reduce__����s����zRandom.__reduce__c����������������K���sJ���|�j�D�]>}d|jv�r�qFd|jv�r.|�j|�_�qFd|jv�r|�j|�_�qFqd�S�)N� _randbelowr���r$���)�__mro__�__dict__�_randbelow_with_getrandbitsrf����_randbelow_without_getrandbits)�cls�kwargsrV���r:���r:���r;����__init_subclass__����s���� zRandom.__init_subclass__c�����������������C���s4���|sdS�|�j�}|���}||�}||kr0||�}q|S�)Nr���)r���� bit_length)r8����nr����k�rr:���r:���r;���ri�������s���� z"Random._randbelow_with_getrandbitsr=���c�����������������C���sj���|�j�}||kr$td��t|��|��S�|dkr0dS�||�}||�|�}|��}||krZ|��}qJt||��|�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.r���)r$���rQ����_floor)r8���ro����maxsizer$����rem�limitrq���r:���r:���r;���rj�������s����z%Random._randbelow_without_getrandbitsc�����������������C���s���|���|d���|d�S�)N�����little)r����to_bytes�r8���ro���r:���r:���r;���r"�����s����zRandom.randbytesc����������� ������C���s��t�|�}||krtd��|d�u�r:|dkr2|��|�S�td��t�|�}||krRtd��||�}|dkrx|dkrx||��|��S�|dkr�td|||f���t�|�}||kr�td��|dkr�||�d�|�}n"|dk�r�||�d�|�}ntd��|dkr�td��|||��|���S�) Nz!non-integer arg 1 for randrange()r���zempty range for randrange()z non-integer stop for randrange()r=���z(empty range for randrange() (%d, %d, %d)z non-integer step for randrange()zzero step for randrange())rK���r_���rf���) r8����start�stop�step�istart�istop�width�istepro���r:���r:���r;���r%���"��s4���� zRandom.randrangec�����������������C���s���|���||d��S�)Nr=���)r%����r8���rT����br:���r:���r;���r#���N��s����zRandom.randintc�����������������C���s���||���t|���S�r6���)rf���rH���)r8����seqr:���r:���r;���r���W��s����z Random.choicec�����������������C���s����|d�u�rN|�j�}ttdt|���D�]*}||d��}||�||��||<�||<�q nTtdtd��t}ttdt|���D�]0}||��|d���}||�||��||<�||<�qpd�S�)Nr=���zuThe *random* parameter to shuffle() has been deprecated since Python 3.9 and will be removed in a subsequent version.r4���)rf����reversed�rangerH���rQ���rR���rr���)r8���r9���r$���� randbelow�i�jr ���r:���r:���r;���r)���\��s���� �zRandom.shuffle)�countsc�������������������s���t��t�rtdtd��t���t��t�s0td��t��}|d�ur�tt |���t��|kr`t d������}t�|t�sztd��|dkr�t d��|�j t|�|d�}t������fd d �|D��S�|�j}d|��kr�|ks�n�t d��d�g|�}d} |d k�r| dtt|d�d���7�} || k�r\t��} t|�D�]2}|||��}| |�||<�| ||�d��| |<��q&nNt��} | j}t|�D�]8}||�}|| v��r�||�}�q|||���|�||<��qp|S�)Nz\Sampling from a set deprecated since Python 3.9 and will be removed in a subsequent version.r4���zAPopulation must be a sequence. For dicts or sets, use sorted(d).z2The number of counts does not match the populationzCounts must be integersr���z)Total of counts must be greater than zero)rp���c��������������������s���g�|�]}����|���qS�r:���r:���)r[����s�r���� cum_counts� populationr:���r;���� <listcomp>���r]���z!Random.sample.<locals>.<listcomp>z,Sample larger than population or is negative��������r.���r5���r=���)rB����_SetrQ���rR���r^���� _Sequencer`���rH����list�_accumulater_����poprK���r&���r�����_bisectrf����_ceil�_log�set�add)r8���r����rp���r����ro����total� selectionsr�����result�setsize�poolr����r�����selected�selected_addr:���r����r;���r&���v��sT����5 � z Random.sample)�cum_weightsrp���c�������������������s����|�j��t����d�u�r�|d�u�rHt��d7������fdd�td�|�D��S�ztt|���W�q��ty����t|t�sr��|}td|���d��Y�q�0�n|d�ur�td��t���kr�t d���d�d���dkr�t d��t ���d ���������fd d�td�|�D��S�)N���������c��������������������s���g�|�]}�����������qS�r:���r:����r[���r����)r ���ro���r����r$���r:���r;���r�������r]���z"Random.choices.<locals>.<listcomp>z4The number of choices must be a keyword argument: k=z2Cannot specify both weights and cumulative weightsz3The number of weights does not match the populationr?���z*Total of weights must be greater than zeror=���c��������������������s$���g�|�]}���������d�����qS�)r���r:���r����)r���r�����hir����r$���r����r:���r;���r�������s����)r$���rH���rr����_repeatr����r����r`���rB���rK���r_���r����)r8���r�����weightsr����rp���r:���)r���r����r ���r����ro���r����r$���r����r;���r������s<���� �� �zRandom.choicesc�����������������C���s���|||�|�������S�r6����r$���r����r:���r:���r;���r+������s����zRandom.uniformr����r1���c�����������������C���sz���|�����}z |d�u�rdn||�||��}W�n�ty>���|�Y�S�0�||krbd|�}d|�}||�}}|||�t||����S�)N��������?r1���)r$����ZeroDivisionError�_sqrt)r8����low�high�mode�urV���r:���r:���r;���r*�����s���� zRandom.triangularc�����������������C���sP���|�j�}|��}d|���}t|d��|�}||�d�}|t|��krqDq|||��S�)Nr1���r����r0���)r$���� NV_MAGICCONSTr����)r8����mu�sigmar$����u1�u2�z�zzr:���r:���r;���r �����s���� zRandom.normalvariatec�����������������C���s`���|�j�}|�j}d�|�_|d�u�rT|��t�}tdtd|������}t|�|�}t|�|�|�_|||��S�)Ng��������r1���)r$���r7����TWOPIr����r�����_cos�_sin)r8���r����r����r$���r�����x2pi�g2radr:���r:���r;���r���,��s���� zRandom.gaussc�����������������C���s���t�|��||��S�r6���)�_expr ���)r8���r����r����r:���r:���r;���r���R��s����zRandom.lognormvariatec�����������������C���s���t�d|�������|�S��Nr1���)r����r$���)r8����lambdr:���r:���r;���r���\��s����zRandom.expovariatec�����������������C���s����|�j�}|dkrt|���S�d|�}|td||����}|��}tt|��}|||��}|��} | d||��k�s�| d|�t|��kr4q�q4d|�} | |�d| |���}|��}|dkr�|t|��t�} n|t|��t�} | S�)Ng���ư>r����r1���)r$���r����r����r�����_pir�����_acos)r8���r�����kappar$���r����rq���r����r�����dr�����q�f�u3�thetar:���r:���r;���r,���m��s$���� $zRandom.vonmisesvariatec�����������������C���s~��|dks|dkrt�d��|�j}|dkr�td|�d��}|t�}||�}|��}d|��k�r`dk�sdqF�qFd|���}t|d|���|�} |t| ��} ||�|�}||| ��| �}|t�d|��dks�|t|�krF| |�S�qFn�|dkr�td|�����|�S�|��} t|�t�}|| �}|dk�r$|d|��} nt||�|���} |��}|dk�r^|| |d��k�rp�qrq�|t| ��kr�qrq�| |�S�d�S�)Nr����z*gammavariate: alpha and beta must be > 0.0r1���r/���gH�����z>g�P���?r2���)r_���r$���r�����LOG4r����r����� SG_MAGICCONST�_e)r8����alpha�betar$����ainv�bbb�cccr����r�����vr9���r����rq���r����r�����pr:���r:���r;���r������s@���� zRandom.gammavariatec�����������������C���s(���|���|d�}|r$|||���|d���S�dS�)Nr1���r����)r���)r8���r����r�����yr:���r:���r;���r������s����zRandom.betavariatec�����������������C���s���d|������}d|d|���S�r����r����)r8���r����r����r:���r:���r;���r!������s����zRandom.paretovariatec�����������������C���s"���d|������}|t|��d|���S�r����)r$���r����)r8���r����r����r����r:���r:���r;���r-������s����zRandom.weibullvariate)N)Nr4���)Nr=���)N)N)r����r1���N)#�__name__� __module__�__qualname__rY���r<���r'���r���r(���rc���rd���re���rm���ri����BPFrj���rf���r"���r%���r#���r���r)���r&���r���r+���r*���r ���r���r���r���r,���r���r���r!���r-���� __classcell__r:���r:���rW���r;���r���e���s<��� *! , c& & *Ar���c�������������������@���s<���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Ze�ZZ dS�)r���c�����������������C���s���t��td�d�d?�t�S�)Nr>���rA���r5���)rK���rL����_urandom� RECIP_BPFrZ���r:���r:���r;���r$�����s����zSystemRandom.randomc�����������������C���s<���|dk�rt�d��|d�d�}t�t|�d�}||d�|�?�S�)Nr���z#number of bits must be non-negativer>���rv���rA���)r_���rK���rL���r����)r8���rp����numbytesr9���r:���r:���r;���r�����s ����zSystemRandom.getrandbitsc�����������������C���s���t�|�S�r6���)r����ry���r:���r:���r;���r"�����s����zSystemRandom.randbytesc�����������������O���s���d�S�r6���r:����r8����args�kwdsr:���r:���r;���r'���%��s����zSystemRandom.seedc�����������������O���s���t�d��d�S�)Nz*System entropy source does not have state.)�NotImplementedErrorr����r:���r:���r;����_notimplemented)��s����zSystemRandom._notimplementedN) r����r����r����r$���r���r"���r'���r����r���r(���r:���r:���r:���r;���r��� ��s��� r���c����������� ���������s����ddl�m}m}�ddlm}�|��}���fdd�t|��D��}|��}||�} ||| �} t|�}t|�}t||�d�d|���d�j �����td | | ||f���d�S�) Nr���)�stdev�fmean)�perf_counterc��������������������s���g�|�]}������qS�r:���r:���r�����r�����funcr:���r;���r����X��r]���z#_test_generator.<locals>.<listcomp>z.3fz sec, z times z"avg %g, stddev %g, min %g, max %g ) � statisticsr����r�����timer����r�����min�max�printr����) ro���r����r����r�����meanr�����t0�data�t1�xbarr����r����r����r:���r����r;����_test_generatorS��s���� r��������c�����������������C���s����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 ��d�S�)Nr:���)r����r1���)g{�G�z�?r1���)皙�����?r1���)r����r/���)r����r1���)g�������?r1���)r1���r1���)r/���r1���)g������4@r1���)g������i@r1���)�������@r����)r����r1���gUUUUUU�?) r����r$���r ���r���r,���r���r���r���r*���)�Nr:���r:���r;����_testd��s ����r�����fork)�after_in_child�__main__)r����)T�warningsr���rQ����mathr���r����r���r����r���r����r���r����r���r����r���r����r ���r����r ���r����r���r����r���r����r ���rr����osr���r�����_collections_abcr���r����r���r����� itertoolsr���r����r���r����r���r�����_os�_randomrM���r����ImportError�hashlib�__all__r����r����r����r����r����r���r����_instr'���r$���r+���r*���r#���r���r%���r&���r)���r���r ���r���r���r,���r���r���r���r!���r-���r���r(���r���r"���r����r�����hasattr�register_at_forkr����r:���r:���r:���r;����<module>0���sp��� �����*,