
    tKg.                         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y)    N)_pep440)assert_)with_special_errorsassert_func_equalFuncDatac                       e Zd Zd Zy)MissingModulec                     || _         y N)name)selfr   s     \/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/scipy/special/_testutils.py__init__zMissingModule.__init__   s	    	    N)__name__
__module____qualname__r    r   r   r	   r	      s    r   r	   c                 H   t        |       t        k(  r-t        j                  j	                  | j
                   d      S t        j                  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|}${{&++6G'HII;;f(()GOOG,DD//",wiyA   r   c                 B     t        j                          fd       }|S )zc
    Enable special function errors (such as underflow, overflow,
    loss of precision, etc.)
    c                  p    t        j                  d      5   | i |}d d d        |S # 1 sw Y   S xY w)Nraiseall)scerrstate)akwresfuncs      r   wrapperz$with_special_errors.<locals>.wrapper*   s1    [[W%.R.C &
 &
s   	+5)	functoolswraps)r-   r.   s   ` r   r   r   %   s'    
 __T  Nr   c                    t        |d      rt        |      }t        j                  |      }|j                  dk(  r	|d d d f   }|j
                  d   }t        |d      r|}d }|}n9t        j                  ||f   }t        t        ||j
                  d               }d }t        | |t        t        |            |||||||	||
|      }|j                          y )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ZZF{{a$ll1oGw
# uuVW_%eGTZZ];<T4eGn!5$2T".v*%4-DFE 
KKMr   c                   4    e Zd ZdZ	 	 	 	 ddZd ZddZd Zy)	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.

    Nc                    || _         || _        |
| _        t        |d      s|f}t	        |      | _        |.t        |d      s|f}t	        |      | _        |"d}t        |      |d | _        nt        d      || _        || _	        || _
        t        |d      s|f}|| _        |	| _        || _        || _        || _        || _        | j                   sd| _        y y )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__   s     		 }i0*,M"=1%>95"0!2"'"7D&Q ))$"&DV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   sm    }}UBJJ/HHUOExxYY		d<TXX:D<TYY;DTzr   c                 0   *+ t        j                  dt              } j                  r t	        j
                   j                         | j                  }||j                  }n|j                  |      } j                  |      \  }} j                  r}t        j                  |j                  d   ft        j                        }t         j                    j                        D ]#  \  *}|s	|t#         ||dd*f               z  }% ||   }g +t%         j                         D ]  \  }	*t        j&                  *      rAt)        *j*                        *+j-                  |dd*f   j                  t.                     \|r9|	t1        |      k  r++j-                  |dd*f   j                  ||	                +j-                  |dd*f           d+ fd	}
 |
 j2                        } j4                  +t7         j4                  D cg c]  }|dd|f    c}      }nHd} j8                  r&t1        |      dk(  rt        j:                  |d         } |
 j<                  |      }t?        t1        |      t1        |      k(         t%        t        ||            D ]  \  }\  }}t        j@                  |j                  t        jB                        s jD                  rUt        jF                  |      }t        jF                  |      }t        jF                  |      }t        jF                  |      }nTt        jH                  |      }t        jH                  |      }t        jJ                  |      }t        jJ                  |      }t        j:                  |      }t        j:                  |      }t        jL                  d	      5  t        jN                  |      }d|t        jP                  |       <   t        jN                  ||z
        }d|t        jP                  |       <   |t        jN                  |      z  }d|t        jP                  |       <   ddd       ||z  z   k  }||k(  }||k(  }||k(  }||z  |z  |z   }|jR                  }  j8                  r"|| z  }|| z  }| ||z  jU                         z  }  jV                  sZ j8                  sNt        jF                  |      }!t        jF                  |      }"|!|z  ||"z  z  }#||# z  }| |#jU                         z  } t        jX                  |      sd
g}$|$j-                  d||   j[                         z         |$j-                  d|   j[                         z         |$j-                  dt        jT                  |      | |fz         t        j\                  |      d   D ]  *t)        *      **fd}%dj_                  ta        |%+            }&dj_                  ta        |%|            }'dj_                  ta        |%|            }( |%|      })|$j-                  |& d|' d|( d|) d        t?        ddj_                  |$              yc c}w # 1 sw Y   %xY w)z,Check the special function against the data.errisinstancer   Nr   c                    j                   r |  }ng }t        t        d               D ]l  }|%||   r |j                  t        j
                         *|j                   | t        t        t                    D cg c]
  }|   |    c}              n t	        j                  |      }t        |t              s|f}|S c c}w )Nr   )	r;   rE   lenappendr@   nanrQ   rA   
isinstance)r-   	skip_maskgotjiparamsr   s        r   eval_func_at_paramsz+FuncData.check.<locals>.eval_func_at_params   s    Fms6!9~.A ,1

266* JJtU%FBT+UBTQF1IaLBT+U%VWX	 /
 jjoc5)fJ	 ,Vs   ?Cr3   )rf   ignorer&    zMax |adiff|: %gzMax |rdiff|: %gzCBad results (%d out of %d) for the following points (in output %d):c                 >    dt        j                  |    d      z  S )Nz%30s   )	precision)r@   array2string)xrh   s    r   fmtzFuncData.check.<locals>.fmt.  s    %!(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imagrc   complexrb   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idxrk   rg   icolwantedrf   
output_numrr   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msgrs   r*   bcdrh   rj   s,   `                                         @@r   rF   zFuncData.check   s}   $11^
 LL 1 12<99D=JJE;;u%D((/
d $**Q-!1288<J !3!3T5F5FG	6$vd1Q3i'8"99J H 
#D  2 23FCq!Kd1Q3i..w78C#f+-d1a4j//s<=d1Q3i( 4	  "$)), *T5H5HI5HTD4L5HIJF I{{s3x1}HHSV,	()9)9YOF 	CCK'("+CV,<"=JA}}QWWb&8&89T=Q=Q!!!!QQQQHHQKEHHQKE*A-.r{{5))*{{1q5)+,bkk$''(r{{1~--.r{{5))* + tEz 11H6)I6)IH*Y6ABE**K{{%%2244//"'%-EEM!B.(~1133vve}d

,tE{/@@A

,uU|/?/?/AAB

 - ffUm[*FG H E*1-AAAL		#c6"23A		#c3-0A		#c6"23AE
AJJ!D4s)A3a@A . tyy~.} #> J4 +*s   ZBZZ	c                 x   t        j                  t        t        t         j                  | j
                                    rd}nd}| j                  rNdj                  | j                  j                  |t        j                  j                  | j                              S d| j                  j                   | dS )z%Pretty-printing, esp. for Nose outputz
 (complex)rm   z<Data for {}{}: {}>z
<Data for >)r@   r   r?   r   r   rR   rP   formatr-   r   ospathbasename)r   
is_complexs     r   __repr__zFuncData.__repr__7  s    66$s2??D,>,>?@A%JJ==(//		0B0BJ,.GG,<,<T]],KM M  		 2 23J<qAAr   )NNNNNNNFTFT)NNN)r   r   r   __doc__r   r^   rF   r   r   r   r   r   r   X   s0    &P BFFJLP@D!(F	F/P
Br   r   )	NNNNTNFFT)r   r/   rv   
scipy._libr   numpyr@   numpy.testingr   r   scipy.specialspecialr(   __all__r	   r"   r   r   r   r   r   r   <module>r      sY    	     !  
B 

$ >B6::?EIBiB iBr   