L i/dZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl Z ddlZ ddlZddlmZddlmZdZej,eej.ekrdZ gdZdZej6d xsd Zd evrd Zd ej:dvZGddeZ GddZ!GddZ"dZ#dZ$dZ%dZ&dZ'dZ(y#e$rdZYnwxYw)z Generic test utilities. N)module_from_specspec_from_file_location)version)_pep440z3.0.8) PytestTestercheck_free_memory_TestPythranFuncIS_MUSLF HOST_GNU_TYPEmuslTeditableceZdZdZy)FPUModeChangeWarningzWarning about FPU mode changeN)__name__ __module__ __qualname____doc__[/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/_lib/_testutils.pyrr3s'rrc"eZdZdZdZ ddZy)ra" Run tests for this namespace ``scipy.test()`` runs tests for all of SciPy, with the default settings. When used from a submodule (e.g., ``scipy.cluster.test()``, only the tests for that namespace are run. Parameters ---------- label : {'fast', 'full'}, optional Whether to run only the fast tests, or also those marked as slow. Default is 'fast'. verbose : int, optional Test output verbosity. Default is 1. extra_argv : list, optional Arguments to pass through to Pytest. doctests : bool, optional Whether to run doctests or not. Default is False. coverage : bool, optional Whether to run tests with code coverage measurements enabled. Default is False. tests : list of str, optional List of module names to run tests for. By default, uses the module from which the ``test`` function is called. parallel : int, optional Run tests in parallel with pytest-xdist, if number given is larger than 1. Default is 1. c||_yN) module_name)selfrs r__init__zPytestTester.__init__Vs &rNcddl}tj|j} tj j | jd} ddg} |g}| |z } td|Dr td|r&t|dkDr| ddt|dz zzgz } |r | d | zgz } |d k(r| d d gz } n |d k7r| d |gz } | |jg}|7|dkDr2tr| dt|gz } nddl } | jdd| dgt|zz } |j!| } | dk(S#t"$r}|j$} Yd}~| dk(Sd}~wwxYw)Nrz --showlocalsz --tb=shortc34K|]}|dk(xs|dk(yw)-mz --markersNr).0args r z(PytestTester.__call__..es!GSsd{0c[00GszMust specify -m before ---vz--cov=fastr znot slowfullz-nzMCould not run tests in parallel because pytest-xdist plugin is not available.) stacklevelz--pyargs)pytestsysmodulesrospathabspath__path__any ValueErrorint_pytest_has_xdiststrwarningswarnlistmain SystemExitcode)rlabelverbose extra_argvdoctestscoveragetestsparallelr+module module_path pytest_argsr7r<excs r__call__zPytestTester.__call__YsT--.ggoofooa&89 %|4  Jz! GJG G89 9 s7|a' C#s7|A~"667 7K  H{23 3K F? D*- -K f_ D%= (K =%%&E  HqL "c(m44  F)*,  |d5k11  ;;{+D  88D  sD55 E> EE)r'r$NFFNN)rrrrrrHrrrrr8s:'KP6:.rrc"eZdZdZej ej ejejejejgZ ejejgZejej gZdZdZdZdZdZdZdZy ) r aL These are situations that can be tested in our pythran tests: - A function with multiple array arguments and then other positional and keyword arguments. - A function with array-like keywords (e.g. `def somefunc(x0, x1=None)`. Note: list/tuple input is not yet tested! `self.arguments`: A dictionary which key is the index of the argument, value is tuple(array value, all supported dtypes) `self.partialfunc`: A function used to freeze some non-array argument that of no interests in the original function c.i|_d|_d|_yr) arguments partialfuncexpected)rs r setup_methodz_TestPythranFunc.setup_methods rctj|}i}|jjD];\}}|jtj j us-|j||<=|Sr)inspect signature parametersitemsdefault Parameterempty)rfuncrQ optional_argskr&s rget_optional_argsz"_TestPythranFunc.get_optional_argssi%%d+  ((..0 -DAqyy 1 1 7 77#$99 a  -rcrd}|jD]%}t|j|d}||kDs$|}'|S)Nrr$)rKlen)rmax_lenarg_idxcur_lens rget_max_dtype_list_lengthz*_TestPythranFunc.get_max_dtype_list_lengthsF~~ "G$..1!45G ! "rc8|t|dz kDr|dS||S)Nr$)r\)r dtype_list dtype_idxs r get_dtypez_TestPythranFunc.get_dtypes* s:q( (b> !i( (rc(t|jD]v}g}|jD]T}|j|j|d|}|j |j|dj |V|j |xy)Nr$r)ranger`rKreappendastype pythranfunc)rtype_idx args_arrayr^ new_dtypes rtest_all_dtypesz _TestPythranFunc.test_all_dtypessd<<>? *HJ>> P NN4>>'+B1+E+35 !!$.."9!"<"C"CI"NO P D  j )  *rcg}|jD]/}|j|j|ddddddd1|j|y)Nrrb)rKrhrjrrlr^s r test_viewsz_TestPythranFunc.test_viewssZ ~~ FG   dnnW5a82>ttD E F*%rcg}|jD]?}|jtj|j|ddddddA|j|y)Nrr))axis)rKrhnprepeatrjrps r test_stridedz_TestPythranFunc.test_stridedsf ~~ 9G   biiw(?(B()336Q38 9 9 *%rN)rrrrrtint8int16int32int64intcintp ALL_INTEGERfloat32float64 ALL_FLOAT complex64 complex128 ALL_COMPLEXrNrZr`rernrqrvrrrr r sz 77BHHbhh"''277KKRZZ(I<</K )*& &rr c"ddlm}|dduS)zQ Check if the pytest-xdist plugin is installed, providing parallel tests r find_specxdistN)importlib.utilrrs rr5r5s ) W T ))rc.ddl} ttjd}dj |tjd}||dzkr|j|yy#t $r+t }||jd|d|dz d}YNwxYw) zJ Check *free_mb* of memory is available, otherwise do pytest.skip rNSCIPY_AVAILABLE_MEMz={} MB memory required, but environment SCIPY_AVAILABLE_MEM={}zlCould not determine available memory; set SCIPY_AVAILABLE_MEM variable to free memory in MB to run the test.z MB memory required, but .Az MB available)r+ _parse_sizer.environformatKeyError_get_mem_availableskip)free_mbr+mem_freemsgs rrrs Orzz*?@AMTT RZZ 568'C- C  O%'   KKI J 28C<. N Os?A 1BBcddddddddddddddd d }tjd jd j|j |tj }|r|j d |vr tdt|j d||j d zS)Nrg?@@geAgmBg@g0AgAgpB)r brYMGTkbMbGbTbkibMibGibTibz^\s*(\d+)\s*({})\s*$|r)zInvalid size stringr$) rematchrjoinkeysIgroupr3float)size_strsuffixesms rrrss4Cti ) UH (//0IJ A  (*.//  x 3 33rc ddl}|jjS#ttf$rYnwxYwt j jdri}td5}|D]F}|j}t|ddz||djdj<H dddn #1swYnxYwd|vr|dS|d |d zSy) zD Get information about memory available, not counting swap. rNlinuxz /proc/meminfor$r: memavailablememfreecached) psutilvirtual_memory available ImportErrorAttributeErrorr,platform startswithopensplitrstriplower)rinfoflineps rrrs $$&000  (    ||w' / " Ba BJJL05ad c0AQqTZZ_**,- B B B B T !' ' ?T(^3 3 s 22!A B77Cc  ddl} tjddg|t t jz }tjj|d}tj|||z ||z dz dz }|d z tj d t |d z }t|d 5}|jd|jdt j"ddddt j$dk(r(tjdddd|dt |g n%tjddd|t |g tjgd t'j(d fd}|d|dfS#t$r|j dYwxYw#1swYxYw)z Helper function to test building and importing Cython modules that make use of the Cython APIs for BLAS, LAPACK, optimize, and special. rNmesonz --versionzNo usable 'meson' foundr$rB_cython_examplesbuildT)exist_okzinterpreter-native-file.iniwz [binaries] z python = ''win32setupz--buildtype=releasez --native-filez--vsenv)cwd)rcompilez-vv EXT_SUFFIXc|z j}t||}t|}|jj ||Sr) with_suffixrrloader exec_module)modnamesospecmodsuffix target_dirs rloadz$_test_cython_extension..loadEsE7" / / 7&w3t$ $ r extending extending_cpp)r+ subprocess check_callFileNotFoundErrorrr6 threading get_identr.r/rshutilcopytreemakedirsrwriter, executabler sysconfigget_config_var) tmp_pathsrcdirr+mod_name build_dir native_filerrrrs @@r_test_cython_extensionrs /w 45 #i11344Hww}}V$Q'H OOFHx/08#g-0BBIW$JKK T*i"??@K k3 01  *S^^,A./0 ||ww4. (#i.:#-   w. S^M", 5:F % %l 3F  d?3 33[ / -./ 00sF;5F=F:9F:=Gctj|fd}g}td|D]-}|jtj||f|z|/|D]}|j |D]}|j y)a Run a given function concurrently across a given number of threads. This is equivalent to using a ThreadPoolExecutor, but using the threading primitives instead. This function ensures that the closure passed by parameter gets called concurrently by setting up a barrier before it gets called before any of the threads. Arguments --------- n_workers: int Number of concurrent threads to spawn. fn: callable Function closure to execute concurrently. Its first argument will be the thread id. *args: tuple Variable number of positional arguments to pass to the function. **kwargs: dict Keyword arguments to pass to the function. c>j|g|i|yr)wait)iargskwargsbarrierfns rclosurez(_run_concurrent_barrier..closuregs  1tvrr)targetrrN)rBarrierrgrhThreadstartr) n_workersrrrrworkersrworkerrs ` @r_run_concurrent_barrierrPs* *GG 1i .y''V- ..   r))rrPr.rrrr,rrrrrnumpyrtscipycythonCython.Compiler.Versionrcython_version scipy._librrequired_versionparseVersionr__all__r r_vr1 IS_EDITABLERuntimeWarningrrr r5rrrrrrrrr s   D   #w}}^$w7G'HH O  Yo.4" R<GENN1--  > OOdE&E&P** 4254p%o  Fs CCC