zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
U
P±dAã@sžddlZddlZddlZddlZddlZddlZddlZddlZddlZddl    Z    ddl
m Z z ddl Z Wne k
r€dZ YnXdGdd„Zdd„Ze    jje dde    j d    d
d g¡d d „ƒƒZdd„Zdd„Zdd„Ze    jje dkdddd„ƒZdd„dDƒZdddgZdd„dDƒZdd „Zd!d"d#d$d%d&d'd(d)d*d+g Zd,d-„Zd.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>gZd?d@„ZdAdB„Z e    jj!e "dC¡dk    dDddEdF„ƒZ#dS)HéN)ÚIS_WASMcCs`|dkr|j}i}t|ƒD]@}t||ƒ}t|dƒrt|dƒr|j|kr|jd|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úRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/tests/test_public_api.pyÚ    check_dirs 
ÿrcCsJdddddddddd    d
d d d dddddddœ}|}ttƒ}||ksFt‚dS)Nz,numpy.testing._private.nosetester.NoseTesterz.numpy.core._multiarray_umath._add_newdoc_ufuncz*numpy.core._multiarray_umath.add_docstringz#numpy.core.function_base.add_newdocznumpy.lib.utils.byte_boundsz/numpy.core._multiarray_umath.compare_chararraysznumpy.lib.utils.deprecatez"numpy.lib.utils.deprecate_with_docznumpy.lib.function_base.dispz1numpy.core._multiarray_umath.fastCopyAndTransposez#numpy.lib.shape_base.get_array_wrapznumpy.lib.utils.get_includeznumpy.lib.npyio.recfromcsvznumpy.lib.npyio.recfromtxtznumpy.lib.utils.safe_evalz)numpy.core.arrayprint.set_string_functionznumpy.__config__.showznumpy.lib.utils.show_runtimeznumpy.lib.utils.who)ÚTesterZ_add_newdoc_ufuncZ add_docstringZ
add_newdocZadd_newdoc_ufuncZ byte_boundsZcompare_chararraysZ    deprecateZdeprecate_with_docZdispZfastCopyAndTransposeZget_array_wrapZ get_includeZ
recfromcsvZ
recfromtxtZ    safe_evalZset_string_functionZ show_configZ show_runtimeZwho)rÚnpÚAssertionError)Z undocumentedZ    allowlistÚ bad_resultsrrrÚtest_numpy_namespace!s0ìrzcan't start subprocess)Úreasonr ÚtestingrcCs6tjdd|f}t |¡}|r"t‚|ttƒks2t‚dS)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-czimport numpy; numpy.N)ÚsysÚ
executableÚ
subprocessÚ check_outputrrr)r ZexeÚresultrrrÚtest_import_lazy_importBs
rcCs$tttƒƒttttƒƒƒks t‚dS)zWAssert that output of dir has only one "testing/tester"
    attribute without duplicateN)ÚlenrrÚsetrrrrrÚtest_dir_testingYsr cCsttjƒ}|ikst‚dS©N)rrÚlinalgr©rrrrÚtest_numpy_linalg_s
