
    gl                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl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Zn# e$ r dZY nw xY wd-dZd Zej                            ed          ej                            ddg          d	                         Zd
 Zd Zd Zej                            edu d          d             Zd dD             Zej        dk     red dD             z  Zg dZd dD             Zej        dk     red dD             z  Zd Zej        dk     rdgZng Zej                             d          d             Z!g dZ"ej        dk     re"g dz  Z"d Z#d  Z$ej        %                     ej&        d!          d"vd#          d$             Z'd% Z(ej                             d&          d'             Z)d( Z*d) Z+d*e,fd+Z-d, Z.dS ).    N)IS_WASMc                     || j         }i }t          |           D ]Y}|dk    r	t          | |          }t          |d          r0t          |d          r |j        |k    r|j        dz   |j         z   ||<   Z|S )zEReturns a mapping of all objects with the wrong __module__ attribute.Ncore
__module____name__.)r   dirgetattrhasattrr   )modulemodule_nameresultsnameitems        g/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/numpy/tests/test_public_api.py	check_dirr      s    oGF B B6>>vt$$D,'' 	BGD*,E,E 	BO{22 Oc1DMAGDMN    c                  F    ddi} t          t                    }|| k    sJ d S )Nrecarrayznumpy.rec.recarray)r   np)	allowlistbad_resultss     r   test_numpy_namespacer   &   s7     	(I B--K )######r   zcan't start subprocess)reasonr   testingc                     t           j        dd| z   f}t          j        |          }|rJ | t	          t
                    v sJ dS )a  Make sure we can actually use the modules we lazy load.

    While not exported as part of the public API, it was accessible.  With the
    use of __getattr__ and __dir__, this isn't always true It can happen that
    an infinite recursion may happen.

    This is the only way I found that would force the failure to appear on the
    badly implemented code.

    We also test for the presence of the lazily imported modules in dir

    z-czimport numpy; numpy.N)sys
executable
subprocesscheck_outputr	   r   )r   exeresults      r   test_import_lazy_importr#   1   sM     >4!7$!>
?C$S))F 3r77??????r   c                      t          t          t                              t          t          t          t                                        k    sJ dS )zWAssert that output of dir has only one "testing/tester"
    attribute without duplicateN)lenr	   r   set r   r   test_dir_testingr(   H   s;     s2ww<<3s3r77||,,,,,,,,r   c                  H    t          t          j                  } | i k    sJ d S N)r   r   linalgr   s    r   test_numpy_linalgr-   N   s(    BI&&K"r   c                  H    t          t          j                  } | i k    sJ d S r*   )r   r   fftr,   s    r   test_numpy_fftr0   S   s(    BF##K"r   z#ctypes not available in this pythonc                      t          j        t          j        j        j                  } t          | dd           }|
J d            d S )Ntest_not_exportedzG'test_not_exported' is mistakenly exported, NPY_NO_EXPORT does not work)ctypesCDLLr   _core_multiarray_tests__file__r
   )cdllfs     r   test_NPY_NO_EXPORTr:   X   sC     ;rx1:;;D)400A99 499999r   c                     g | ]}d |z   S numpy.r'   .0ss     r   
