a
    �¥»aª:  ã                   @   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zd dl	Z	W n e
yj   dZ	Y n0 d%dd„Zdd„ Zej d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g d¢Zdd„ dD ƒZdd„ Zg d¢Zdd„ Zg d ¢Zd!d"„ Zd#d$„ ZdS )&é    Nc                 C   s`   |du r| j }i }t| ƒD ]@}t| |ƒ}t|dƒrt|dƒr|j|kr|jd |j  ||< q|S )zEReturns a mapping of all objects with the wrong __module__ attribute.NÚ
__module__Ú__name__Ú.)r   ÚdirÚgetattrÚhasattrr   )ÚmoduleÚmodule_nameÚresultsÚnameÚitem© r   úU/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/numpy/tests/test_public_api.pyÚ	check_dir   s    
ÿr   c                  C   s~   dddddddddd	d
dddddddddddœ} t jdk rbdddddddddœ}t| fi |¤Ž}n| }ttƒ}||kszJ ‚d S )Nz,numpy.testing._private.nosetester.NoseTesterz.numpy.core._multiarray_umath._add_newdoc_ufuncz*numpy.core._multiarray_umath.add_docstringz#numpy.core.function_base.add_newdocznumpy.lib.utils.byte_boundsz/numpy.core._multiarray_umath.compare_chararraysznumpy.lib.utils.deprecatez"numpy.lib.utils.deprecate_with_docznumpy.lib.function_base.dispz2numpy.core._multiarray_umath._fastCopyAndTransposez#numpy.lib.shape_base.get_array_wrapznumpy.lib.utils.get_includeznumpy.lib.npyio.mafromtxtznumpy.lib.npyio.ndfromtxtznumpy.lib.npyio.recfromcsvznumpy.lib.npyio.recfromtxtznumpy.lib.utils.safe_evalz)numpy.core.arrayprint.set_string_functionznumpy.__config__.showznumpy.lib.utils.who)ÚTesterZ_add_newdoc_ufuncZadd_docstringZ
add_newdocZadd_newdoc_ufuncZbyte_boundsZcompare_chararraysZ	deprecateZdeprecate_with_docZdispZfastCopyAndTransposeZget_array_wrapZget_includeZ	mafromtxtZ	ndfromtxtZ
recfromcsvZ
recfromtxtZ	safe_evalZset_string_functionZshow_configZwho)é   é   zbuiltins.boolzbuiltins.complexzbuiltins.floatzbuiltins.intzbuiltins.objectzbuiltins.str)ÚboolÚcomplexÚfloatÚintÚlongÚobjectÚstrÚunicode)ÚsysÚversion_infoÚdictr   Únp)ZundocumentedÚbuiltinsZ	allowlistÚbad_resultsr   r   r   Útest_numpy_namespace   sH    ë
ø
r!   r   Útestingr   c                 C   s6   t jdd|  f}t |¡}|r"J ‚| ttƒv s2J ‚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)r   Ú
executableÚ
subprocessÚcheck_outputr   r   )r   ZexeÚresultr   r   r   Útest_import_lazy_importO   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_testinge   s    r*   c                  C   s   t tjƒ} | i ksJ ‚d S ©N)r   r   Úlinalg©r    r   r   r   Útest_numpy_linalgk   s    
r.   c                  C   s   t tjƒ} | i ksJ ‚d S r+   )r   r   Úfftr-   r   r   r   Útest_numpy_fftp   s    
r0   z#ctypes not available in this python)Úreasonc                  C   s0   t  tjjj¡} t| dd ƒ}|d u s,J dƒ‚d S )NZtest_not_exportedzG'test_not_exported' is mistakenly exported, NPY_NO_EXPORT does not work)ÚctypesÚCDLLr   ÚcoreZ_multiarray_testsÚ__file__r   )ÚcdllÚfr   r   r   Útest_NPY_NO_EXPORTu   s    r8   c                 C   s   g | ]}d | ‘qS ©znumpy.r   ©Ú.0Úsr   r   r   Ú
<listcomp>‹   ó    r=   )#Z	ctypeslibÚ	distutilszdistutils.cpuinfozdistutils.exec_commandzdistutils.misc_utilzdistutils.logzdistutils.system_infoÚdoczdoc.constantsz
doc.ufuncsZf2pyr/   Úlibz
lib.formatz
lib.mixinszlib.recfunctionszlib.scimathzlib.stride_tricksr,   Úmaz	ma.extraszma.mrecordsZmatlibZ
polynomialzpolynomial.chebyshevzpolynomial.hermitezpolynomial.hermite_ezpolynomial.laguerrezpolynomial.legendrezpolynomial.polynomialÚrandomr"   Útypingztyping.mypy_pluginÚversion)z
numpy.charznumpy.emathz	numpy.recc                 C   s   g | ]}d | ‘qS r9   r   r:   r   r   r   r=   ¹   r>   )sÚcompatzcompat.py3kZconftestr4   zcore.arrayprintzcore.defchararrayzcore.einsumfunczcore.fromnumericzcore.function_basezcore.getlimitszcore.macharzcore.memmapzcore.multiarrayzcore.numericzcore.numerictypeszcore.overrideszcore.recordszcore.shape_basez
core.umathzcore.umath_testsz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.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.unixccompilerZdualzf2py.auxfuncszf2py.capi_mapszf2py.cb_ruleszf2py.cfuncszf2py.common_ruleszf2py.crackfortranzf2py.diagnosezf2py.f2py2ezf2py.f2py_testingzf2py.f90mod_ruleszf2py.func2subrz
f2py.ruleszf2py.use_rulesz
fft.helperzlib.arraypadzlib.arraysetopszlib.arrayteratorzlib.function_basezlib.histogramszlib.index_trickszlib.nanfunctionsz	lib.npyiozlib.polynomialzlib.shape_basezlib.twodim_basezlib.type_checkzlib.ufunclikezlib.user_arrayz	lib.utilszlinalg.lapack_litezlinalg.linalgzma.benchzma.corezma.testutilszma.timer_comparisonZ	matrixlibzmatrixlib.defmatrixzpolynomial.polyutilszrandom.mtrandzrandom.bit_generatorztesting.print_coercion_tablesztesting.utilsc                 C   sD   d| v sd| v sd| v rdS | t v r(dS | tv r4d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_unexpected0  s    rJ   )
znumpy.core.code_generatorsz!numpy.core.code_generators.genapiz)numpy.core.code_generators.generate_umathz+numpy.core.code_generators.ufunc_docstringsz-numpy.core.code_generators.generate_numpy_apiz-numpy.core.code_generators.generate_ufunc_apiz$numpy.core.code_generators.numpy_apiznumpy.core.cversionsznumpy.core.generate_numpy_apiznumpy.distutils.msvc9compilerc                  C   sX   g } t jtjtjd dd�D ]$\}}}t|ƒr|tvr|  |¡ q| rTt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   rJ   Ú	SKIP_LISTÚappendÚAssertionError)ÚmodnamesÚ_ÚmodnameÚispkgr   r   r   Útest_all_modules_are_expectedQ  s    þrX   )z
numpy.mathznumpy.distutils.log.sysznumpy.doc.constants.reznumpy.doc.constants.textwrapznumpy.lib.emathznumpy.lib.mathznumpy.matlib.charznumpy.matlib.recznumpy.matlib.emathznumpy.matlib.mathznumpy.matlib.linalgznumpy.matlib.fftznumpy.matlib.randomznumpy.matlib.ctypeslibznumpy.matlib.mac                  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 ]F}| d¡s,| d | }tt||ƒtj	ƒr,t
|ƒr,|tvr,| |¡ q,|S )NÚ__all__rU   r   )Ú	importlibÚimport_moduler   rY   r   Ú
startswithÚ
isinstancer   ÚtypesÚ
ModuleTyperJ   ÚSKIP_LIST_2rR   )Úmod_nameÚmembersr   ZobjnamesZobjnameZfullobjnamer   r   r   Úfind_unexpected_members“  s    


