
    ^Mh.                         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 d dl	Z	d dl
mZ g dZ G d d          Zd Zd Z	 	 	 	 ddZ G d d          ZdS )    N)_pep440)assert_)with_special_errorsassert_func_equalFuncDatac                       e Zd Zd ZdS )MissingModulec                     || _         d S N)name)selfr   s     X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/scipy/special/_testutils.py__init__zMissingModule.__init__   s    			    N)__name__
__module____qualname__r    r   r   r	   r	      s#            r   r	   c                 0   t          |           t          u r(t          j                            | j         d          S t          j                            t          j        | j	                  t          j
        |          k     | j         d| d          S )Nz is not installedreasonz version >= z	 required)typer	   pytestmarkskipr   skipifr   parse__version__Versionr   )modulemin_vers     r   check_versionr"      s    F||}$${&+'H'H'HIII;f())GOG,D,DD/AAwAAA    r   c                 F     t          j                    fd            }|S )zc
    Enable special function errors (such as underflow, overflow,
    loss of precision, etc.)
    c                  r    t          j        d          5   | i |}d d d            n# 1 swxY w Y   |S )Nraiseall)scerrstate)akwresfuncs      r   wrapperz$with_special_errors.<locals>.wrapper*   s    [W%%% 	! 	!$.R..C	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!