<listcomp>rA   n   s(     ! ! !1(Q, ! ! !r   ) 	ctypeslibdtypes
exceptionsf2pyr/   libzlib.array_utilsz
lib.formatzlib.introspectz
lib.mixinsz	lib.npyiozlib.recfunctionszlib.scimathzlib.stride_tricksr+   maz	ma.extraszma.mrecords
polynomialzpolynomial.chebyshevzpolynomial.hermitezpolynomial.hermite_ezpolynomial.laguerrezpolynomial.legendrezpolynomial.polynomialrandomstringsr   ztesting.overridestypingztyping.mypy_pluginversion)      c                     g | ]}d |z   S r<   r'   r>   s     r   rA   rA      s)     	 	 	1	 	 	r   )	distutilszdistutils.cpuinfozdistutils.exec_commandzdistutils.misc_utilzdistutils.logzdistutils.system_info)
numpy.charznumpy.emath	numpy.recc                     g | ]}d |z   S r<   r'   r>   s     r   rA   rA      s(     - - -x!| - - -r   ),compatzcompat.py3kconftestr   zcore.multiarrayzcore.numericz
core.umathzcore.arrayprintzcore.defchararrayzcore.einsumfunczcore.fromnumericzcore.function_basezcore.getlimitszcore.numerictypeszcore.overrideszcore.recordszcore.shape_basezf2py.auxfuncszf2py.capi_mapszf2py.cb_ruleszf2py.cfuncszf2py.common_ruleszf2py.crackfortranzf2py.diagnosezf2py.f2py2ezf2py.f90mod_ruleszf2py.func2subrz
f2py.ruleszf2py.symboliczf2py.use_rulesz
fft.helperzlib.user_arrayzlinalg.lapack_litezlinalg.linalgzma.corezma.testutilszma.timer_comparisonmatlib	matrixlibzmatrixlib.defmatrixzpolynomial.polyutilszrandom.mtrandzrandom.bit_generatorztesting.print_coercion_tablesc                     g | ]}d |z   S r<   r'   r>   s     r   rA   rA      s)     :$ :$ :$1:$ :$ :$r   )7zdistutils.armccompilerzdistutils.fujitsuccompilerzdistutils.ccompilerzdistutils.ccompiler_optzdistutils.commandzdistutils.command.autodistzdistutils.command.bdist_rpmzdistutils.command.buildzdistutils.command.build_clibzdistutils.command.build_extzdistutils.command.build_pyzdistutils.command.build_scriptszdistutils.command.build_srczdistutils.command.configz!distutils.command.config_compilerzdistutils.command.developzdistutils.command.egg_infozdistutils.command.installzdistutils.command.install_clibzdistutils.command.install_dataz!distutils.command.install_headerszdistutils.command.sdistzdistutils.conv_templatezdistutils.corezdistutils.extensionzdistutils.fcompilerzdistutils.fcompiler.absoftzdistutils.fcompiler.armzdistutils.fcompiler.compaqzdistutils.fcompiler.environmentzdistutils.fcompiler.g95zdistutils.fcompiler.gnuzdistutils.fcompiler.hpuxzdistutils.fcompiler.ibmzdistutils.fcompiler.intelzdistutils.fcompiler.laheyzdistutils.fcompiler.mipszdistutils.fcompiler.nagzdistutils.fcompiler.nonezdistutils.fcompiler.pathf95zdistutils.fcompiler.pgzdistutils.fcompiler.nvzdistutils.fcompiler.sunzdistutils.fcompiler.vastzdistutils.fcompiler.fujitsuzdistutils.from_templatezdistutils.intelccompilerzdistutils.lib2defzdistutils.line_endingszdistutils.mingw32ccompilerzdistutils.msvccompilerzdistutils.npy_pkg_configzdistutils.numpy_distributionzdistutils.pathccompilerzdistutils.unixccompilerc                 d    d| v sd| v sd| v rdS | t           v rdS | t          v rdS | t          v rdS dS )z%Check if this needs to be considered.z._z.testsz.setupFT)PUBLIC_MODULESPUBLIC_ALIASED_MODULESPRIVATE_BUT_PRESENT_MODULESr   s    r   is_unexpectedr^     s[    t||x4''8t+;+;u~u%%%u***u4r   znumpy.distutils.msvc9compilerz'ignore:.*np.compat.*:DeprecationWarningc                      g } t          j        t          j        t          j        dz   d          D ]3\  }}}t          |          r|t          vr|                     |           4| rt          d|            dS )z|
    Test that we don't add anything that looks like a new public module by
    accident.  Check is based on filenames.
    r   N)pathprefixonerrorzFound unexpected modules: )	pkgutilwalk_packagesr   __path__r   r^   	SKIP_LISTappendAssertionError)modnames_modnameispkgs       r   test_all_modules_are_expectedrm   )  s     H$2:<+:K;?A A A % %7E !! 	%gY&>&> OOG$$$ FD(DDEEEF Fr   )znumpy.lib.mathznumpy.matlib.charznumpy.matlib.recznumpy.matlib.emathznumpy.matlib.exceptionsznumpy.matlib.mathznumpy.matlib.linalgznumpy.matlib.fftznumpy.matlib.randomznumpy.matlib.ctypeslibznumpy.matlib.ma)znumpy.distutils.log.sysznumpy.distutils.log.loggingznumpy.distutils.log.warningsc                      d }  | d          }t           D ] }|                     | |                     !|r"t          d                    |                    dS )a  
    Method checking all objects. The pkgutil-based method in
    `test_all_modules_are_expected` does not catch imports into a namespace,
    only filenames.  So this test is more thorough, and checks this like:

        import .lib.scimath as emath

    To check if something in a module is (effectively) public, one can check if
    there's anything in that namespace that's a public function/object but is
    not exposed in a higher-level namespace.  For example for a `numpy.lib`
    submodule::

        mod = np.lib.mixins
        for obj in mod.__all__:
            if obj in np.__all__:
                continue
            elif obj in np.lib.__all__:
                continue

            else:
                print(obj)

    c                 n   g }t          j        |           }t          |d          r|j        }nt	          |          }|D ]t}|                    d          s]| dz   |z   }t          t          ||          t          j	                  r-t          |          r|t          vr|                    |           u|S )N__all__rj   r   )	importlibimport_moduler   rp   r	   
