L i.ddlZddlZddlZddlmZddlZddlmZddl Z ddl m Z gdZ GddZdZdZ d d ZGd d Zy) N)_pep440)assert_)with_special_errorsassert_func_equalFuncDataceZdZdZy) MissingModulec||_yN)name)selfr s ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/special/_testutils.py__init__zMissingModule.__init__s  N)__name__ __module__ __qualname__rrrr r srr cFt|tur-tjj |j dStjj tj|jtj|k|jd|dS)Nz is not installedreasonz version >= z required) typer pytestmarkskipr skipifrparse __version__Versionr)modulemin_vers r check_versionr"s F|}${{&++6G'HII ;;   f(()GOOG,DD//",wiyA  rcBtjfd}|S)zc Enable special function errors (such as underflow, overflow, loss of precision, etc.) cptjd5|i|}ddd|S#1swYSxYw)Nraiseall)scerrstate)akwresfuncs rwrapperz$with_special_errors..wrapper*s6 [[W % !.R.C !  ! s +5) functoolswraps)r-r.s` rrr%s' __T Nrc t|dr t|}tj|}|jdk(r |dddf}|j d} t|dr|} d}|}n9tj ||f} tt| | j d}d}t|| tt| ||||||| || |  }|jy)Nnextr) result_columns result_funcrtolatol param_filter knownfailurenan_ok vectorizedignore_inf_signdistinguish_nan_and_inf) hasattrlistnpasarrayndimshapec_rangercheck)r-resultspointsr6r7r8r9r;dtyper:r<r=nparamsdatar4r5fdatas rrr7svvf ZZ F {{a$ll1oGw # uuVW_%eGTZZ];< T4eGn!5$2 T ".v*%4-D  FE  KKMrc4eZdZdZ ddZdZddZdZy) ra 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|ds|f}t ||_|.t|ds|f}t ||_|"d}t||d|_n td||_||_ ||_ t|ds|f}||_ | |_ | |_ | |_| |_||_|j sd|_yy)N__len__z5Only result_func or result_columns should be providedz7Either result_func or result_columns should be providedT)r-rKdatanamer>tuple param_columnsr4 ValueErrorr5r6r7r8r9r:r;r<r=)r r-rKrRr4r5r6r7r8r9rPr:r;r<r=messages rrzFuncData.__init__s    }i0*,M"=1  %>95"0!2"'"7D &Q ))  $"&D VW W&  |Y/(?L(( $.'>$++#'D ,rc"tj|tjstjt}tj |}|j |j}}|d|jz}|d|jz}||fS)N) r@ issubdtypeinexactrIfloatfinfor6r7epstiny)r rIinfor6r7s rget_toleranceszFuncData.get_tolerancessm}}UBJJ/HHUOExxYY d <TXX:D <TYY;DTzrc < *+tjdt}jr t j j| j }| |j}n|j|}j|\}}jr}tj|jdftj}tj jD]#\*}|s |t#||dd*fz}%||}g+t%j D]\} *tj&*rAt)*j**+j-|dd*fjt.\|r9| t1|kr++j-|dd*fj|| +j-|dd*fd+fd } | j2} j4+t7j4D cgc] } |dd| f c} } nHd}j8r&t1| dk(rtj:| d}| j<|} t?t1| t1| k(t%t| | D]\}\}}tj@|jtjBs jDrUtjF|}tjF|}tjF|}tjF|}nTtjH|}tjH|}tjJ|}tjJ|}tj:|}tj:|}tjLd 5tjN|}d|tjP|<tjN||z }d|tjP|<|tjN|z }d|tjP|<ddd||zzk}||k(}||k(}||k(}||z|z|z}|jR} j8r"||z}||z}| ||zjUz} jVsZj8sNtjF|}!tjF|}"|!|z||"zz}#||#z}| |#jUz} tjX|sd g}$|$j-d ||j[d |$j-d |j[d |$j-dtjT|d| d|dtj\|dD]*t)***fd}%dj_ta|%+}&dj_ta|%| }'dj_ta|%| }(|%|})|$j-|&d|'d|(d|)dt?ddj_|$ycc} w#1swY+xYw)z,Check the special function against the data. errisinstancerNrc jr|}ng}ttdD]l}|%||r |jtj *|j|t ttDcgc] }|| c}nt j|}t|t s|f}|Scc}w)Nr) r;rElenappendr@nanrQrA isinstance)r- skip_maskgotjiparamsr s reval_func_at_paramsz+FuncData.check..eval_func_at_paramssFms6!9~.YA ,1 266* JJtU%F BT+UQF1IaL+U%VWX Y jjoc5)fJ ,Vs?Cr3)rfignorer&z Max |adiff|: gz Max |rdiff|: z Bad results (z out of z&) for the following points (in output z):c<tj|ddS)N) precision30s)r@ array2string)xrhs rfmtzFuncData.check..fmt.s"$//!A$""Ec!JKrz z => z != z (rdiff )F r )1operator methodcallerAssertionErrorr9rxfailrKrIastyper^r8r@onesrCbool_ziprRr? enumerate iscomplexobjintimagrccomplexrbr-r4rQr:isnanr5rrWcomplexfloatingr<isinfisposinfisneginfr)absoluteisfinitesizesumr=anymaxnonzerojoinmap),r rKrIdtypes__tracebackhide__r6r7 param_maskfilteridxrkrgicolwantedrf output_numrtypinf_xpinf_yminf_xminf_ynan_xnan_yabs_ydiffrdifftol_mask pinf_mask minf_masknan_maskbad_j point_countinf_xinf_yboth_nonfinitemsgrur*bcdrhrjs,` @@rrFzFuncData.checks$11 ^     LL 1 1 2 <99D =JJE;;u%D((/ d   $**Q-!1288 / JA}}QWWb&8&89T=Q=Q!!!!QQQQHHQKEHHQKE* / A-.r{{5))*{{1q5)+,bkk$''(r{{1~--.r{{5))* /tEz 11H6)I6)IH*Y6ABE**K{{%% 2244 //   "'%-EEM!B.(~1133 vve}d ]4;??+ /J4 / /sZ BZZ chtjtttj|j rd}nd}|j rFd|jj|dtjj|j dSd|jj|dS)zPretty-printingz (complex)rmz ) r@rr?rrrRrPr-rospathbasename)r is_complexs r__repr__zFuncData.__repr__7s 66$s2??D,>,>?@ A%JJ == !3!3 4ZLww'' 67q: ;  2 23JrsY !  B  $>B6::?EIBiBiBr