o
    ðT·jl  ã                   @   s"  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zd dlZW n eyG   dZY nw d@dd„Zdd„ Zejjedd�ej d	d
g¡dd„ ƒƒZdd„ Zdd„ Zdd„ Zejjedu dd�dd„ ƒZdd„ dD ƒZejdk r”edd„ dD ƒ7 Zg d¢Zdd„ dD ƒZejdk r­edd„ d D ƒ7 Zd!d"„ Zejdk rºd#gZng Zej  d$¡d%d&„ ƒZ!g d'¢Z"ejdk rÕe"g d(¢7 Z"d)d*„ Z#d+d,„ Z$ejj%e &d-¡d.vd/d�d0d1„ ƒZ'd2d3„ Z(ej  d4¡d5d6„ ƒZ)d7d8„ Z*d9d:„ Z+d;e,fd<d=„Z-d>d?„ Z.dS )Aé    N)ÚIS_WASMc                 C   sj   |du r| j }i }t| ƒD ]%}|dkrqt| |ƒ}t|dƒr2t|dƒr2|j|kr2|jd |j  ||< q|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Úitem© r   ú^/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/numpy/tests/test_public_api.pyÚ	check_dir   s   

€r   c                  C   s    ddi} t tƒ}|| ksJ ‚d S )NÚrecarrayznumpy.rec.recarray)r   Únp)Ú	allowlistÚbad_resultsr   r   r   Útest_numpy_namespace&   s   ÿr   zcan't start subprocess)Úreasonr   Útestingc                 C   s6   t jdd|  f}t |¡}|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Úresultr   r   r   Útest_import_lazy_import1   s   
r   c                   C   s$   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   Úsetr   r   r   r   Útest_dir_testingH   s   $r"   c                  C   ó   t tjƒ} | i ksJ ‚d S ©N)r   r   Úlinalg©r   r   r   r   Útest_numpy_linalgN   ó   
r'   c                  C   r#   r$   )r   r   Úfftr&   r   r   r   Útest_numpy_fftS   r(   r*   z#ctypes not available in this pythonc                  C   s0   t  tjjj¡} t| dd ƒ}|d u s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Úfr   r   r   Útest_NPY_NO_EXPORTX   s   r3   c                 C   ó   g | ]}d | ‘qS ©únumpy.r   ©Ú.0Úsr   r   r   Ú
<listcomp>n   ó    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                 C   r4   r5   r   r7   r   r   r   r:   ‘   ó    ÿ)Ú	distutilszdistutils.cpuinfozdistutils.exec_commandzdistutils.misc_utilzdistutils.logzdistutils.system_info)ú
numpy.charznumpy.emathú	numpy.recc                 C   r4   r5   r   r7   r   r   r   r:   ¥   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                 C   r4   r5   r   r7   r   r   r   r:   Ô   rI   )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                 C   sD   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   r   r   r   Úis_unexpected  s   rU   znumpy.distutils.msvc9compilerz'ignore:.*np.compat.*:DeprecationWarningc                  C   sX   g } t jtjtjd dd�D ]\}}}t|ƒr |tvr |  |¡ q| 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   rU   Ú	SKIP_LISTÚappendÚAssertionError)ÚmodnamesÚ_ÚmodnameÚispkgr   r   r   Útest_all_modules_are_expected)  s   þ
€ÿrc   )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                  C   s>   dd„ } | dƒ}t D ]	}| | |ƒ¡ q
|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                 S   sx   g }t  | ¡}t|dƒr|j}nt|ƒ}|D ]#}| d¡s9| d | }tt||ƒtj	ƒr9t
|ƒr9|tvr9| |¡ q|S )NÚ__all__r`   r   )Ú	importlibÚimport_moduler	   rd   r   Ú
startswithÚ
isinstancer   ÚtypesÚ
ModuleTyperU   ÚSKIP_LIST_2r]   )Úmod_nameÚmembersr
   ÚobjnamesÚobjnameÚfullobjnamer   r   r   Úfind_unexpected_membersn  s   



€z@test_all_modules_are_expected_2.<locals>.find_unexpected_membersÚnumpyz5Found unexpected object(s) that look like modules: {}N)rQ   Úextendr^   Úformat)rq   Úunexpected_membersra   r   r   r   Útest_all_modules_are_expected_2U  s   ÿÿrv   c               	   C   sø   dd„ } g }t D ]}| |ƒs| |¡ q|rtd |¡ƒ‚tD ]}zt|ƒ W q ty5   | |¡ Y qw |r?td |¡ƒ‚tjdd��$}tj	dt
d� tj	dtd� tD ]}| |ƒsa| |¡ qVW d	  ƒ n1 slw   Y  |rzt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              	   S   s*   zt  | ¡ W dS  ttfy   Y dS w )NFT)re   rf   ÚImportErrorÚAttributeError)r   r   r   r   Úcheck_importable‘  s   ýÿz-test_api_importable.<locals>.check_importablez5Modules 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: {})rQ   r]   r^   rt   rR   Úevalrx   ÚwarningsÚcatch_warningsÚfilterwarningsÚDeprecationWarningÚImportWarningrS   )ry   Úmodule_namesr   Úwr   r   r   Útest_api_importable‰  sD   
€ÿÿÿ
€þýþÿr…   ÚPy_DEBUG)Nr   Ú0z£NumPy 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                  C   sâ   t  d¡tjv } tj ¡ }z|jdd�}W n ty$   | 	dg ¡}Y nw t
|ƒdkr6| r4d}t|ƒd‚dS ztdd„ |D ƒƒ}W n tyT   | rQd	}t|ƒd‚Y dS w |jd
kr\dS | ¡ }d|j› d�}|tu soJ |ƒ‚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                 s   s   � | ]
}|j d kr|V  qdS )rr   NrT   )r8   Úepr   r   r   Ú	<genexpr>Û  s   € z-test_array_api_entry_point.<locals>.<genexpr>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   r0   re   ÚmetadataÚentry_pointsÚselectrx   Úgetr    r^   ÚnextÚStopIterationÚvalueÚloadrr   )Únumpy_in_sitepackagesÚepsÚxp_epsÚmsgr‹   Úxpr   r   r   Útest_array_api_entry_point¹  s4   
û

ü
ÿrœ   c                  C   sV   dd„ } dd„ }| t jƒ}||ƒ}| t  ¡ ƒ}||ƒ}||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                 S   s   dd„ | D ƒS )Nc                 S   s   h | ]	}|  d ¡s|’qS )r`   )rg   )r8   Úmr   r   r   Ú	<setcomp>ø  s    zYtest_main_namespace_all_dir_coherence.<locals>._remove_private_members.<locals>.<setcomp>r   ©Ú
member_setr   r   r   Ú_remove_private_members÷  s   zFtest_main_namespace_all_dir_coherence.<locals>._remove_private_membersc                 S   s   |   dh¡S )NÚbool)Ú
differencerŸ   r   r   r   Ú_remove_exceptionsú  s   ÿzAtest_main_namespace_all_dir_coherence.<locals>._remove_exceptionszMembers that break symmetry: N)r   rd   Ú__dir__Úsymmetric_difference)r¡   r¤   Úall_membersÚdir_membersr   r   r   Ú%test_main_namespace_all_dir_coherenceò  s   