z@test_all_modules_are_expected_2.<locals>.find_unexpected_membersÚnumpyz5Found unexpected object(s) that look like modules: {}N)rG   ÚextendrS   Úformat)rc   Zunexpected_membersrV   r   r   r   Útest_all_modules_are_expected_2z  s    ÿrg   c               	   C   sú   dd„ } g }t D ]}| |ƒs| |¡ q|r:td |¡ƒ‚tD ].}zt|ƒ W q> tyj   | |¡ Y q>0 q>|r€td |¡ƒ‚tjdd��H}tj	dt
d� tj	dtd� tD ]}| |ƒs®| |¡ q®W d	  ƒ n1 sÚ0    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              	   S   s,   zt  | ¡ W n ttfy&   Y dS 0 dS )NFT)rZ   r[   Ú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: {})rG   rR   rS   rf   rH   Úevalri   ÚwarningsÚcatch_warningsÚfilterwarningsÚDeprecationWarningÚImportWarningrI   )rj   Zmodule_namesr	   Úwr   r   r   Útest_api_importable®  s8    ÿÿ*þru   )N)r   r$   rN   r^   rZ   ro   rd   r   Zpytestr2   rh   r   r!   ÚmarkZparametrizer'   r*   r.   r0   Zskipifr8   rG   rH   rI   rJ   rQ   rX   r`   rg   ru   r   r   r   r   Ú<module>   s@   

0
ÿ
'w4