s   	,00)	functoolswraps)r-   r.   s   ` r   r   r   %   s:    
 _T     Nr   TFc                    t          |d          rt          |          }t          j        |          }|j        dk    r|d d d f         }|j        d         }t          |d          r|}d }|}n>t          j        ||f         }t          t          ||j        d                             }d }t          | |t          t          |                    |||||||	||
|          }|	                                 d S )Nnext   r   )
result_columnsresult_funcrtolatolparam_filterknownfailurenan_ok
vectorizedignore_inf_signdistinguish_nan_and_inf)
hasattrlistnpasarrayndimshapec_ranger   check)r-   resultspointsr6   r7   r8   r9   r;   dtyper:   r<   r=   nparamsdatar4   r5   fdatas                    r   r   r   7   s    vv fZF{a$l1oGw
## 	 uVW_%eGTZ];;<<T4eGnn!5!5$2T".v*%4-DF F FE 
KKMMMMMr   c                   6    e Zd ZdZ	 	 	 	 d	dZd Zd
dZd ZdS )r   a  
    Data set for checking a special function.

    Parameters
    ----------
    func : function
        Function to test
    data : numpy array
        columnar data to use for testing
    param_columns : int or tuple of ints
        Columns indices in which the parameters to `func` lie.
        Can be imaginary integers to indicate that the parameter
        should be cast to complex.
    result_columns : int or tuple of ints, optional
        Column indices for expected results from `func`.
    result_func : callable, optional
        Function to call to obtain results.
    rtol : float, optional
        Required relative tolerance. Default is 5*eps.
    atol : float, optional
        Required absolute tolerance. Default is 5*tiny.
    param_filter : function, or tuple of functions/Nones, optional
        Filter functions to exclude some parameter ranges.
        If omitted, no filtering is done.
    knownfailure : str, optional
        Known failure error message to raise when the test is run.
        If omitted, no exception is raised.
    nan_ok : bool, optional
        If nan is always an accepted result.
    vectorized : bool, optional
        Whether all functions passed in are vectorized.
    ignore_inf_sign : bool, optional
        Whether to ignore signs of infinities.
        (Doesn't matter for complex-valued functions.)
    distinguish_nan_and_inf : bool, optional
        If True, treat numbers which contain nans or infs as
        equal. Sets ignore_inf_sign to be True.

    NFTc                    || _         || _        |
| _        t          |d          s|f}t	          |          | _        |;t          |d          s|f}t	          |          | _        |d}t          |          n|d | _        nt          d          || _        || _	        || _
        t          |d          s|f}|| _        |	| _        || _        || _        || _        || _        | j        s	d| _        d S d S )N__len__z5Only result_func or result_columns should be providedz7Either result_func or result_columns should be providedT)r-   rK   datanamer>   tupleparam_columnsr4   
ValueErrorr5   r6   r7   r8   r9   r:   r;   r<   r=   )r   r-   rK   rR   r4   r5   r6   r7   r8   r9   rP   r:   r;   r<   r=   messages                   r   r   zFuncData.__init__   s3    		 }i00 	-*,M"=11%>955 3"0!2"'"7"7D&Q ))) ' $"&DVWWW&		|Y// 	+(?L(($.'>$+ 	(#'D   	( 	(r   c                     t          j        |t           j                  st          j        t                    }t          j        |          }| j        | j        }}|
d|j        z  }|
d|j	        z  }||fS )N   )
r@   
issubdtypeinexactrI   floatfinfor6   r7   epstiny)r   rI   infor6   r7   s        r   get_toleranceszFuncData.get_tolerances   si    }UBJ// 	$HUOOExY	d<TX:D<TY;DTzr   c                 ~   )* t          j        dt                    } j        rt	          j         j                    j        |j        }n                    |           	                    |          \  }} j
        rzt          j        j        d         ft          j                  }t           j         j
                  D ],\  )}|r%|t#           |dd)f                             z  }-|         g *t%           j                  D ]\  }	)t          j        )          rLt)          )j                  )*                    dd)f                             t.                               e|rL|	t1          |          k     r9*                    dd)f                             ||	                              *                    dd)f                    d* fd	}
 |
 j                  } j        !t7          fd j        D                       }nHd} j        r-t1          |          dk    rt          j        |d                   } |
 j        |          }t?          t1          |          t1          |          k               t%          t          ||                    D ] \  }\  }}t          j         |j        t          j!                  s j"        rQt          j#        |          }t          j#        |          }t          j#        |          }t          j#        |          }nPt          j$        |          }t          j$        |          }t          j%        |          }t          j%        |          }t          j        |          }t          j        |          }t          j&        d	
          5  t          j'        |          }d|t          j(        |           <   t          j'        ||z
            }d|t          j(        |           <   |t          j'        |          z  }d|t          j(        |           <   ddd           n# 1 swxY w Y   ||||z  z   k    }||k    }||k    }||k    }||z  |z  |z   }|j)        } j        r&|| z  }|| z  }|||z  *                                z  } j+        sW j        sPt          j#        |          } t          j#        |          }!| |z  ||!z  z  }"||" z  }||"*                                z  }t          j,        |          r{dg}#|#                    d||         -                                d           |#                    d||         -                                d           |#                    dt          j*        |          ||fz             t          j.        |          d         D ])t)          )          ))fd}$d/                    ta          |$*                    }%d/                    ta          |$|                    }&d/                    ta          |$|                    }' |$|          }(|#                    |% d|& d|' d|( d           t?          dd/                    |#                     dS )z,Check the special function against the data.errisinstancer   Nr   c                    j         r |  }ng }t          t          d                             D ]x|(|         r |                    t          j                   ,|                     | t          fdt          t                              D                                   yt	          j        |          }t          |t                    s|f}|S )Nr   c                 ,    g | ]}|                  S r   r   ).0ijparamss     r   
<listcomp>z?FuncData.check.<locals>.eval_func_at_params.<locals>.<listcomp>   s!    +U+U+UQF1IaL+U+U+Ur   )	r;   rE   lenappendr@   nanrQ   rA   
isinstance)r-   	skip_maskgotre   rf   r   s      @r   eval_func_at_paramsz+FuncData.check.<locals>.eval_func_at_params   s     	&dFms6!9~~.. Y YA ,1,

26*** JJttU+U+U+U+U+U%FBTBT+U+U+U%V%VWXXXXjooc5)) fJr   c                 (    g | ]}d d |f         S r   r   )rc   icolrK   s     r   rg   z"FuncData.check.<locals>.<listcomp>   s%    IIITD4LIIIr   r3   )rl   ignorer&    zMax |adiff|: gzMax |rdiff|: zCBad results (%d out of %d) for the following points (in output %d):c                 B    dt          j        |          d          z  S )Nz%30s   )	precision)r@   array2string)xre   s    r   fmtzFuncData.check.<locals>.fmt.  s!    %!(K(K(KKKr   z  z => z != z	  (rdiff )F
r   )1operatormethodcallerAssertionErrorr9   r   xfailrK   rI   astyper^   r8   r@   onesrC   bool_ziprR   r?   	enumerateiscomplexobjintimagri   complexrh   r-   r4   rQ   r:   isnanr5   r   rW   complexfloatingr<   isinfisposinfisneginfr)   absoluteisfinitesizesumr=   anymaxnonzerojoinmap)+r   rK   rI   dtypes__tracebackhide__r6   r7   
param_maskfilteridxrn   rm   wantedrl   
output_numrx   ypinf_xpinf_yminf_xminf_ynan_xnan_yabs_ydiffrdifftol_mask	pinf_mask	minf_masknan_maskbad_jpoint_countinf_xinf_yboth_nonfinitemsgry   r*   bcdre   rf   s+   ``                                       @@r   rF   zFuncData.check   s   $1^
 
  	3L 12222<9D=JEE;;u%%D((//
d  	$$*Q-!128<<J !3T5FGG : :	6 :$vvd111Q3i'8'8"9"99J
#D  233 	) 	)FCq!! )KKd111Q3i..w778888 )C#f++--d111a4j//s<<====d111Q3i((((	 	 	 	 	 	 	  "!$),, *IIIIT5HIIIJJFF I{ -s3xx1}}HSV,,	(()9YOOOF 	CCKK'((("+CV,<,<"="= >	/ >	/JA}QWb&899 	(T=Q 	(!!!!QQQQHQKKEHQKKE*** / /A-.r{5)))*{1q5))+,bk$'''(r{1~~--.r{5)))*/ / / / / / / / / / / / / / / tEz 11H6)I6)IH*Y6ABE*K{ 5%%22444/ 4 4"'%-EEM!B.(~11333ve}} /d

@4;??+<+<@@@AAA

A5<+;+;+=+=AAABBB

 - fUmm[*FG H H H E**1- B BAAAL L L L L		#c6"2"233A		#c3--00A		#c6"2"233AE

AJJ!@@@@@@A@@@AAAAtyy~~...}>	/ >	/s   BQ$$Q(	+Q(	c                 (   t          j        t          t          t           j        | j                                      rd}nd}| j        r7d| j        j         | dt          j
                            | j                   dS d| j        j         | dS )zPretty-printingz
 (complex)rr   z
<Data for z: >)r@   r   r?   r   r   rR   rP   r-   r   ospathbasename)r   
is_complexs     r   __repr__zFuncData.__repr__7  s    6$s2?D,>??@@AA 	%JJJ= 	B:!3 :Z : :w''66: : : ; B	 2AJAAAAr   )NNNNNNNFTFT)NNN)r   r   r   __doc__r   r^   rF   r   r   r   r   r   r   X   s        & &P BFFJLP@D!( !( !( !(F	 	 	F/ F/ F/ F/P
B 
B 
B 
B 
Br   r   )	NNNNTNFFT)r   r/   r|   
scipy._libr   numpyr@   numpy.testingr   r   scipy.specialspecialr(   __all__r	   r"   r   r   r   r   r   r   <module>r      s)   				                ! ! ! ! ! !       
B
B
B       
  
 
 
$ >B6::?EI   BiB iB iB iB iB iB iB iB iB iBr   