r$cCsttjƒ}|ikst‚dSr!)rrÚfftrr#rrrÚtest_numpy_fftds
r&z#ctypes not available in this pythoncCs0t tjjj¡}t|ddƒ}|dks,tdƒ‚dS)NZtest_not_exportedzG'test_not_exported' is mistakenly exported, NPY_NO_EXPORT does not work)ÚctypesÚCDLLrÚcoreZ_multiarray_testsÚ__file__rr)ÚcdllÚfrrrÚtest_NPY_NO_EXPORTis r-cCsg|] }d|‘qS©znumpy.r©Ú.0ÚsrrrÚ
<listcomp>sr2)%Ú    array_apizarray_api.linalgZ    ctypeslibÚ    distutilszdistutils.cpuinfozdistutils.exec_commandzdistutils.misc_utilz distutils.logzdistutils.system_infoÚdocz doc.constantsz
doc.ufuncsZf2pyr%Úlibz
lib.formatz
lib.mixinszlib.recfunctionsz lib.scimathzlib.stride_tricksr"Úmaz    ma.extrasz ma.mrecordsZmatlibZ
polynomialzpolynomial.chebyshevzpolynomial.hermitezpolynomial.hermite_ezpolynomial.laguerrezpolynomial.legendrezpolynomial.polynomialÚrandomrÚtypingztyping.mypy_pluginÚversionz
numpy.charz numpy.emathz    numpy.reccCsg|] }d|‘qSr.rr/rrrr2¯s)tÚcompatz compat.py3kZconftestr)zcore.arrayprintzcore.defchararrayzcore.einsumfunczcore.fromnumericzcore.function_basezcore.getlimitsz core.memmapzcore.multiarrayz core.numericzcore.numerictypeszcore.overridesz core.recordszcore.shape_basez
core.umathzcore.umath_testszdistutils.armccompilerzdistutils.ccompilerzdistutils.ccompiler_optzdistutils.commandzdistutils.command.autodistzdistutils.command.bdist_rpmzdistutils.command.buildzdistutils.command.build_clibzdistutils.command.build_extzdistutils.command.build_pyzdistutils.command.build_scriptszdistutils.command.build_srczdistutils.command.configz!distutils.command.config_compilerzdistutils.command.developzdistutils.command.egg_infozdistutils.command.installzdistutils.command.install_clibzdistutils.command.install_dataz!distutils.command.install_headerszdistutils.command.sdistzdistutils.conv_templatezdistutils.corezdistutils.extensionzdistutils.fcompilerzdistutils.fcompiler.absoftzdistutils.fcompiler.armzdistutils.fcompiler.compaqzdistutils.fcompiler.environmentzdistutils.fcompiler.g95zdistutils.fcompiler.gnuzdistutils.fcompiler.hpuxzdistutils.fcompiler.ibmzdistutils.fcompiler.intelzdistutils.fcompiler.laheyzdistutils.fcompiler.mipszdistutils.fcompiler.nagzdistutils.fcompiler.nonezdistutils.fcompiler.pathf95zdistutils.fcompiler.pgzdistutils.fcompiler.nvzdistutils.fcompiler.sunzdistutils.fcompiler.vastzdistutils.fcompiler.fujitsuzdistutils.from_templatezdistutils.intelccompilerzdistutils.lib2defzdistutils.line_endingszdistutils.mingw32ccompilerzdistutils.msvccompilerzdistutils.npy_pkg_configzdistutils.numpy_distributionzdistutils.pathccompilerzdistutils.unixccompilerZdualz f2py.auxfuncszf2py.capi_mapsz f2py.cb_rulesz f2py.cfuncszf2py.common_ruleszf2py.crackfortranz f2py.diagnosez f2py.f2py2ezf2py.f90mod_ruleszf2py.func2subrz
f2py.rulesz f2py.symboliczf2py.use_rulesz
fft.helperz lib.arraypadzlib.arraysetopszlib.arrayteratorzlib.function_basezlib.histogramszlib.index_trickszlib.nanfunctionsz    lib.npyiozlib.polynomialzlib.shape_basezlib.twodim_basezlib.type_checkz lib.ufunclikezlib.user_arrayz    lib.utilszlinalg.lapack_litez linalg.linalgzma.benchzma.corez ma.testutilszma.timer_comparisonZ    matrixlibzmatrixlib.defmatrixzpolynomial.polyutilsz random.mtrandzrandom.bit_generatorztesting.print_coercion_tablesz testing.utilscCsDd|ksd|ksd|krdS|tkr(dS|tkr4dS|tkr@dSdS)z%Check if this needs to be considered.z._z.testsz.setupFT)ÚPUBLIC_MODULESÚPUBLIC_ALIASED_MODULESÚPRIVATE_BUT_PRESENT_MODULES©r rrrÚ is_unexpected'sr@znumpy.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.code_generators.generate_umath_docznumpy.core.cversionsznumpy.core.generate_numpy_apiznumpy.distutils.msvc9compilercCsXg}tjtjtjdddD]$\}}}t|ƒr|tkr| |¡q|rTtd|›ƒ‚dS)z|
    Test that we don't add anything that looks like a new public module by
    accident.  Check is based on filenames.
    rN)ÚpathÚprefixÚonerrorzFound unexpected modules: )    ÚpkgutilÚ walk_packagesrÚ__path__rr@Ú    SKIP_LISTÚappendr)ÚmodnamesÚ_ÚmodnameÚispkgrrrÚtest_all_modules_are_expectedIsþ rMz
