
    uhhl                     n   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
Zd dlm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g ZndgZ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        R/var/www/histauto/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                  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   ))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_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                 P    d| vo"d| vod| vo| t           vo| t          vo| t          vS )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_unexpectedr]     sT     	D 	4XT1 	4hd6J 	4&	4..	4 33	r   znumpy.distutils.msvc9compilerc                      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_expectedrl     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__ri   r   )	importlibimport_moduler   ro   r	   
startswith
isinstancer
   types
ModuleTyper]   SKIP_LIST_2rf   )mod_namemembersr   objnamesobjnamefullobjnames         r   find_unexpected_membersz@test_all_modules_are_expected_2.<locals>.find_unexpected_membersa  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   numpyz3Found unexpected object(s) that look like modules: N)rY   extendrg   )r|   unexpected_membersrj   s      r   test_all_modules_are_expected_2r   H  s    2  $ 1099! D D!!"9"9'"B"BCCCC ? >);> > ? ? 	?? ?r   c                  v   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)rp   rq   ImportErrorAttributeError)r   s    r   check_importablez-test_api_importable.<locals>.check_importable  sI    	#K0000^, 	 	 	55	 ts    ,,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: )rY   rf   rg   rZ   evalr   warningscatch_warningsfilterwarningsDeprecationWarningImportWarningr[   )r   module_namesr   ws       r   test_api_importabler   |  s      L% - -,, 	-,,, : 9*69 9 : : 	: . - -	- 	- 	- 	-,,,,,	-  7 6'36 6 7 7 	7 
	 	-	-	- 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  0 / ,/ / 0 0 	00 0s%   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                     t          j        d          t          j        v } t          j                                        }|                    d          }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   rp   metadataentry_pointsselectr%   rg   nextStopIterationvalueloadr}   )numpy_in_sitepackagesepsxp_epsmsgr   xps         r   test_array_api_entry_pointr     s2     &.y99R[H


)
)
+
+CZZkZ**F
6{{a  	09C %%4/<<v<<<<<     	09C %%4/	 
x$$$ 		B	9BH 	9 	9 	9  ;;;;;;;;s   ?B B;:B;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 )ri   )rr   )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   ro   __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	        |          ry|j
        rr|j
        j        f|}|}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   Nri   )testsrJ   r=   __znumpy.core.)fromlist)
numpy.corer   r	   r   r5   rr   rZ   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     sr    28}} '8 '8 ""3''	222%%%)???;// V$$	8	8$*O$:$FI(N),Y  %(33D99 #*96K#L#L !+2.2234" " "
 (7"$9, ,       WT;7777777O'8 '8r   c                      ddl m}  ddlm} ddlm} t          h}t                      }i }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   )Callable)Any)_ArrayFunctionDispatcherr}   ri   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)collections.abcr   rK   r   numpy._core._multiarray_umathr   r   r&   r%   popr	   r
   r   r   r   rr   rf   r   
isfunctionrs   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;; 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 ]t}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|j        dk    r,|j        dv r7|
                    |j        |j        |j        d           |                    |           vt          |           dk    |rt          |          dk    sJ |            d S d S )Nr   r}   ri   r   )charr   rE   rG   lapack_litemrecordsr   r   rH   rK   mtrandbit_generatorr   r   r   r   r   rR   )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   rr   rf   r   r   r   r   r   r   incorrect_entriesr   r   r   s          r   test___module___attributer    s   DMdO
m

q
 
 ""$$v;; <	. <	.KV[11F  ((9.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 O'???O'888 ? '   !(( &"("3$*O    "%%f---} m

q
 
 @  >$%%***,=***> >**r   returnc                 l   | j         }| j        }| j        }||                    d          d         k    sJ t          j        |         }t          j        t          |                    d          |          }|| u p:t          |d          o*t          | d          o|j        | j        k    o
|j         |k    S )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8>>#&&r*****[%F!'8>>#+>+>GGJc 	
 J	** 0wsJ/G/G 0!S^30#x/r   c                  |   t           g} t           h}t                      }g }t          |           dk    rf|                                 }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          sn|	                    d          sYt          |          sJ||vrF|
                    |j         d| |j         d|j         d           |                    |           /t          |           dk    f|rt          |          dk    sJ |            d S d S )	Nr   r}   ri   >   r   rK   r   r   :)found_at
advertises)r   r&   r%   r   r	   r
   r   r   r   rr   rf   r   r   r  r   r  r  s          r   *test___qualname___and___module___attributer"    s    DMdO
m

q
 
 ""$$v;; 	. 	.KV[11F  ((.6?****3// +#666V_44o--$$V,,,##F++++$V,,.
++. O..s33.  **3//	.
 7v>>. ///!(('-$F$F$F$F)/):&R&RV=P&R&R    "%%f---; m

q
 
 >  >$%%***,=***> >**r   r*   )/r  rp   r   rb   r   r   r   rt   r   pytestr}   r   numpy.testingr   r3   r   r   r   markskipifparametrizer#   r(   r-   r0   r:   rY   version_inforZ   r[   r]   re   rl   rv   r   r   xfailget_config_varr   r   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 * * * V g :$ :$8
:$ :$ :$ :z   wII01IF F F,   g    K1? 1? 1?h-0 -0 -0` IZ((>	8   ' ' 'T  2 A .8 .8 .8br@ r@ r@jG> G> G>Tt    &)> )> )> )> )>s   = AA