a
    Re6                     @   s0  d dl mZ d dlmZ d dlZd dlZd dlZd dlmZ d dl	Z
d dlmZmZ d dlZd dlmZmZ d dlZd dlmZmZmZmZmZmZmZmZmZmZ dd Zd	d
 Zdd Z dd Z!dd Z"dd Z#ej$%dddd Z&dd Z'dd Z(G dd dZ)G dd dZ*G dd  d Z+d!d" Z,dS )#    )PoolN)Fraction)assert_equalassert_)raisesdeprecated_call)
_aligned_zeroscheck_random_state
MapWrappergetfullargspec_no_selfFullArgSpecrng_integers_validate_int_rename_parameter_contains_nan_rng_html_rewritec                  C   sr   d} dd }dD ]\}dD ]R}dD ]H}t jt jfD ]6}|ddd	|ffD ] }t| D ]}||||| qPqDq0q qqd S )
N
   c                 S   s   t | |||f}t| |||d}|d u r4t|j}t|jd d | d t| drft|j| | nt|j| f| t|j| |dkrt	|j
j| n@|dkr|jdkrt	|j
j| n|d u rt	|j
j| nt d S )N)aligndatar   __len__CF)reprr   npdtype	alignmentr   Z__array_interface__hasattrshaper   flagsc_contiguoussizef_contiguous
ValueError)r   r   orderr   err_msgx r&   O/var/www/sunrise/env/lib/python3.9/site-packages/scipy/_lib/tests/test__util.pycheck   s"    

z"test__aligned_zeros.<locals>.check)	                      @   N)r   r)   r+      )r   r   Nr)   r*   r+   )r   uint8float64range)Zniterr(   r   nr#   r   r   jr&   r&   r'   test__aligned_zeros   s    r7   c                  C   s   t d} tt| tjj t | } tt| tjj t d } tt| tjj ttt d ttjdrtj	tj
 }t |} tt| tjj	 d S )Nr)   a	Generator)r	   r   typer   randomRandomStateassert_raisesr"   r   r9   ZPCG64)ZrsiZrgr&   r&   r'   test_check_random_state7   s    r>   c               
   C   s   t d} t| j}t|tdgd d dg d i  t| j}t|tddgd d d g d i  G dd d}| }t|j}t|tg dd	d
ddgdd ii  d S )Nr)   pool)r)   funciterablec                   @   s   e Zd ZdddddZdS )z0test_getfullargspec_no_self.<locals>._rv_genericr*   r+   N)r    c                _   s   d S Nr&   )selfr8   bcr    argskwargsr&   r&   r'   _rvsT   s    z5test_getfullargspec_no_self.<locals>._rv_generic._rvs)r*   r+   )__name__
__module____qualname__rH   r&   r&   r&   r'   _rv_genericS   s   rL   )r8   rD   rE   rF   rG   )r*   r+   r    )r
   r   __init__r   r   __call__rH   )pZargspecrL   Zrv_objr&   r&   r'   test_getfullargspec_no_selfJ   s    


rP   c                  C   s   t d} t | }td}t|jtu  t|jd u  t|jdu  t	|t j| }t
|| tt td}W d    n1 s0    Y  d S )N      $@r)   Fr   )r   arangesinr
   r   _mapfuncmapr?   	_own_poollistr   r=   RuntimeError)in_argout_argrO   outr&   r&   r'   test_mapwrapper_serial]   s    



r\   c                  C   s>   t d"} | tjg d W d    n1 s00    Y  d S )Nr*   )r)   r*   r+   r,   )r   rU   mathrS   )rO   r&   r&   r'   	test_pooll   s    
r^   c                  C   s.  t d} t | }tdV}|t j| }tt|| t|jdu  tt|j	t
 t|jd u W d    n1 sx0    Y  tt}|t j|  W d    n1 s0    Y  t|jtu  tdL}t|j}t|jdu  |  |t j| }tt|| W d    n1 s 0    Y  d S )NrQ   r*   TF)r   rR   rS   r
   r   rW   r   rV   