startswith
isinstancer
   types
ModuleTyper^   SKIP_LIST_2rg   )mod_namemembersr   objnamesobjnamefullobjnames         r   find_unexpected_membersz@test_all_modules_are_expected_2.<locals>.find_unexpected_membersn  s    (2269%% 	#~HH6{{H 	8 	8G%%c** 8&nw6gfg668HII 8$[11 8&k99#NN;777r   numpyz5Found unexpected object(s) that look like modules: {}N)rZ   extendrh   format)r}   unexpected_membersrk   s      r   test_all_modules_are_expected_2r   U  s    2  $ 1099! D D!!"9"9'"B"BCCCC G ++162D+E+EG G 	GG Gr   c                     d } g }t           D ]"} | |          s|                    |           #|r"t          d                    |                    t          D ]7}	 t          |           # t          $ r |                    |           Y 4w xY w|r"t          d                    |                    t          j        d          5 }t          j	        dt                     t          j	        dt                     t          D ]"} | |          s|                    |           #	 ddd           n# 1 swxY w Y   |r"t          d	                    |                    dS )
a	  
    Check that all submodules listed higher up in this file can be imported

    Note that if a PRIVATE_BUT_PRESENT_MODULES entry goes missing, it may
    simply need to be removed from the list (deprecation may or may not be
    needed - apply common sense).
    c                 b    	 t          j        |            n# t          t          f$ r Y dS w xY wdS )NFT)rq   rr   ImportErrorAttributeError)r   s    r   check_importablez-test_api_importable.<locals>.check_importable  sI    	#K0000^, 	 	 	55	 ts    ,,z5Modules in the public API that cannot be imported: {}z1Modules in the public API that were not found: {}T)recordalways)categoryNzPModules that are not really public but looked public and can not be imported: {})rZ   rg   rh   r   r[   evalr   warningscatch_warningsfilterwarningsDeprecationWarningImportWarningr\   )r   module_namesr   ws       r   test_api_importabler     s      L% - -,, 	-,,, B ,,2F<,@,@B B 	B . - -	- 	- 	- 	-,,,,,	-  ? ))/)=)=? ? 	? 
	 	-	-	- 13EFFFF=AAAA6 	1 	1K##K00 1##K000	11 1 1 1 1 1 1 1 1 1 1 1 1 1 1  8 ""(&"6"68 8 	88 8s%   A..BBA!D::D>D>Py_DEBUG)Nr   0zNumPy possibly built with `USE_DEBUG=True ./tools/travis-test.sh`, which does not expose the `array_api` entry point. See https://github.com/numpy/numpy/pull/19800c                  N   t          j        d          t          j        v } t          j                                        }	 |                    d          }n&# t          $ r |	                    dg           }Y nw xY wt          |          dk    r| rd}t          |          ddS 	 t          d |D                       }n%# t          $ r | rd}t          |          dY dS w xY w|j        d	k    rdS |                                }d
|j         d}|t           u s
J |            dS )zx
    Entry point for Array API implementation can be found with importlib and
    returns the main numpy namespace.
    platlib	array_api)groupr   z%No entry points for 'array_api' foundNc              3   0   K   | ]}|j         d k    |V  dS )r~   Nr]   )r?   eps     r   	<genexpr>z-test_array_api_entry_point.<locals>.<genexpr>  s.      <<G););"););););<<r   z%'numpy' not in array_api entry pointsznumpy.array_apiznumpy entry point value 'z0' does not point to our Array API implementation)	sysconfigget_pathr   r7   rq   metadataentry_pointsselectr   getr%   rh   nextStopIterationvalueloadr~   )numpy_in_sitepackagesepsxp_epsmsgr   xps         r   test_array_api_entry_pointr     so     &.y99R[H


)
)
+
+C*+.. * * *
 b))* 6{{a  	09C %%4/<<v<<<<<     	09C %%4/	 
x$$$ 		B	9BH 	9 	9 	9  ;;;;;;;;s$    A  A:9A:'C C#"C#c                      d } d } | t           j                  } ||          } | t          j                              } ||          }||k    s J d|                    |                       dS )z
    Checks if `dir(np)` and `np.__all__` are consistent and return
    the same content, excluding exceptions and private members.
    c                     d | D             S )Nc                 <    h | ]}|                     d           |S )rj   )rs   )r?   ms     r   	<setcomp>zYtest_main_namespace_all_dir_coherence.<locals>._remove_private_members.<locals>.<setcomp>  s)    ???aQ\\#->->????r   r'   