ÿÿr©   z:ignore:numpy.core(\.\w+)? is deprecated:DeprecationWarningc                  C   s¾   ddl m}  ttjƒD ]Q}| d¡s|dv sd|› �tv rqttj|ƒ}t 	|¡rS|}|}t|ƒD ] }| d¡r9q1t||ƒ}t
d|› �|gd�}|t||ƒu sQJ ‚q1q|t| |ƒu s\J ‚qdS )	zp
    Check that all "semi-public" members of `numpy._core` are also accessible
    from `numpy.core` shims.
    r   Nr`   )ÚtestsrD   r6   Ú__znumpy.core.)Úfromlist)Ú
numpy.corer   r   r   r.   rg   rR   r   ÚinspectÚismoduleÚ
__import__)r   Úmember_nameÚmemberÚ	submoduleÚsubmodule_nameÚsubmodule_member_nameÚsubmodule_memberÚcore_submoduler   r   r   Útest_core_shims_coherence  s2   ÿ


þÿõÞr¸   c                  C   sŒ  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 |¡r`d|jv r`| d¡s`d|jvr`|dvr`||vr`| |¡ | |¡ q2t |¡smt||t	jfƒr°||v r¦|jdv r||jdkr|q2|jd	krˆ|j d
¡rˆq2|jdv r“|jdkr“q2|jdkr™q2|
 |j|j|	| f¡ q2| |¡ |j|	|< q2t|ƒdks*~~~	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)Ú_ArrayFunctionDispatcherrr   r`   únumpy._core)r?   rA   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.stringsrK   N)rE   r¹   rº   r»   r¼   r½   r¾   Únumpy._core._multiarray_umathr¿   r   r!   Údictr    Úpopr   r   r®   r¯   r   rg   r]   rÔ   Ú