isinstancer?   PWLrT   r=   	Exceptionr:   r"   r   rU   close)rY   rZ   rO   r[   excinfoqr&   r&   r'   test_mapwrapper_parallelq   s"    


,
*

re   key)ifftdiagarccosrandnrandarrayc           	      C   s   | dv rddg}n| dkr t }nd}tt| }d|  }t|d}|| W d   n1 s^0    Y  d	d
 |jD }dd
 |D }d|v sJ | dv rtj}n| dkrtj}nt}t|| }|| ||usJ t|t	rt|t	sJ dS )z9Test that 'from numpy import *' functions are deprecated.)rg   rh   ri   g      ?g        finfor*   z scipy\.%s is deprecated.*2\.0\.0matchNc                 S   s   g | ]}t j|jd  qS )r   )ospathsplitextfilename).0dr&   r&   r'   
<listcomp>       z*test_numpy_deprecation.<locals>.<listcomp>c                 S   s   g | ]}t j|qS r&   )rp   rq   basename)rt   fnamer&   r&   r'   rv      rw   Z
test__util)rk   rj   rg   )
floatgetattrscipyr   rW   r   r;   Zfftr_   r:   )	rf   argr@   ro   depfnames	basenamesrootZfunc_npr&   r&   r'   test_numpy_deprecation   s,    

&

