B
    G0d:                 @   sR  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yd dl	Z	W n e
k
rl   dZ	Y nX 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kdddd Zdd dD ZdddgZdd dD Zdd Zdd d!d"d#d$d%d&d'd(g
Zd)d* Zd+d,d-d.d/d0d1d2d3d4d5d6d7d8d9gZd:d; Zd<d= ZdS )?    Nc             C   sd   |dkr| j }i }xLt| D ]@}t| |}t|drt|dr|j|kr|jd |j  ||< qW |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   M/var/www/html/venv/lib/python3.7/site-packages/numpy/tests/test_public_api.py	check_dir   s    

r   c              C   sz   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 r^ddddddddd}t| f|}n| }tt}||ksvt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AssertionError)ZundocumentedbuiltinsZ	allowlistbad_resultsr   r   r   test_numpy_namespace   sD    
r"   r   testingr   c             C   s6   t jdd|  f}t|}|r"t| ttks2t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   )r   exeresultr   r   r   test_import_lazy_importO   s    
r)   c               C   s$   t ttt tttks tdS )zWAssert that output of dir has only one "testing/tester"
    attribute without duplicateN)lenr   r   setr   r   r   r   r   test_dir_testinge   s    r,   c              C   s   t tj} | i kstd S )N)r   r   linalgr   )r!   r   r   r   test_numpy_linalgk   s    
r.   c              C   s   t tj} | i kstd S )N)r   r   fftr   )r!   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 ks,t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   r   )Zcdllfr   r   r   test_NPY_NO_EXPORTu   s    r7   c             C   s   g | ]}d | qS )znumpy.r   ).0sr   r   r   
<listcomp>   s    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versionz
numpy.charznumpy.emathz	numpy.recc             C   s   g | ]}d | qS )znumpy.r   )r8   r9   r   r   r   r:      s    )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| ksd| ksd| krdS | t kr(dS | tkr4dS | tk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    rF   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   s\   g } x@t jtjtjd ddD ]$\}}}t|r|tkr| | qW | rXt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   rF   	SKIP_LISTappendr   )modnames_modnameispkgr   r   r   test_all_modules_are_expectedQ  s    
rS   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   sB   dd } | d}xt D ]}|| | qW |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   s|   g }t | }t|dr |j}nt|}xN|D ]F}|ds.| d | }tt||tj	r.t
|r.|tkr.|| q.W |S )N__all__rP   r   )	importlibimport_moduler   rT   r   
startswith
isinstancer   types
ModuleTyperF   SKIP_LIST_2rN   )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)rC   extendr   format)r^   Zunexpected_membersrQ   r   r   r   test_all_modules_are_expected_2z  s    
rb   c           	   C   s   dd } g }xt D ]}| |s|| qW |r>td|x8tD ]0}yt| W qD tk
rr   || Y qDX qDW |rtd|tjddB}tj	dt
d tj	dtd xtD ]}| |s|| qW W d	Q R X |rt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,   yt |  W n ttfk
r&   dS X dS )NFT)rU   rV   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: {})rC   rN   r   ra   rD   evalrd   warningscatch_warningsfilterwarningsDeprecationWarningImportWarningrE   )re   Zmodule_namesr	   wr   r   r   test_api_importable  s2    


rp   )N)r   r%   rJ   rY   rU   rj   r_   r   Zpytestr2   rc   r   r"   markZparametrizer)   r,   r.   r0   Zskipifr7   rC   rD   rE   rF   rM   rS   r[   rb   rp   r   r   r   r   <module>   sl   

0(w4