isfunctionrh   Úufunc)r¹   rº   r»   r¼   r½   r¾   Údispatched_functionÚvisited_modulesÚvisited_functionsÚfunctions_original_pathsÚduplicated_functionsÚmodules_queuer
   r±   r²   r   r   r   Útest_functions_single_location:  sd    
ÿ
ÿ

ÿþ



ÿ


þÿ

€¬Vrç   c                  C   s`  t g} t h}tƒ }g }t| ƒdkr |  ¡ }t|ƒD ]€}t||ƒ}t |¡rGd|jv rG| 	d¡sGd|jvrG|dvrG||vrG|  
|¡ | |¡ qt |¡s™t|dƒr™|j 	d¡s™|j|jkr™||vr™|jdv rl|jdkrlq|jd	krv|jdks€|jd
kr�|jdkr�q|jdv r‡q| 
t|j|j|jd�¡ | |¡ qt| ƒdks|r¬t|ƒdks®J |ƒ‚d S d S )Nr   rr   r`   rÀ   )Úcharr   r<   r?   rA   Úlapack_liteÚmrecordsr   rª   rB   rE   ÚmtrandÚbit_generatorr   rÓ   rÛ   r   rz   rL   )	ÚBitGeneratorÚ	GeneratorÚMT19937ÚPCG64Ú	PCG64DXSMÚPhiloxÚRandomStateÚSFC64ÚSeedSequence)ÚFuncÚactualÚexpected)r   r!   r    rÞ   r   r   r®   r¯   r   rg   r]   rÔ   r	   r   rÝ   ©ræ   râ   rã   Úincorrect_entriesr
   r±   r²   r   r   r   Útest___module___attribute­  s`   
ÿ
ÿ

ÿþ
ý


ýÿ
€É9ÿrû   Úreturnc                 C   sb   | j }| j}| j}|| d¡d ksJ ‚tj| }t t| d¡|¡}|| u p0| 	d¡o0|j |kS )Nr   éÿÿÿÿznumpy.random)
Ú__qualname__r   r   Úsplitr   ÚmodulesÚ	functoolsÚreducer   rg   )ÚobjÚqualnamer   r   r
   Ú
actual_objr   r   r   Ú_check___qualname__ð  s   

ûr  c                  C   s  t g} t h}tƒ }g }t| ƒdkr{|  ¡ }t|ƒD ][}t||ƒ}t |¡rGd|jv rG| 	d¡sG|dvrGd|jvrG||vrG|  
|¡ | |¡ qt |¡stt|dƒrt|j 	d¡st| 	d¡stt|ƒst||vrt| 
t|j|jd�¡ | |¡ qt| ƒdks|r‡t|ƒdks‰J |ƒ‚d S d S )Nr   rr   r`   )r?   rA   rª   r   rE   rì   r<   ré   rÀ   r   )r÷   rø   )r   r!   r    rÞ   r   r   r®   r¯   r   rg   r]   rÔ   r	   r  rÝ   rþ   rù   r   r   r   Útest___qualname___attribute  sR   
ÿ
ÿ

ÿþ
ýüûÿÿ
€á!ÿr  r$   )/r  r   r�   r   rY   ri   re   r®   r~   rr   r   Únumpy.testingr   Úpytestr,   rw   r   r   ÚmarkÚskipifÚparametrizer   r"   r'   r*   r3   rQ   Úversion_inforR   rS   rU   r\   r€   rc   rk   rv   r…   ÚxfailÚget_config_varrœ   r©   r¸   rç   rû   r¢   r  r  r   r   r   r   Ú<module>   s„    ÿ
ÿ

"ÿ
.ÿ=



40ý
1ÿ
,sC