member_sets    r   _remove_private_memberszFtest_main_namespace_all_dir_coherence.<locals>._remove_private_members  s    ??:????r   c                 .    |                      dh          S )Nbool)
differencer   s    r   _remove_exceptionszAtest_main_namespace_all_dir_coherence.<locals>._remove_exceptions  s"    $$&
   	r   zMembers that break symmetry: N)r   rp   __dir__symmetric_difference)r   r   all_membersdir_memberss       r   %test_main_namespace_all_dir_coherencer     s    
@ @ @  
 *)"*55K$$[11K))"*,,77K$$[11K+%%%	;++K88	; 	; &%%%%r   z:ignore:numpy.core(\.\w+)? is deprecated:DeprecationWarningc                     ddl m}  t          t          j                  D ]}|                    d          s|dv sd| t          v r(t          t          j        |          }t          j	        |          rf|}|}t          |          D ]Q}|                    d          rt          ||          }t          d| |g          }|t          ||          u sJ R|t          | |          u sJ dS )	zp
    Check that all "semi-public" members of `numpy._core` are also accessible
    from `numpy.core` shims.
    r   Nrj   )testsrJ   r=   __znumpy.core.)fromlist)
numpy.corer   r	   r   r5   rs   r[   r
   inspectismodule
__import__)r   member_namemember	submodulesubmodule_namesubmodule_member_namesubmodule_membercore_submodules           r   test_core_shims_coherencer     s]    28}} "8 "8 ""3''	222%%%)???;//
 F## 	8I(N),Y  %(33D99 #*96K#L#L !+2.2234" " "
 (7"$9, ,       WT;7777777E"8 "8r   c                      ddl m} m}m}m}m}m} ddlm} t          h}t                      }t                      }	g }
t          g}t          |          dk    r|                                }t          |          D ]\}t          ||          }t!          j        |          rZd|j        v rQ|                    d          s<d|j        vr3|dvr/||vr+|                    |           |                    |           t!          j        |          st/          ||t          j        f          r||v r|j        dv r|j        dk    r|j        d	k    r|j                            d
          r|j        dv r|j        dk    r|j        dk    r|
                    |j        |j        |	|         f           =|                    |           |j        |	|<   ^t          |          dk    ~~~	t          |
          dk    s
J |
            dS )z
    Check that each public function is available from one location only.

    Test performs BFS search traversing NumPy's public API. It flags
    any function-like object that is accessible from more that one place.
    r   )AnyCallableDictListSetTuple)_ArrayFunctionDispatcherr~   rj   numpy._core)rE   rG   r   r   )absolutearccosarccosharcsinarcsinharctanarctan2arctanh
left_shiftright_shift	conjugateinvert	remainderdivideconcatenatepower	transposetrimcoefznumpy.polynomialaddequal	not_equalgreatergreater_equalless
less_equalnumpy.stringsrQ   N)rK   r   r   r   r   r   r   numpy._core._multiarray_umathr   r   r&   dictr%   popr	   r
   r   r   r   rs   rg   r   
isfunctionrt   ufunc)r   r   r   r   r   r   dispatched_functionvisited_modulesvisited_functionsfunctions_original_pathsduplicated_functionsmodules_queuer   r   r   s                  r   test_functions_single_locationr   :  s    =<<<<<<<<<<<<<<<      /1TO14 ?Cff )+DM
m

