
    *il                        S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SK
rS SKJr   S SKrS)S jrS r\	R$                  R'                  \SS9\	R$                  R)                  SS/5      S	 5       5       rS
 rS rS r\	R$                  R'                  \SL SS9S 5       rS V s/ s H  n SU -   PM
     sn r\R6                  S:  a  \S V s/ s H  n SU -   PM
     sn -  r/ SQrS V s/ s H  n SU -   PM
     sn r\R6                  S:  a  \S V s/ s H  n SU -   PM
     sn -  rS r\R6                  S:  a  / rOS/rS r / SQr!\R6                  S:  a  \!/ SQ-  r!S r"S r#\	R$                  RI                  \RJ                  " S5      S;  SS9S  5       r&S! r'\	R$                  RQ                  S"5      S# 5       r)S$ r*S% r+S&\,4S' jr-S( r.g! \ a    Sr GNf = fs  sn f s  sn f s  sn f s  sn f )*    N)IS_WASMc                    Uc  U R                   n0 n[        U 5       Hl  nUS:X  a  M  [        X5      n[        US5      (       d  M)  [        US5      (       d  M<  UR                  U:w  d  MN  UR                  S-   UR                   -   X#'   Mn     U$ )zEReturns a mapping of all objects with the wrong __module__ attribute.core
__module____name__.)r   dirgetattrhasattrr   )modulemodule_nameresultsnameitems        Y/var/www/html/ai-backend/venv/lib/python3.13/site-packages/numpy/tests/test_public_api.py	check_dirr      s}    ooGF6>v$D,''GD*,E,EOO{2 OOc1DMMAGM  N    c                  8    SS0n [        [        5      nX:X  d   eg )Nrecarrayznumpy.rec.recarray)r   np)	allowlistbad_resultss     r   test_numpy_namespacer   &   s*     	(I B-K ###r   zcan't start subprocess)reasonr   testingc                     [         R                  SSU -   4n[        R                  " U5      nU(       a   eU [	        [
        5      ;   d   eg)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   sD     >>4!7$!>
?C$$S)F: 3r7??r   c                  ~    [        [        [        5      5      [        [        [        [        5      5      5      :X  d   eg)zSAssert that output of dir has only one "testing/tester"
attribute without duplicateN)lenr	   r   set r   r   test_dir_testingr(   H   s'     s2w<3s3r7|,,,,r   c                  F    [        [        R                  5      n U 0 :X  d   eg N)r   r   linalgr   s    r   test_numpy_linalgr-   N   s    BII&K"r   c                  F    [        [        R                  5      n U 0 :X  d   eg r*   )r   r   fftr,   s    r   test_numpy_fftr0   S   s    BFF#K"r   z#ctypes not available in this pythonc                      [         R                  " [        R                  R                  R
                  5      n [        U SS 5      nUb   S5       eg )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   sG     ;;rxx11::;D)40A9 5 4 59r   ) 	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numpy.)      )	distutilszdistutils.cpuinfozdistutils.exec_commandzdistutils.misc_utilzdistutils.logzdistutils.system_info)
numpy.charznumpy.emath	numpy.rec))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.testutilsmatlib	matrixlibzmatrixlib.defmatrixzpolynomial.polyutilszrandom.mtrandzrandom.bit_generatorztesting.print_coercion_tables)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                     SU ;  =(       aA    SU ;  =(       a5    SU ;  =(       a)    U [         ;  =(       a    U [        ;  =(       a	    U [        ;  $ )z%Check if this needs to be considered.z._z.testsz.setup)PUBLIC_MODULESPUBLIC_ALIASED_MODULESPRIVATE_BUT_PRESENT_MODULESr   s    r   is_unexpectedrT     sT     	D 	4XT1 	4hd6J 	4&	4..	4 33	r   znumpy.distutils.msvc9compilerc                     / n [         R                  " [        R                  [        R                  S-   SS9 H5  u  pn[        U5      (       d  M  U[        ;  d  M$  U R                  U5        M7     U (       a  [        SU  35      eg)zp
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   rT   	SKIP_LISTappendAssertionError)modnames_modnameispkgs       r   test_all_modules_are_expectedrc     sy     H$22:<++:K;?AE !!gY&> OOG$A 9(DEE 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                      S n U " S5      n[          H  nUR                  U " U5      5        M     U(       a  [        SU 35      eg)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[         R                  " U 5      n[        US5      (       a  UR                  nO[	        U5      nU H|  nUR                  S5      (       a  M  U S-   U-   n[        [        X$5      [        R                  5      (       d  MM  [        U5      (       d  M_  U[        ;  d  Mk  UR                  U5        M~     U$ )N__all__r`   r   )	importlibimport_moduler   rf   r	   
startswith
isinstancer
   types
ModuleTyperT   SKIP_LIST_2r]   )mod_namemembersr   objnamesobjnamefullobjnames         r   find_unexpected_members@test_all_modules_are_expected_2.<locals>.find_unexpected_membersa  s    ((269%%~~H6{HG%%c**&nw6gf68H8HII$[11&k9#NN;7   r   numpyz3Found unexpected object(s) that look like modules: N)rP   extendr^   )rs   unexpected_membersra   s      r   test_all_modules_are_expected_2rx   H  sY    2$ 19!!!"9'"BC "  ));(<> ? 	? r   c                  v   S n / n[          H#  nU " U5      (       a  M  UR                  U5        M%     U(       a  [        SU 35      e[         H  n [	        U5        M     U(       a  [        SU 35      e[        R                  " SS9 n[        R                  " S[        S9  [        R                  " S[        S9  [         H#  nU " U5      (       a  M  UR                  U5        M%     SSS5        U(       a  [        S	U 35      eg! [
         a    UR                  U5         M  f = f! , (       d  f       NF= f)
z
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                 ^     [         R                  " U 5        g! [        [        4 a     gf = f)NFT)rg   rh   ImportErrorAttributeError)r   s    r   check_importable-test_api_importable.<locals>.check_importable  s3    	##K0  ^, 		s    ,,z3Modules in the public API that cannot be imported: z/Modules in the public API that were not found: T)recordalways)categoryNzNModules that are not really public but looked public and can not be imported: )rP   r]   r^   rQ   evalr|   warningscatch_warningsfilterwarningsDeprecationWarningImportWarningrR   )r}   module_namesr   ws       r   test_api_importabler   |  s6    L%,,, &  **69 : 	: .	- .  ''3n6 7 	7 
	 	 	-3EF=A6K#K00##K0 7 
.  @ ,~/ 0 	0   	-,	- 
.	-s%   D
AD*D*D'&D'*
D8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                     [         R                  " S5      [        R                  ;   n [        R
                  R                  5       nUR                  SS9n[        U5      S:X  a  U (       a  Sn[        U5      Seg [        S U 5       5      nUR                  S	:X  a  gUR                  5       nS
UR                   S3nU[        L d   U5       eg! [         a    U (       a  Sn[        U5      Se gf = f)zl
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   H   #    U  H  oR                   S :X  d  M  Uv   M     g7f)ru   NrS   ).0eps     r   	<genexpr>-test_array_api_entry_point.<locals>.<genexpr>  s     <vG);""vs   "	"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   rg   metadataentry_pointsselectr%   r^   nextStopIterationvalueloadru   )numpy_in_sitepackagesepsxp_epsmsgr   xps         r   test_array_api_entry_pointr     s      &..y9R[[H



)
)
+CZZkZ*F
6{a 9C %4/<v<< 
xx$$ 		B
#BHH: .9 	9  ;;'   9C %4/	s   ;C C10C1c                      S n S nU " [         R                  5      nU" U5      nU " [         R                  " 5       5      nU" U5      nX#:X  d   SUR                  U5       35       eg)z|
Checks if `dir(np)` and `np.__all__` are consistent and return
the same content, excluding exceptions and private members.
c                 `    U  Vs1 s H  oR                  S5      (       a  M  UiM     sn$ s  snf )Nr`   )ri   )
member_setms     r   _remove_private_membersFtest_main_namespace_all_dir_coherence.<locals>._remove_private_members  s#    %?:a\\#->:???s   ++c                 &    U R                  S15      $ )Nbool)
difference)r   s    r   _remove_exceptionsAtest_main_namespace_all_dir_coherence.<locals>._remove_exceptions  s    $$&
  	r   zMembers that break symmetry: N)r   rf   __dir__symmetric_difference)r   r   all_membersdir_memberss       r   %test_main_namespace_all_dir_coherencer     sm    
@
 *"**5K$[1K)"**,7K$[1K% '++K8
9	;%r   z:ignore:numpy.core(\.\w+)? is deprecated:DeprecationWarningc                  2   SSK Jn   [        [        R                  5       H  nUR                  S5      (       d  US;   d  SU 3[        ;   a  M.  [        [        R                  U5      n[        R                  " U5      (       a  UR                  (       ap  UR                  R                  bY  UnUn[        U5       HD  nUR                  S5      (       a  M  [        X55      n[        SU 3U/S9nU[        Xu5      L a  MD   e   M  U[        X5      L a  M   e   g)	zd
Check that all "semi-public" members of `numpy._core` are also accessible
from `numpy.core` shims.
r   Nr`   )testsrC   rF   __znumpy.core.)fromlist)
numpy.corer   r	   r   r5   ri   rQ   r
   inspectismodule__spec__origin
__import__)r   member_namemember	submodulesubmodule_namesubmodule_member_namesubmodule_membercore_submodules           r   test_core_shims_coherencer     s    288} ""3''22}%)??;/ V$$FOO$:$:$FI(N),Y%(33D99#*9#L !+!.!1234"
 (7",    *8  WT7777O %r   c                  f   SSK Jn   SSKJn  SSKJn  [        1n[        5       n0 n/ n[        /n[        U5      S:  Ga  UR                  5       n[        U5       GH  n	[        X5      n
[        R                  " U
5      (       ae  SU
R                  ;   aU  U	R                  S5      (       d?  SU
R                  ;  a/  U	S;  a)  X;  a$  UR!                  U
5        UR#                  U
5        M  [        R$                  " U
5      (       d"  ['        X[        R(                  45      (       d  M  X;   a  U
R                  S	;   a  UR                  S:X  a  M  U
R                  S
:X  a#  UR                  R                  S5      (       a  GM&  U
R                  S;   a  UR                  S:X  a  GMI  UR                  S:X  a  GM\  UR!                  U
R                  UR                  XZ   45        GM  UR#                  U
5        UR                  XZ'   GM     [        U5      S:  a  GM  AAA[        U5      S:X  d   U5       eg)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   )Callable)Any)_ArrayFunctionDispatcherru   r`   numpy._core)r>   r@   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.stringsrJ   N)collections.abcr   rD   r   numpy._core._multiarray_umathr   r   r&   r%   popr	   r
   r   r   r   ri   r]   r   
isfunctionrj   ufunc)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 ?A )+DM
m
q
 ""$v;KV1F   ((6??***3//V__4#EE-$$V,##F+ ""6**6#BCC.  , & 72  :5223EFF   +  !//_<  ,6  )//19; &))&17=,4a '	 m
q
 l 	?,D#$)?+??)r   c                     [         /n [         1n[        5       n/ n[        U 5      S:  Ga  U R                  5       n[	        U5       GH  n[        XE5      n[        R                  " U5      (       ae  SUR                  ;   aU  UR                  S5      (       d?  SUR                  ;  a/  US;  a)  Xa;  a$  U R                  U5        UR                  U5        M  [        R                  " U5      (       a  M  [        US5      (       d  M  UR                  R                  S5      (       a  M  UR                  UR                  :w  d  M  Xb;  d  GM  UR                  S;   a  UR                  S:X  a  GM(  UR                  S	:X  a  UR                  S:X  d   UR                  S
:X  a  UR                  S:X  a  GMk  UR                  S;   a  UR                  S:X  a  GM  UR                  S;   a  GM  UR                  UR                  UR                  UR                  S.5        UR                  U5        GM     [        U 5      S:  a  GM  U(       a  [        U5      S:X  d   U5       eg g )Nr   ru   r`   r   )charr   r>   r@   lapack_litemrecordsr   r   rA   rD   mtrandbit_generatorr   r   r   r   r   rK   )c_long
c_longlongznumpy.ctypeslib)	BitGenerator	GeneratorMT19937PCG64	PCG64DXSMPhiloxRandomStateSFC64SeedSequence)Funcactualexpected)r   r&   r%   r   r	   r
   r   r   r   ri   r]   r   r   r   r   r   r   incorrect_entriesr   r   r   s          r   test___module___attributer	    s   DMdO
m
q
 ""$v;KV1F   ((6??***3//V__4 $ 
 -$$V,##F+$$V,,
++OO..s33!!V__4/ ?? '  oo8 __
2v'7Q__0V__5S OO'??OO'88 ?? '  !(( &"("3"3$*OO "%%f-y ' m
q
 @ $%*=,==* r   returnc                    U R                   nU R                  nU R                  nX!R                  S5      S   :X  d   e[        R
                  U   n[        R                  " [        UR                  S5      U5      nXPL =(       dU    [        US5      =(       aB    [        U S5      =(       a/    UR                  U R                  :H  =(       a    UR                   U:H  $ )Nr   __get____self__)
__qualname__r   r   splitr   modules	functoolsreducer
   r   )objqualnamer   r   r   
actual_objs         r   "_check_correct_qualname_and_moduler    s    H<<D..K>>#&r****[[%F!!'8>>#+>GJ 	
 J	* 0wsJ/G 0!!S^^30##x/r   c                     [         /n [         1n[        5       n/ n[        U 5      S:  Ga  U R                  5       n[	        U5       GHa  n[        XE5      n[        R                  " U5      (       ae  SUR                  ;   aU  UR                  S5      (       d?  US;  a9  SUR                  ;  a)  Xa;  a$  U R                  U5        UR                  U5        M  [        R                  " U5      (       a  M  [        US5      (       d  M  UR                  R                  S5      (       a  M  UR                  S5      (       a  M  [        U5      (       a  GM  Xb;  d  GM  UR                  UR                   SU 3UR                   SUR                   3S.5        UR                  U5        GMd     [        U 5      S:  a  GM  U(       a  [        U5      S:X  d   U5       eg g )	Nr   ru   r`   >   r   rD   r   r   :)found_at
advertises)r   r&   r%   r   r	   r
   r   r   r   ri   r]   r   r   r  r   r  r  s          r   *test___qualname___and___module___attributer    s    DMdO
m
q
 ""$v;KV1F   ((6??***3//#66V__4-$$V,##F+$$V,,
++OO..s33**3//6v>>/!(('-&7q$F)/):):(;1V=P=P<Q&R "%%f-7 ' m
q
 > $%*=,==* r   r*   )/r  rg   r   rY   r   r   r   rk   r   pytestru   r   numpy.testingr   r3   r{   r   r   markskipifparametrizer#   r(   r-   r0   r:   rP   version_inforQ   rR   rT   r\   rc   rm   rx   r   xfailget_config_varr   r   r   r   r   r	  r   r  r  )ss   0r   <module>r&     s        
       !
$ G$<=)- . >*-

 FdN@  B5B5(!) ! !)1(Q, !) !D g
	
1 
	 	N *6 * *6x!| *6 * V g8
:$8
1 8
:$ :z wI01IF, g  K1?h-0` Z(>	8  ''T2 A.8.8br@jG>Tt &)>U  Fv!F	&*X:$s)   G 3G%G*6G/G4G"!G"