r   c                  C   s   t   tjg dtjd} | jtjks,J | jtjks<J ttj} | jttjjks`J tjtjkspJ t	tjtjsJ W d    n1 s0    Y  d S )Nr)   r*   r+   r   )
r   r|   rl   r3   r   r   rm   float32Zeps
issubclass)r%   r&   r&   r'   $test_numpy_deprecation_functionality   s    r   c                  C   sh  t j } t| ddddd}t |dks.J t |dks@J |jdksNJ t| dddd}t |dkspJ t |dksJ |jdksJ t| dddd	d}t |d
ksJ t |dksJ |jdksJ t| ddd	d}t |d
ksJ t |dks
J |jdksJ zt j } W n ty>   Y d S 0 t| ddddd}t |dksfJ t |dkszJ |jdksJ t| dddd}t |dksJ t |dksJ |jdksJ t| dddd	d}t |d
ksJ t |dksJ |jdksJ t| ddd	d}t |d
ks@J t |dksTJ |jdksdJ d S )Nr*      d   T)lowhighr    endpoint)r   )r   r    r   r   Fr,   )	r   r;   r<   r   maxminr   Zdefault_rngAttributeError)rngZarrr&   r&   r'   test_rng_integers   sJ    
r   c                	   @   sn   e Zd Zejddedede	dgdd Z
ejdde	dgeddgdd Zd	d
 ZdS )TestValidateIntr5   r,   c                 C   s   t |d}|dksJ d S )Nr5   r,   )r   rC   r5   r&   r&   r'   test_validate_int   s    
z!TestValidateInt.test_validate_intg      @r)   c                 C   s<   t jtdd t|d W d    n1 s.0    Y  d S )Nzn must be an integerrn   r5   )pytestr   	TypeErrorr   r   r&   r&   r'   test_validate_int_bad  s    z%TestValidateInt.test_validate_int_badc                 C   s>   t jtdd tddd W d    n1 s00    Y  d S )Nz$n must be an integer not less than 0rn   r5   r   )r   r   r"   r   )rC   r&   r&   r'   test_validate_int_below_min  s    z+TestValidateInt.test_validate_int_below_minN)rI   rJ   rK   r   markparametrizer   r2   int16rl   r   r   r   r   r&   r&   r&   r'   r      s
   &
 
r   c                   @   sD   e Zd Zedddd Zedddddd Zd	d
 Zdd ZdS )TestRenameParameteroldnewc                 C   s   |S rB   r&   rC   r   r&   r&   r'   old_keyword_still_accepted  s    z.TestRenameParameter.old_keyword_still_acceptedz1.9.0)dep_versionc                 C   s   |S rB   r&   r   r&   r&   r'   old_keyword_deprecated  s    z*TestRenameParameter.old_keyword_deprecatedc                 C   sP  |  d}| j dd}| j dd}||  kr@|  kr@dksFn J td}tjt|d | j dd W d    n1 s0    Y  td}tjt|d | j ddd W d    n1 s0    Y  tjt|d | j ddd W d    n1 s0    Y  tjt|d | j ddd W d    n1 sB0    Y  d S )	Nr   r   r   z.old_keyword_still_accepted() got an unexpectedrn   Z
unexpectedz)old_keyword_still_accepted() got multipler   r   )r   reescaper   r   r   )rC   res1res2res3messager&   r&   r'   test_old_keyword_still_accepted  s    
$
*
,.z3TestRenameParameter.test_old_keyword_still_acceptedc              	   C   s  d}|  d}| j dd}tjt|d | j dd}W d    n1 sJ0    Y  ||  krr|  krrdksxn J td}tjt|d | j dd W d    n1 s0    Y  td}tjt|d | j ddd W d    n1 s0    Y  tjt|dN tjt|d | j ddd W d    n1 sF0    Y  W d    n1 sf0    Y  tjt|dN tjt|d | j ddd	 W d    n1 s0    Y  W d    n1 s0    Y  d S )
Nz+Use of keyword argument `old` is deprecatedr   r   rn   r   z*old_keyword_deprecated() got an unexpectedr   z%old_keyword_deprecated() got multipler   )r   r   ZwarnsDeprecationWarningr   r   r   r   )rC   Zdep_msgr   r   r   r   r&   r&   r'   test_old_keyword_deprecated0  s(    
*$
*
,Nz/TestRenameParameter.test_old_keyword_deprecatedN)rI   rJ   rK   r   r   r   r   r   r&   r&   r&   r'   r     s   

r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestContainsNaNTestc                 C   s   t dddt jg}t|dd\}}|s,J |dks8J t|dd\}}|sPJ |dks\J d}tjt|d t|d	d W d    n1 s0    Y  d
}tjt|d t|dd W d    n1 s0    Y  d S )Nr)   r*   r+   	propagate)
nan_policyZomitzThe input contains nan valuesrn   raiseznan_policy must be one ofnan)r   rl   r   r   r   r   r"   )rC   r   Zcontains_nanr   msgr&   r&   r'   test_policyN  s    *zTestContainsNaNTest.test_policyc                 C   s   t g d}t|d rJ t dddt jg}t|d sBJ t t jddt jg}t|d shJ t dddt jg}t|d rJ t jdddt jgdd}t|d sJ d S )	Nr   r   r)   r*   r+   3objectr   r   rl   r   r   )rC   data1data2data3data4Zdata5r&   r&   r'   test_contains_nan_1da  s    z(TestContainsNaNTest.test_contains_nan_1dc                 C   s   t ddgddgg}t|d r&J t ddgdt jgg}t|d sNJ t ddgdt jgg}t|d rvJ t jddgdt jggdd}t|d sJ d S )	Nr)   r*   r+   r,   r   1r   r   r   )rC   r   r   r   r   r&   r&   r'   test_contains_nan_2dq  s    z(TestContainsNaNTest.test_contains_nan_2dN)rI   rJ   rK   r   r   r   r&   r&   r&   r'   r   L  s   r   c                  C   s*   dd } t |  }g d}||ks&J d S )Nc                  S   s   g d} | S )N)znp.random.default_rng(8989843)np.random.default_rng(seed)z8np.random.default_rng(0x9a71b21474694f919882289dc1559ca) bob r&   )linesr&   r&   r'   mock_str  s    z(test__rng_html_rewrite.<locals>.mock_str)np.random.default_rng()r   r   r   )r   )r   resrefr&   r&   r'   test__rng_html_rewrite  s    	
r   )-multiprocessingr   Zmultiprocessing.poolr`   rp   r   r]   Z	fractionsr   numpyr   Znumpy.testingr   r   r   r   r=   r   r|   Zscipy._lib._utilr   r	   r
   r   r   r   r   r   r   r   r7   r>   rP   r\   r^   re   r   r   r   r   r   r   r   r   r   r&   r&   r&   r'   <module>   s6   0#!
:?3