numpy.mathznumpy.distutils.log.sysznumpy.distutils.log.loggingznumpy.distutils.log.warningsznumpy.doc.constants.reznumpy.doc.constants.textwrapznumpy.lib.emathznumpy.lib.mathznumpy.matlib.charznumpy.matlib.recznumpy.matlib.emathznumpy.matlib.mathznumpy.matlib.linalgznumpy.matlib.fftznumpy.matlib.randomznumpy.matlib.ctypeslibznumpy.matlib.macCs>dd„}|dƒ}tD]}| ||ƒ¡q|r:td |¡ƒ‚dS)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)
 
    cSsxg}t |¡}t|dƒr |j}nt|ƒ}|D]F}| d¡s,|d|}tt||ƒtj    ƒr,t
|ƒr,|t kr,|  |¡q,|S)NÚ__all__rJr) Ú    importlibÚ import_modulerrNrÚ
startswithÚ
isinstancerÚtypesÚ
ModuleTyper@Ú SKIP_LIST_2rH)Úmod_nameÚmembersr    ZobjnamesZobjnameZ fullobjnamerrrÚfind_unexpected_memberss
 
 
  z@test_all_modules_are_expected_2.<locals>.find_unexpected_membersÚnumpyz5Found unexpected object(s) that look like modules: {}N)r<ÚextendrÚformat)rXZunexpected_membersrKrrrÚtest_all_modules_are_expected_2tsÿr\c    Csèdd„}g}tD]}||ƒs| |¡q|r:td |¡ƒ‚tD]0}z t|ƒWq>tk
rl| |¡Yq>Xq>|r‚td |¡ƒ‚tjdd>}tj    dt
dtj    dt dt D]}||ƒs°| |¡q°W5QRX|rätd     |¡ƒ‚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    Ss.zt |¡Wnttfk
r(YdSXdS)NFT)rOrPÚ ImportErrorÚAttributeError)r
rrrÚ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)ÚcategoryzPModules that are not really public but looked public and can not be imported: {}N) r<rHrr[r=Úevalr^ÚwarningsÚcatch_warningsÚfilterwarningsÚDeprecationWarningÚ ImportWarningr>)r_Z module_namesr
ÚwrrrÚtest_api_importable¨s8 ÿ ÿþrjÚPy_DEBUGz£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/19800cCs²tj ¡}z|jdd}Wn tk
r:| dg¡}YnXt|ƒdksPtdƒ‚ztdd„|Dƒƒ}Wnt    k
r„tdƒd‚YnX| 
¡}d    |j ›d
}|t j ks®t|ƒ‚dS) z}
    Entry point for Array API implementation can be found with importlib and
    returns the numpy.array_api namespace.
    r3)Úgrouprz%No entry points for 'array_api' foundcss|]}|jdkr|VqdS)rYNr?)r0ÚeprrrÚ    <genexpr>ñs
z-test_array_api_entry_point.<locals>.<genexpr>z%'numpy' not in array_api entry pointsNznumpy entry point value 'z0' does not point to our Array API implementation)rOÚmetadataZ entry_pointsÚselectr^ÚgetrrÚnextÚ StopIterationÚloadÚvaluerYr3)ZepsZxp_epsrmZxpÚmsgrrrÚtest_array_api_entry_pointØs
 ÿrw)N)$rÚ    sysconfigrrDrSrOrdrYrZpytestZ numpy.testingrr'r]rrÚmarkZskipifZ parametrizerr r$r&r-r<r=r>r@rGrMrUr\rjZxfailÚget_config_varrwrrrrÚ<module>sŽ  
 
!  ÿ
*ýxõï40 ý