
    G/Ph-Y                        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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        [/var/www/html/test/jupyter/venv/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                  H    ddd} t          t                    }|| k    sJ d S )Nznumpy.rec.recarrayznumpy.__config__.show)recarrayshow_config)r   np)	allowlistbad_resultss     r   test_numpy_namespacer   %   s<     ). 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_fftr1   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>rB   n   s(     ! ! !1(Q, ! ! !r   ) 	ctypeslibdtypes
exceptionsf2pyr0   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   rB   rB      s)     	 	 	1	 	 	r   )	distutilszdistutils.cpuinfozdistutils.exec_commandzdistutils.misc_utilzdistutils.logzdistutils.system_info)
numpy.charznumpy.emathz	numpy.recc                     g | ]}d |z   S r=   r(   r?   s     r   rB   rB      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   rB   rB      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   r8   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   )testsrK   r>   __znumpy.core.)fromlist)
numpy.corer   r	   r   r6   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   znumpy._core)rF   rH   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_equalznumpy.stringsrR   N)rL   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   r+   )*r   r   r    rc   ru   rq   r   r   r~   r   numpy.testingr   pytestr4   r   r   r   markskipifparametrizer$   r)   r.   r1   r;   rZ   version_infor[   r\   r^   rf   r   rm   rw   r   r   xfailget_config_varr   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@ p@ p@s   9 AA