q
 
 ""$$v;; P	G P	GKV[11F  ((LG6?****3// +V_44#EEEo--$$V,,,##F++++ "6**?G6$7#BCC?G ...  ,  & 722  :55223EFF 6 !  +   !/_<<  ,66  )//1&9;    &))&1117=,V4i m

q
 
 l 	?,D#$$)))+?)))))r   c                     t           g} t           h}t                      }g }t          |           dk    r|                                 }t	          |          D ]j}t          ||          }t          j        |          rZd|j        v rQ|	                    d          s<d|j        vr3|dvr/||vr+| 
                    |           |                    |           t          j        |          st          |d          r|j        	                    d          s|j        |j        k    r||vr|j        dv r|j        dk    r|j        d	k    r|j        dk    s|j        d
k    r|j        dk    r|j        dv r!|
                    t          |j        |j        |j                             |                    |           lt          |           dk    |rt          |          dk    sJ |            d S d S )Nr   r~   rj   r   )charr   rB   rE   rG   lapack_litemrecordsr   r   rH   rK   mtrandbit_generatorr   r   r   r   r   rR   )	BitGenerator	GeneratorMT19937PCG64	PCG64DXSMPhiloxRandomStateSFC64SeedSequence)Funcactualexpected)r   r&   r%   r   r	   r
   r   r   r   rs   rg   r   r   r   r   r   r   r   incorrect_entriesr   r   r   s          r   test___module___attributer    ss   DMdO
m

q
 
 ""$$v;; 5	. 5	.KV[11F  ((2.6?****3// +V_44 $  
 o--$$V,,,##F++++$V,,#.
++#. O..s33#. !V_44/// ? '   o88 _
22v'7Q7Q_00V_5S5S ? '   !((#_%0!'     "%%f---o m

q
 
 r  >$%%***,=***> >**r   returnc                 6   | j         }| j        }| j        }||                    d          d         k    sJ t          j        |         }t          j        t          |                    d          |          }|| u p|	                    d          o
|j         |k    S )Nr   znumpy.random)
__qualname__r   r   splitr   modules	functoolsreducer
   rs   )objqualnamer   r   r   
actual_objs         r   _check___qualname__r    s    H<D.K8>>#&&r*****[%F!'8>>#+>+>GGJc 	
 "">22 0#x/r   c                  v   t           g} t           h}t                      }g }t          |           dk    rc|                                 }t	          |          D ]*}t          ||          }t          j        |          rZd|j        v rQ|	                    d          s<|dvr8d|j        vr/||vr+| 
                    |           |                    |           t          j        |          st          |d          r|j        	                    d          sk|	                    d          sVt          |          sG||vrC|
                    t          |j        |j                             |                    |           ,t          |           dk    c|rt          |          dk    sJ |            d S d S )Nr   r~   rj   )rE   rG   r   r   rK   r  rB   r   r   r   )r  r  )r   r&   r%   r   r	   r
   r   r   r   rs   rg   r   r   r  r   r  r  s          r   test___qualname___attributer     s   DMdO
m

q
 
 ""$$v;; 	. 	.KV[11F  ((.6?****3// + $   V_44o--$$V,,,##F++++$V,,.
++. O..s33.  **3//	.
 (//. ///!((%2V_    
 "%%f---? m

q
 
 B  >$%%***,=***> >**r   r*   )/r  r   r   r   rc   ru   rq   r   r   r~   r   numpy.testingr   pytestr3   r   r   r   markskipifparametrizer#   r(   r-   r0   r:   rZ   version_infor[   r\   r^   rf   r   rm   rw   r   r   xfailget_config_varr   r   r   r   r  r   r  r   r'   r   r   <module>r)     s       



                      ! ! ! ! ! ! MMMM   FFF   $ $ $ G$<==)--  .- >=*- - -  
  
 FdN@  B B5 5B B5(! ! !) ! ! !D g 	 	
	 	 	 	N   - - -6 - - - \ g :$ :$8
:$ :$ :$ :z  " g01III EFFF F GFF,   g    K1G 1G 1Gh-8 -8 -8` IZ((>	8   . . .b  2 A )8 )8 )8Xp@ p@ p@f@> @> @>F    $(> (> (> (> (>s   = AA